aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2016-02-15 14:59:03 +0100
committerYves Senn <yves.senn@gmail.com>2016-02-15 15:19:16 +0100
commitea70c295ffc7b335ed6c587f4060746e8b59d833 (patch)
tree9f75790319b11197986e5f231da92affa4c7c23a
parent7c3dc9632b2ae2feca90f5b1f88b9ce3ca5fbba9 (diff)
downloadrails-ea70c295ffc7b335ed6c587f4060746e8b59d833.tar.gz
rails-ea70c295ffc7b335ed6c587f4060746e8b59d833.tar.bz2
rails-ea70c295ffc7b335ed6c587f4060746e8b59d833.zip
Revert "Prefer Minitest's location for test failures."
This reverts commit 0db310586ac3e15be95d2ef27ff40cfa24c05c10. Closes #23686. Conflicts: railties/test/application/test_runner_test.rb It's possible that the `result.location` returned by minitest is outside the test file itself. For example in the case of mocha. This resulted in bad rerun snipptets: ``` bin/rails test app/models/deliveries/delivery.rb:103 ``` Let's always use the first line of the failed test-case in our rerun snippet. We can display the line number of the assertion error elsewhere.
-rw-r--r--railties/lib/rails/test_unit/reporter.rb10
-rw-r--r--railties/test/application/test_runner_test.rb2
2 files changed, 3 insertions, 9 deletions
diff --git a/railties/lib/rails/test_unit/reporter.rb b/railties/lib/rails/test_unit/reporter.rb
index 73b8d7d27b..317726f672 100644
--- a/railties/lib/rails/test_unit/reporter.rb
+++ b/railties/lib/rails/test_unit/reporter.rb
@@ -73,14 +73,8 @@ module Rails
end
def format_rerun_snippet(result)
- # Try to extract path to assertion from backtrace.
- if result.location =~ /\[(.*)\]\z/
- assertion_path = $1
- else
- assertion_path = result.method(result.name).source_location.join(':')
- end
-
- "#{self.executable} #{relative_path_for(assertion_path)}"
+ location, line = result.method(result.name).source_location
+ "#{self.executable} #{relative_path_for(location)}:#{line}"
end
def app_root
diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb
index 7ecadb60ca..5a6119c483 100644
--- a/railties/test/application/test_runner_test.rb
+++ b/railties/test/application/test_runner_test.rb
@@ -467,7 +467,7 @@ module ApplicationTests
create_test_file :models, 'post', pass: false
output = run_test_command('test/models/post_test.rb')
- expect = %r{Running:\n\nPostTest\nF\n\nFailure:\nPostTest#test_truth:\nwups!\n\nbin/rails test test/models/post_test.rb:6\n\n\n\n}
+ expect = %r{Running:\n\nPostTest\nF\n\nFailure:\nPostTest#test_truth:\nwups!\n\nbin/rails test test/models/post_test.rb:4\n\n\n\n}
assert_match expect, output
end