diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2015-09-28 20:27:30 +0200 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2015-09-29 08:37:33 +0200 |
commit | 2310fb9d810f11681c1eecdb88518c23c8b379cf (patch) | |
tree | 969834f7a9f74738c4ad208418372b802b754f66 /railties/lib | |
parent | 64a3b09b408400c94fd25f22c2ce791a8d90b5cb (diff) | |
download | rails-2310fb9d810f11681c1eecdb88518c23c8b379cf.tar.gz rails-2310fb9d810f11681c1eecdb88518c23c8b379cf.tar.bz2 rails-2310fb9d810f11681c1eecdb88518c23c8b379cf.zip |
Add fail fast to test runner.
Passing `--fail-fast` to the test runner will now abort the test run
on the first failure. The run continues on any unexpected errors.
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/test_unit/minitest_plugin.rb | 5 | ||||
-rw-r--r-- | railties/lib/rails/test_unit/reporter.rb | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/railties/lib/rails/test_unit/minitest_plugin.rb b/railties/lib/rails/test_unit/minitest_plugin.rb index b65d67b2a5..3a0a58df88 100644 --- a/railties/lib/rails/test_unit/minitest_plugin.rb +++ b/railties/lib/rails/test_unit/minitest_plugin.rb @@ -33,6 +33,11 @@ module Minitest options[:output_inline] = false end + opts.on("-f", "--fail-fast", + "Abort test run on first failure") do + options[:fail_fast] = true + end + options[:patterns] = opts.order! end diff --git a/railties/lib/rails/test_unit/reporter.rb b/railties/lib/rails/test_unit/reporter.rb index c88e9aa60e..8f1116b6af 100644 --- a/railties/lib/rails/test_unit/reporter.rb +++ b/railties/lib/rails/test_unit/reporter.rb @@ -17,6 +17,10 @@ module Rails io.puts format_rerun_snippet(result) io.puts end + + if fail_fast? && result.failure && !result.error? && !result.skipped? + raise Interrupt + end end def report @@ -48,6 +52,10 @@ module Rails options.fetch(:output_inline, true) end + def fail_fast? + options[:fail_fast] + end + def format_rerun_snippet(result) location, line = result.method(result.name).source_location "#{self.executable} #{relative_path_for(location)}:#{line}" |