Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
masa-kunikata opened this issue Dec 24, 2019 · 4 comments

Comments

@masa-kunikata
Copy link

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

@masa-kunikata
Copy link
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

@deivid-rodriguez
Copy link
Contributor

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

@masa-kunikata
Copy link
Author

masa-kunikata commented Jun 14, 2020

@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

@deivid-rodriguez
Copy link
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
Labels
None yet
Development

No branches or pull requests

2 participants