File tree 2 files changed +34
-17
lines changed
2 files changed +34
-17
lines changed Original file line number Diff line number Diff line change 3
3
4
4
# Load the test files from the command line.
5
5
argv = ARGV . select do |argument |
6
- begin
7
- case argument
8
- when /^-/ then
9
- argument
10
- when /\* / then
11
- FileList [ argument ] . to_a . each do |file |
12
- require File . expand_path file
13
- end
6
+ case argument
7
+ when /^-/ then
8
+ argument
9
+ when /\* / then
10
+ FileList [ argument ] . to_a . each do |file |
11
+ require File . expand_path file
12
+ end
14
13
15
- false
16
- else
17
- require File . expand_path argument
14
+ false
15
+ else
16
+ path = File . expand_path argument
18
17
19
- false
20
- end
21
- rescue LoadError => e
22
- raise unless e . path
23
- abort " \n File does not exist: #{ e . path } \n \n "
18
+ abort " \n File does not exist: #{ path } \n \n " unless File . exist? ( path )
19
+
20
+ require path
21
+
22
+ false
24
23
end
25
24
end
26
25
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ def test_pattern
24
24
$:. replace orig_loaded_features
25
25
end
26
26
27
- def test_load_error_from_require
27
+ def test_load_error_from_missing_test_file
28
28
out , err = capture_io do
29
29
ARGV . replace %w[ no_such_test_file.rb ]
30
30
@@ -45,6 +45,24 @@ def test_load_error_from_require
45
45
assert_match expected , err
46
46
end
47
47
48
+ def test_load_error_raised_implicitly
49
+ File . write ( "error_test.rb" , "require 'superkalifragilisticoespialidoso'" )
50
+ out , err = capture_io do
51
+ ARGV . replace %w[ error_test.rb ]
52
+
53
+ exc = assert_raises ( LoadError ) do
54
+ load @loader
55
+ end
56
+ if RUBY_ENGINE == "jruby"
57
+ assert_equal "no such file to load -- superkalifragilisticoespialidoso" , exc . message
58
+ else
59
+ assert_equal "cannot load such file -- superkalifragilisticoespialidoso" , exc . message
60
+ end
61
+ end
62
+ assert_empty out
63
+ assert_empty err
64
+ end
65
+
48
66
def test_load_error_raised_explicitly
49
67
File . write ( "error_test.rb" , "raise LoadError, 'explicitly raised'" )
50
68
out , err = capture_io do
You can’t perform that action at this time.
0 commit comments