Ruby rake/testtask producing incorrect command
I have tests for my project broken up into multiple files - test/test_1.rb and test/test_2.rb.
Running 'rake test' gives:
$ rake test
ruby -I"lib:test" -I"/foo/rake-0.9.2/lib" "/foo/rake_test_loader.rb" "test/test_general.rb test/test_cv.rb"
/home/rob/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:11:in `require': no such file to load -- /home/rob/src/robsyme/bioruby-chado/test/test_general.rb test/test_cv.rb (LoadError)
... #you can guess the rest
Note the last argument in the ruby command : "test/test_general.rb test/test_cv.rb"
If I remove the quotes (splitting the last argument into two arguments), the tests run perfectly.
- Why would rake's test开发者_StackOverflow runner be grouping the two files together into the one argument?
- Am I doing something wrong with the rake test setup?
Environment:
$ grep -A4 TestTask Rakefile
Rake::TestTask.new(:test) do |test|
test.libs << 'test'
test.pattern = FileList['test/**/test_*.rb']
test.verbose = true
end
$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
$ gem --version
1.8.10
$ rake --version
rake, version 0.9.2
Added:
test.test_files = FileList['test/test*.rb']
File list should be given to test files not to pattern. To pattern I suppose you can give a pattern as a string.
Previous answer (misunderstood question)
That's just how the shell works. You can quote a filename if you want to target a filename that has space in it. It then get's passed as one argument and not two.
$ cat > "foo bar"
foobar
^D
$ cat foo\ bar
foobar
$ cat "foo bar"
foobar
or
$ ls "Rakefile Gemfile"
ls: Rakefile Gemfile: No such file or directory
$ ls Rakefile Gemfile
Gemfile Rakefile
精彩评论