lib/grntest/worker.rb in grntest-1.2.9 vs lib/grntest/worker.rb in grntest-1.3.0

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright (C) 2012-2016 Kouhei Sutou <kou@clear-code.com> +# Copyright (C) 2012-2018 Kouhei Sutou <kou@clear-code.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. @@ -97,16 +97,17 @@ unless @suite_name == suite_name @reporter.on_suite_finish(self) if @suite_name @suite_name = suite_name @reporter.on_suite_start(self) end - @test_script_path = test_script_path - @test_name = test_name - runner = TestRunner.new(@tester, self) - succeeded = false unless runner.run + unless run_test(test_script_path, test_name) + succeeded = false + end + break if interruptted? + if @tester.stop_on_failure? and @test_suites_result.have_failure? break end end @status = "finished" @@ -160,10 +161,34 @@ end def on_test_finish(result) @result.on_test_finish @reporter.on_test_finish(self, result) - @test_script_path = nil - @test_name = nil + end + + private + def run_test(test_script_path, test_name) + begin + @test_script_path = test_script_path + @test_name = test_name + + n = -1 + loop do + n += 1 + + runner = TestRunner.new(@tester, self) + return true if runner.run + + if n < @tester.n_retries and not interruptted? + @test_suites_result.n_total_tests += 1 + next + end + + return false + end + ensure + @test_script_path = nil + @test_name = nil + end end end end