Reputation: 85
I have installed, Ruby 1.8.7, ci_reporter 1.8.4, test unit 2.5.4, rake 10.0.3.
My testA.rb, testB.rb ... testZ.rb :
require 'includeA.rb'
require 'includeB.rb'
require 'includeC.rb'
require 'includeD.rb'
Begin of the code...
... End of the code
Here my rakefile :
require 'rake/testtask'
require 'rubygems'
gem 'ci_reporter'
gem 'test-unit'
require 'test/unit'
require 'ci/reporter/rake/test_unit'
task :default => [:test]
task :test do
sh "ruby -I E:/pathToIncludesA/" " -I E:/pathToIncludesB/" " -I E:/pathToIncludesC/" " -I E:/pathToIncludesD/" " E:/pathToTests/testA.rb"
sh "ruby -I E:/pathToIncludesA/" " -I E:/pathToIncludesB/" " -I E:/pathToIncludesC/" " -I E:/pathToIncludesD/" " E:/pathToTests/testB.rb"
...
sh "ruby -I E:/pathToIncludesA/" " -I E:/pathToIncludesB/" " -I E:/pathToIncludesC/" " -I E:/pathToIncludesD/" " E:/pathToTests/testZ.rb"
end
And I launch the test execution with :
rake CI_REPORTER=reports test
All works fine, but now a lot of tests will be added in my "pathToTest" and now I would like to run all the tests but with a single cmd in my rakefile.
I try this from a windows batch cmd : for /r "E:\ExempleOfTests\" %%i in (*.rb) do ruby "%%i"
It runs all the .rb files in the folder ExempleOfTests.
So now I am refactoring my rakefile, trying to incorporate the windows batch cmd.
Here my new rakefile :
require 'rake/testtask'
require 'rubygems'
gem 'ci_reporter'
gem 'test-unit'
require 'test/unit'
require 'ci/reporter/rake/test_unit'
task :default => [:test]
task :test do
sh "for /r E:/pathToTests/ %%i in (*.rb) do ruby -I E:/pathToIncludesA/ -I E:/pathToIncludesB/ -I E:/pathToIncludesC/ -I E:/pathToIncludesD/ %%i"
end
But my output console when I launch with "rake CI_REPORTS=reports test" :
unexpected %%i
rake aborted
commande failed with status (1) ...
Could someone help me?
Upvotes: 3
Views: 1587
Reputation: 2187
You can run it like this:
find path/to/test/folder -name '*_test.rb' | xargs -n1 -I{} bundle exec ruby -Itest {}
and then wrap it into rake task if you want.
Upvotes: 2