Created
February 8, 2012 22:38
-
-
Save jsl/1775007 to your computer and use it in GitHub Desktop.
Hacked SubTestTask that allows exit status to be returned after failing tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Rails | |
# Don't abort when tests fail; move on the next test task. | |
# Silence the default description to cut down on `rake -T` noise. | |
class SubTestTask < Rake::TestTask | |
# Create the tasks defined by this task lib. | |
def define | |
lib_path = @libs.join(File::PATH_SEPARATOR) | |
task @name do | |
puts "running sub test task #{@name}" | |
run_code = '' | |
RakeFileUtils.verbose(@verbose) do | |
run_code = | |
case @loader | |
when :direct | |
"-e 'ARGV.each{|f| load f}'" | |
when :testrb | |
"-S testrb #{fix}" | |
when :rake | |
rake_loader | |
end | |
@ruby_opts.unshift( "-I\"#{lib_path}\"" ) | |
@ruby_opts.unshift( "-w" ) if @warning | |
begin | |
ruby(ruby_command(run_code)) { |ok, res| at_exit { exit res.exitstatus } unless ok } | |
rescue => error | |
warn "Error running #{name}: #{error.inspect}" | |
end | |
end | |
end | |
self | |
end | |
private | |
def ruby_command run_code | |
@ruby_opts.join(" ") + | |
" \"#{run_code}\" " + | |
file_list.collect { |fn| "\"#{fn}\"" }.join(' ') + | |
" #{option_list}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment