Skip to content
Browse files

Run all spec tasks even when a failure occurs.

This will also set the final exit status to one of the failing statuses if
a failure occurs. Obviously, since there can only be one final exit status,
there is only one value possible if more than one spec process fails. But the
main point is to exit with some error status if some spec process fails.
  • Loading branch information...
1 parent 1b068bd commit 02d7caab6ec7aca698935b4bcd5a160bc8c4f078 @brixen brixen committed Apr 11, 2012
Showing with 29 additions and 13 deletions.
  1. +29 −13 Rakefile
View
42 Rakefile
@@ -88,20 +88,36 @@ ENV['CXX'] = BUILD_CONFIG[:cxx] unless ENV['CXX']
$dlext = RbConfig::CONFIG["DLEXT"]
$CC = ENV['CC']
-def run_specs(flags=nil)
- unless File.directory? BUILD_CONFIG[:runtime]
- # Setting these enables the specs to run when rbx has been configured
- # to be installed, but rake install has not been run yet.
- ENV["RBX_RUNTIME"] = File.expand_path "../runtime", __FILE__
- ENV["RBX_LIB"] = File.expand_path "../lib", __FILE__
- ENV["CFLAGS"] = "-Ivm/capi"
- end
+class SpecRunner
+ attr_reader :exit_status
+
+ def initialize
+ @exit_status = 0
+
+ unless File.directory? BUILD_CONFIG[:runtime]
+ # Setting these enables the specs to run when rbx has been configured
+ # to be installed, but rake install has not been run yet.
+ ENV["RBX_RUNTIME"] = File.expand_path "../runtime", __FILE__
+ ENV["RBX_LIB"] = File.expand_path "../lib", __FILE__
+ ENV["CFLAGS"] = "-Ivm/capi"
+ end
- ENV.delete("RUBYOPT")
+ ENV.delete("RUBYOPT")
+
+ @handler = lambda do |ok, status|
+ @exit_status = status.exitstatus unless ok
+ end
+ end
- sh "bin/mspec ci #{ENV['CI_MODE_FLAG'] || flags} -d --background"
+ def run(flags=nil)
+ sh("bin/mspec ci #{ENV['CI_MODE_FLAG'] || flags} -d --background", &@handler)
+ end
end
+spec_runner = SpecRunner.new
+
+at_exit { exit spec_runner.exit_status }
+
task :default => :spec
task :github do
@@ -203,17 +219,17 @@ end
desc "Run the CI specs in 1.8 mode but do not rebuild on failure"
task :spec18 => %w[build vm:test] do
- run_specs "-T -X18"
+ spec_runner.run "-T -X18"
end
desc "Run the CI specs in 1.9 mode but do not rebuild on failure"
task :spec19 => %w[build vm:test] do
- run_specs "-T -X19"
+ spec_runner.run "-T -X19"
end
desc "Run the CI specs in 2.0 mode but do not rebuild on failure"
task :spec20 => %w[build vm:test] do
- run_specs "-T -X20"
+ spec_runner.run "-T -X20"
end
desc "Run CI in default (configured) mode but do not rebuild on failure"

0 comments on commit 02d7caa

Please sign in to comment.
Something went wrong with that request. Please try again.