Skip to content

Commit

Permalink
Make it possible to fail fast in isolated run
Browse files Browse the repository at this point in the history
  • Loading branch information
Genki-S committed Aug 3, 2015
1 parent 012d484 commit 27d1712
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ttnt/testtask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def define_run_task
tests.each do |test|
args = "#{@rake_testtask.ruby_opts_string} #{test} #{@rake_testtask.option_list}"
run_ruby args
break if @failed && ENV['FAIL_FAST']
end
else
args =
Expand Down Expand Up @@ -117,6 +118,7 @@ def define_anchor_task
# @param args [String] argument to pass to ruby
def run_ruby(args)
ruby "#{args}" do |ok, status|
@failed = true if !ok
if !ok && status.respond_to?(:signaled?) && status.signaled?
raise SignalException.new(status.termsig)
end
Expand Down
12 changes: 12 additions & 0 deletions test/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ def test_isolated
ENV.delete('ISOLATED')
assert_equal 3, output[:stdout].split('# Running:').count
end

def test_isolated_with_fail_fast
@repo.checkout('change_fizz')
fizzbuzz_file = "#{@repo.workdir}/fizzbuzz.rb"
File.write(fizzbuzz_file, File.read(fizzbuzz_file).gsub(/"buzz"$/, '"bar"'))
ENV['ISOLATED'] = '1'
ENV['FAIL_FAST'] = '1'
output = rake('ttnt:test:run')
ENV.delete('ISOLATED')
ENV.delete('FAIL_FAST')
assert_equal 2, output[:stdout].split('Failure:').count
end
end

class AdditionAmongComments < TTNT::TestCase::AdditionAmongComments
Expand Down

0 comments on commit 27d1712

Please sign in to comment.