From bfab5f8bbeb69d078a71a81ff6ea25919fdaf5fe Mon Sep 17 00:00:00 2001 From: Adrian Setyadi Date: Sun, 15 Oct 2017 07:31:39 +0700 Subject: [PATCH] Account for a file that match 2 or more patterns. --- lib/rake/file_list.rb | 4 ++-- test/test_rake_file_list.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb index 748d668f1..e27de8db5 100644 --- a/lib/rake/file_list.rb +++ b/lib/rake/file_list.rb @@ -318,14 +318,14 @@ def egrep(pattern, *options) # Return a new file list that only contains file names from the current # file list that exist on the file system. def existing - select { |fn| File.exist?(fn) } + select { |fn| File.exist?(fn) }.uniq end # Modify the current file list so that it contains only file name that # exist on the file system. def existing! resolve - @items = @items.select { |fn| File.exist?(fn) } + @items = @items.select { |fn| File.exist?(fn) }.uniq self end diff --git a/test/test_rake_file_list.rb b/test/test_rake_file_list.rb index 7e5d1eed0..3e2622acd 100644 --- a/test/test_rake_file_list.rb +++ b/test/test_rake_file_list.rb @@ -415,13 +415,13 @@ def test_egrep_with_error end def test_existing - fl = FileList["abc.c", "notthere.c"] + fl = FileList["*c.c", "notthere.c", "a*.c"] assert_equal ["abc.c"], fl.existing assert fl.existing.is_a?(FileList) end def test_existing! - fl = FileList["abc.c", "notthere.c"] + fl = FileList["*c.c", "notthere.c", "a*.c"] result = fl.existing! assert_equal ["abc.c"], fl assert_equal fl.object_id, result.object_id