diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb index 1a83c30ec..49f9e55f4 100644 --- a/lib/rake/testtask.rb +++ b/lib/rake/testtask.rb @@ -163,7 +163,7 @@ def file_list # :nodoc: else result = [] result += @test_files.to_a if @test_files - result << @pattern if @pattern + result += FileList[@pattern].to_a if @pattern result end end diff --git a/test/test_rake_test_task.rb b/test/test_rake_test_task.rb index 9b3450334..196c7fb54 100644 --- a/test/test_rake_test_task.rb +++ b/test/test_rake_test_task.rb @@ -82,26 +82,40 @@ def test_libs_equals_empty end def test_pattern_equals + ['gl.rb', 'ob.rb'].each do |f| + create_file(f) + end tt = Rake::TestTask.new do |t| t.pattern = "*.rb" end - assert_equal ["*.rb"], tt.file_list.to_a + assert_equal ["gl.rb", "ob.rb"], tt.file_list.to_a end def test_pattern_equals_test_files_equals + ['gl.rb', 'ob.rb'].each do |f| + create_file(f) + end tt = Rake::TestTask.new do |t| t.test_files = FileList["a.rb", "b.rb"] t.pattern = "*.rb" end - assert_equal ["a.rb", "b.rb", "*.rb"], tt.file_list.to_a + assert_equal ["a.rb", "b.rb", "gl.rb", "ob.rb"], tt.file_list.to_a end def test_run_code_direct + globbed = ['test_gl.rb', 'test_ob.rb'].map { |f| File.join('test', f) } + others = ['a.rb', 'b.rb'].map { |f| File.join('test', f) } + (globbed + others).each do |f| + create_file(f) + end test_task = Rake::TestTask.new do |t| t.loader = :direct + # if t.pettern and t.test_files are nil, + # t.pettern is "test/test*.rb" end assert_equal '-e "ARGV.each{|f| require f}"', test_task.run_code + assert_equal globbed, test_task.file_list.to_a end def test_run_code_rake