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 2
2
3
3
# Load the test files from the command line.
4
4
argv = ARGV . select do |argument |
5
- begin
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
5
+ case argument
6
+ when /^-/ then
7
+ argument
8
+ when /\* / then
9
+ FileList [ argument ] . to_a . each do |file |
10
+ require File . expand_path file
11
+ end
13
12
14
- false
15
- else
16
- require File . expand_path argument
13
+ false
14
+ else
15
+ path = File . expand_path argument
17
16
18
- false
19
- end
20
- rescue LoadError => e
21
- raise unless e . path
22
- abort " \n File does not exist: #{ e . path } \n \n "
17
+ abort " \n File does not exist: #{ path } \n \n " unless File . exist? ( path )
18
+
19
+ require path
20
+
21
+ false
23
22
end
24
23
end
25
24
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