镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Rake::TestTask raises an error when the test path includes non-ascii characters on Windows #332

Description

@masa-kunikata

When a test file path includes non-ascii characters, rake test task Rake::TestTask fails with a message

File does not exist: [test_target_file_name]

It seems the task can't find a file with non-ascii path on Windows.


Summary page including a procedure for reproducing
https://github.com/masa-kunikata/rake_test_task_non_ascii_path

Activity

  1. masa-kunikata commented on Dec 26, 2019

    @masa-kunikata
    Author

    I think the cause of this error is Ruby's bug.

    The Rake::TestTask job is executing an external ruby process.
    The external process calls rake_test_loader.rb with ruby's command -I option.
    When the current directory path includes non-ascii character, require fails because of ruby's bug reported below.

    Non-ASCII characters in the path to ruby executable break require paths
    https://bugs.ruby-lang.org/issues/9737

    A case "require" fails when current directory path contains Japanese character
    https://bugs.ruby-lang.org/issues/13863#note-5

  2. deivid-rodriguez commented on Jun 12, 2020

    @deivid-rodriguez
    Contributor

    Do you still have this problem? Could you check whether #357 fixes it?

  3. masa-kunikata commented on Jun 14, 2020

    @masa-kunikata
    Author

    @deivid-rodriguez
    Thank you for your reply!!!

    It seems that the error occurs even with the #357 patch.

    Though the error message is different from the original one,
    I think the root cause is the same and it lies in Ruby itself.


    Summary

    current dir -> Non ascii path
    "あいうえお"
    Ascii path
    "abcde"
    rake v13.0.1 Error
    File does not exist: target
    OK
    rake v13.0.1
    patched #357 PR
    Error
    cannot load such file -- target (LoadError)
    OK

    Details

    • Non ascii path current directory

      C:\temp\rake_test_task_non_ascii_path\あいうえお>rake

    (Error) rake v13.0.1
    C:/Ruby26-x64/bin/ruby.exe -w -I"lib;lib;test" -I"C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib" "C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_test_loader.rb" "test/target_test.rb"
    

    File does not exist: target

    rake aborted!
    Command failed with status (1): [ruby -w -I"lib;lib;test" -I"C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib" "C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_test_loader.rb" "test/target_test.rb" ]

    Tasks: TOP => default => tsk
    (See full trace by running task with --trace)

    (Error) rake v13.0.1 patched #357 PR
    C:/Ruby26-x64/bin/ruby.exe -w -I"lib;lib;test" -rC:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_test_loader "test/target_test.rb"
    Traceback (most recent call last):
            2: from test/target_test.rb:2:in `'
            1: from C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- target (LoadError)
    rake aborted!
    Command failed with status (1): [ruby -w -I"lib;lib;test" -rC:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_test_loader "test/target_test.rb" ]
    
    Tasks: TOP => default => tsk
    (See full trace by running task with --trace)
    
    
    • Ascii path current directory

      C:\temp\rake_test_task_non_ascii_path\abcde>rake

    (OK) rake v13.0.1
    C:/Ruby26-x64/bin/ruby.exe -w -I"lib;lib;test" -I"C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib" "C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_test_loader.rb" "test/target_test.rb"
    Loaded suite C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_test_loader
    Started
    .
    Finished in 0.0015035 seconds.
    ------------------------------------------------------------------------------------------------------------------------
    1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
    100% passed
    ------------------------------------------------------------------------------------------------------------------------
    665.11 tests/s, 665.11 assertions/s
    
    (OK) rake v13.0.1 patched #357 PR
    C:/Ruby26-x64/bin/ruby.exe -w -I"lib;lib;test" -rC:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_test_loader "test/target_test.rb"
    Loaded suite test/target_test
    Started
    .
    Finished in 0.0012415 seconds.
    ------------------------------------------------------------------------------------------------------------------------
    1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
    100% passed
    ------------------------------------------------------------------------------------------------------------------------
    805.48 tests/s, 805.48 assertions/s
    
  4. deivid-rodriguez commented on Jun 14, 2020

    @deivid-rodriguez
    Contributor

    Right, I figured that would be the case, but since the crashing code is no longer hit with #357 I figured it was worth trying just to make sure! In any case, it wouldn't have really fixed the root cause, only circumvent it.

    I hope your issue gets fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions