File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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- 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
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
1213
13- false
14- else
15- require File . expand_path argument
14+ false
15+ else
16+ require File . expand_path argument
1617
17- false
18+ false
19+ end
20+ rescue LoadError => e
21+ abort "\n File does not exist: #{ e . path } \n \n "
1822 end
1923end
2024
Original file line number Diff line number Diff line change 22
33class TestRakeRakeTestLoader < Rake ::TestCase
44
5+ def setup
6+ super
7+
8+ @loader = File . join @rake_lib , 'rake/rake_test_loader.rb'
9+ end
10+
511 def test_pattern
612 orig_loaded_features = $:. dup
713 FileUtils . touch "foo.rb"
@@ -10,11 +16,31 @@ def test_pattern
1016
1117 ARGV . replace %w[ foo.rb test_*.rb -v ]
1218
13- load File . join ( @rake_lib , "rake/rake_test_loader.rb" )
19+ load @loader
1420
1521 assert_equal %w[ -v ] , ARGV
1622 ensure
1723 $:. replace orig_loaded_features
1824 end
1925
26+ def test_load_error
27+ out , err = capture_io do
28+ ARGV . replace %w[ no_such_test_file.rb ]
29+
30+ assert_raises SystemExit do
31+ load @loader
32+ end
33+ end
34+
35+ assert_empty out
36+
37+ no_such_path = File . join @tempdir , 'no_such_test_file'
38+
39+ expected =
40+ /\A \n
41+ File\ does\ not\ exist:\ #{ no_such_path } (\. rb)? # JRuby is different
42+ \n \n \Z /x
43+
44+ assert_match expected , err
45+ end
2046end
You can’t perform that action at this time.
0 commit comments