File tree Expand file tree Collapse file tree 3 files changed +31
-7
lines changed Expand file tree Collapse file tree 3 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ def perform(*args)
32
32
run_prepare_task if self . args . none? ( EXACT_TEST_ARGUMENT_PATTERN )
33
33
Rails ::TestUnit ::Runner . run ( args )
34
34
rescue Rails ::TestUnit ::InvalidTestError => error
35
- say error . message
35
+ raise ArgumentError , error . message
36
36
end
37
37
38
38
# Define Thor tasks to avoid going through Rake and booting twice when using bin/rails test:*
Original file line number Diff line number Diff line change @@ -58,15 +58,20 @@ def load_tests(argv)
58
58
patterns = extract_filters ( argv )
59
59
tests = list_tests ( patterns )
60
60
tests . to_a . each do |path |
61
- require File . expand_path ( path )
61
+ abs_path = File . expand_path ( path )
62
+ require abs_path
62
63
rescue LoadError => exception
63
- all_tests = list_tests ( [ default_test_glob ] )
64
- corrections = DidYouMean ::SpellChecker . new ( dictionary : all_tests ) . correct ( path )
64
+ if exception . path == abs_path
65
+ all_tests = list_tests ( [ default_test_glob ] )
66
+ corrections = DidYouMean ::SpellChecker . new ( dictionary : all_tests ) . correct ( path )
65
67
66
- if corrections . empty?
67
- raise exception
68
+ if corrections . empty?
69
+ raise exception
70
+ end
71
+ raise InvalidTestError . new ( path , DidYouMean ::Formatter . message_for ( corrections ) )
72
+ else
73
+ raise
68
74
end
69
- raise InvalidTestError . new ( path , DidYouMean ::Formatter . message_for ( corrections ) )
70
75
end
71
76
end
72
77
Original file line number Diff line number Diff line change @@ -971,6 +971,25 @@ def test_did_you_mean_when_specified_file_name_is_close
971
971
972
972
assert_match ( %r{Could not load test file.+test/models/accnt\. rb} , output )
973
973
assert_match ( %r{Did you mean?.+test/models/account_test\. rb} , output )
974
+ assert_not_predicate $?, :success?
975
+ end
976
+
977
+ def test_unrelated_load_error
978
+ app_file "test/models/account_test.rb" , <<-RUBY
979
+ require "test_helper"
980
+
981
+ require "does-not-exist"
982
+
983
+ class AccountsTest < ActiveSupport::TestCase
984
+ def test_truth
985
+ assert true
986
+ end
987
+ end
988
+ RUBY
989
+
990
+ output = run_test_command ( "test/models/account_test.rb" )
991
+ assert_match ( "cannot load such file -- does-not-exist" , output )
992
+ assert_not_predicate $?, :success?
974
993
end
975
994
976
995
def test_pass_TEST_env_on_rake_test
You can’t perform that action at this time.
0 commit comments