File tree Expand file tree Collapse file tree 2 files changed +34
-17
lines changed Expand file tree Collapse file tree 2 files changed +34
-17
lines changed Original file line number Diff line number Diff line change 22
33# Load the test files from the command line.
44argv = 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
1312
14- false
15- else
16- require File . expand_path argument
13+ false
14+ else
15+ path = File . expand_path argument
1716
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
2322 end
2423end
2524
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ def test_pattern
2424 $:. replace orig_loaded_features
2525 end
2626
27- def test_load_error_from_require
27+ def test_load_error_from_missing_test_file
2828 out , err = capture_io do
2929 ARGV . replace %w[ no_such_test_file.rb ]
3030
@@ -45,6 +45,24 @@ def test_load_error_from_require
4545 assert_match expected , err
4646 end
4747
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+
4866 def test_load_error_raised_explicitly
4967 File . write ( "error_test.rb" , "raise LoadError, 'explicitly raised'" )
5068 out , err = capture_io do
You can’t perform that action at this time.
0 commit comments