necktie 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +174 -0
- data/bin/necktie +2 -1
- data/lib/necktie/files.rb +29 -0
- data/lib/necktie/rake.rb +127 -0
- data/lib/necktie/services.rb +11 -7
- data/lib/necktie.rb +4 -54
- data/necktie.gemspec +3 -3
- data/vendor/rake/CHANGES +477 -0
- data/vendor/rake/MIT-LICENSE +21 -0
- data/vendor/rake/README.rdoc +194 -0
- data/vendor/rake/Rakefile +421 -0
- data/vendor/rake/TODO +20 -0
- data/vendor/rake/bin/rake +31 -0
- data/vendor/rake/doc/command_line_usage.rdoc +102 -0
- data/vendor/rake/doc/example/Rakefile1 +38 -0
- data/vendor/rake/doc/example/Rakefile2 +35 -0
- data/vendor/rake/doc/example/a.c +6 -0
- data/vendor/rake/doc/example/b.c +6 -0
- data/vendor/rake/doc/example/main.c +11 -0
- data/vendor/rake/doc/glossary.rdoc +51 -0
- data/vendor/rake/doc/jamis.rb +591 -0
- data/vendor/rake/doc/proto_rake.rdoc +127 -0
- data/vendor/rake/doc/rake.1.gz +0 -0
- data/vendor/rake/doc/rakefile.rdoc +566 -0
- data/vendor/rake/doc/rational.rdoc +151 -0
- data/vendor/rake/doc/release_notes/rake-0.4.14.rdoc +23 -0
- data/vendor/rake/doc/release_notes/rake-0.4.15.rdoc +35 -0
- data/vendor/rake/doc/release_notes/rake-0.5.0.rdoc +53 -0
- data/vendor/rake/doc/release_notes/rake-0.5.3.rdoc +78 -0
- data/vendor/rake/doc/release_notes/rake-0.5.4.rdoc +46 -0
- data/vendor/rake/doc/release_notes/rake-0.6.0.rdoc +141 -0
- data/vendor/rake/doc/release_notes/rake-0.7.0.rdoc +119 -0
- data/vendor/rake/doc/release_notes/rake-0.7.1.rdoc +59 -0
- data/vendor/rake/doc/release_notes/rake-0.7.2.rdoc +121 -0
- data/vendor/rake/doc/release_notes/rake-0.7.3.rdoc +47 -0
- data/vendor/rake/doc/release_notes/rake-0.8.0.rdoc +114 -0
- data/vendor/rake/doc/release_notes/rake-0.8.2.rdoc +165 -0
- data/vendor/rake/doc/release_notes/rake-0.8.3.rdoc +112 -0
- data/vendor/rake/doc/release_notes/rake-0.8.4.rdoc +147 -0
- data/vendor/rake/doc/release_notes/rake-0.8.5.rdoc +53 -0
- data/vendor/rake/doc/release_notes/rake-0.8.6.rdoc +55 -0
- data/vendor/rake/doc/release_notes/rake-0.8.7.rdoc +55 -0
- data/vendor/rake/install.rb +88 -0
- data/vendor/rake/lib/rake/alt_system.rb +108 -0
- data/vendor/rake/lib/rake/application.rb +579 -0
- data/vendor/rake/lib/rake/classic_namespace.rb +9 -0
- data/vendor/rake/lib/rake/clean.rb +35 -0
- data/vendor/rake/lib/rake/cloneable.rb +25 -0
- data/vendor/rake/lib/rake/contrib/compositepublisher.rb +24 -0
- data/vendor/rake/lib/rake/contrib/ftptools.rb +153 -0
- data/vendor/rake/lib/rake/contrib/publisher.rb +75 -0
- data/vendor/rake/lib/rake/contrib/rubyforgepublisher.rb +18 -0
- data/vendor/rake/lib/rake/contrib/sshpublisher.rb +47 -0
- data/vendor/rake/lib/rake/contrib/sys.rb +209 -0
- data/vendor/rake/lib/rake/default_loader.rb +10 -0
- data/vendor/rake/lib/rake/dsl.rb +136 -0
- data/vendor/rake/lib/rake/early_time.rb +18 -0
- data/vendor/rake/lib/rake/environment.rb +40 -0
- data/vendor/rake/lib/rake/ext/module.rb +60 -0
- data/vendor/rake/lib/rake/ext/string.rb +165 -0
- data/vendor/rake/lib/rake/ext/time.rb +14 -0
- data/vendor/rake/lib/rake/file_creation_task.rb +24 -0
- data/vendor/rake/lib/rake/file_list.rb +395 -0
- data/vendor/rake/lib/rake/file_task.rb +47 -0
- data/vendor/rake/lib/rake/file_utils.rb +108 -0
- data/vendor/rake/lib/rake/gempackagetask.rb +97 -0
- data/vendor/rake/lib/rake/invocation_chain.rb +51 -0
- data/vendor/rake/lib/rake/invocation_exception_mixin.rb +16 -0
- data/vendor/rake/lib/rake/lib/project.rake +24 -0
- data/vendor/rake/lib/rake/loaders/makefile.rb +44 -0
- data/vendor/rake/lib/rake/multi_task.rb +16 -0
- data/vendor/rake/lib/rake/name_space.rb +25 -0
- data/vendor/rake/lib/rake/packagetask.rb +184 -0
- data/vendor/rake/lib/rake/psuedo_status.rb +24 -0
- data/vendor/rake/lib/rake/rake_file_utils.rb +133 -0
- data/vendor/rake/lib/rake/rake_module.rb +25 -0
- data/vendor/rake/lib/rake/rake_test_loader.rb +15 -0
- data/vendor/rake/lib/rake/rdoctask.rb +209 -0
- data/vendor/rake/lib/rake/ruby182_test_unit_fix.rb +25 -0
- data/vendor/rake/lib/rake/rule_recursion_overflow_error.rb +20 -0
- data/vendor/rake/lib/rake/runtest.rb +23 -0
- data/vendor/rake/lib/rake/task.rb +318 -0
- data/vendor/rake/lib/rake/task_argument_error.rb +7 -0
- data/vendor/rake/lib/rake/task_arguments.rb +78 -0
- data/vendor/rake/lib/rake/task_manager.rb +328 -0
- data/vendor/rake/lib/rake/tasklib.rb +24 -0
- data/vendor/rake/lib/rake/testtask.rb +175 -0
- data/vendor/rake/lib/rake/win32.rb +55 -0
- data/vendor/rake/lib/rake.rb +72 -0
- data/vendor/rake/rake.blurb +19 -0
- data/vendor/rake/rake.gemspec +214 -0
- data/vendor/rake/rakelib/extra.rake +8 -0
- data/vendor/rake/rakelib/publish.rake +22 -0
- data/vendor/rake/rakelib/rbx.rake +82 -0
- data/vendor/rake/rakelib/ruby19.rake +88 -0
- data/vendor/rake/rakelib/tags.rake +18 -0
- data/vendor/rake/test/capture_stdout.rb +26 -0
- data/vendor/rake/test/check_expansion.rb +5 -0
- data/vendor/rake/test/check_no_expansion.rb +5 -0
- data/vendor/rake/test/contrib/test_sys.rb +47 -0
- data/vendor/rake/test/data/chains/Rakefile +15 -0
- data/vendor/rake/test/data/comments/Rakefile +18 -0
- data/vendor/rake/test/data/default/Rakefile +19 -0
- data/vendor/rake/test/data/dryrun/Rakefile +22 -0
- data/vendor/rake/test/data/file_creation_task/Rakefile +33 -0
- data/vendor/rake/test/data/imports/Rakefile +19 -0
- data/vendor/rake/test/data/imports/deps.mf +1 -0
- data/vendor/rake/test/data/multidesc/Rakefile +17 -0
- data/vendor/rake/test/data/namespace/Rakefile +66 -0
- data/vendor/rake/test/data/nosearch/dummy +1 -0
- data/vendor/rake/test/data/rakelib/test1.rb +5 -0
- data/vendor/rake/test/data/rakelib/test2.rake +3 -0
- data/vendor/rake/test/data/rbext/rakefile.rb +3 -0
- data/vendor/rake/test/data/sample.mf +14 -0
- data/vendor/rake/test/data/statusreturn/Rakefile +8 -0
- data/vendor/rake/test/data/sys/sys1.rake +3 -0
- data/vendor/rake/test/data/unittest/Rakefile +1 -0
- data/vendor/rake/test/data/unittest/subdir/README +0 -0
- data/vendor/rake/test/data/verbose/Rakefile +34 -0
- data/vendor/rake/test/filecreation.rb +32 -0
- data/vendor/rake/test/functional/functional_test.rb +15 -0
- data/vendor/rake/test/functional/session_based_tests.rb +442 -0
- data/vendor/rake/test/in_environment.rb +32 -0
- data/vendor/rake/test/lib/application_test.rb +769 -0
- data/vendor/rake/test/lib/clean_test.rb +15 -0
- data/vendor/rake/test/lib/definitions_test.rb +85 -0
- data/vendor/rake/test/lib/dsl_test.rb +41 -0
- data/vendor/rake/test/lib/earlytime_test.rb +35 -0
- data/vendor/rake/test/lib/environment_test.rb +18 -0
- data/vendor/rake/test/lib/extension_test.rb +63 -0
- data/vendor/rake/test/lib/file_creation_task_test.rb +62 -0
- data/vendor/rake/test/lib/file_task_test.rb +143 -0
- data/vendor/rake/test/lib/filelist_test.rb +623 -0
- data/vendor/rake/test/lib/fileutils_test.rb +251 -0
- data/vendor/rake/test/lib/ftp_test.rb +59 -0
- data/vendor/rake/test/lib/invocation_chain_test.rb +81 -0
- data/vendor/rake/test/lib/makefile_loader_test.rb +26 -0
- data/vendor/rake/test/lib/multitask_test.rb +53 -0
- data/vendor/rake/test/lib/namespace_test.rb +55 -0
- data/vendor/rake/test/lib/package_task_test.rb +118 -0
- data/vendor/rake/test/lib/pathmap_test.rb +210 -0
- data/vendor/rake/test/lib/pseudo_status_test.rb +26 -0
- data/vendor/rake/test/lib/rake_test.rb +41 -0
- data/vendor/rake/test/lib/rdoc_task_test.rb +88 -0
- data/vendor/rake/test/lib/require_test.rb +35 -0
- data/vendor/rake/test/lib/rules_test.rb +349 -0
- data/vendor/rake/test/lib/task_arguments_test.rb +89 -0
- data/vendor/rake/test/lib/task_manager_test.rb +173 -0
- data/vendor/rake/test/lib/task_test.rb +376 -0
- data/vendor/rake/test/lib/tasklib_test.rb +12 -0
- data/vendor/rake/test/lib/test_task_test.rb +77 -0
- data/vendor/rake/test/lib/testtask_test.rb +49 -0
- data/vendor/rake/test/lib/top_level_functions_test.rb +86 -0
- data/vendor/rake/test/lib/win32_test.rb +72 -0
- data/vendor/rake/test/rake_test_setup.rb +24 -0
- data/vendor/rake/test/reqfile.rb +3 -0
- data/vendor/rake/test/reqfile2.rb +3 -0
- data/vendor/rake/test/reqfile3.rake +3 -0
- data/vendor/rake/test/shellcommand.rb +3 -0
- data/vendor/rake/test/test_helper.rb +13 -0
- metadata +212 -56
- /data/{rush → vendor/rush}/README.rdoc +0 -0
- /data/{rush → vendor/rush}/Rakefile +0 -0
- /data/{rush → vendor/rush}/VERSION +0 -0
- /data/{rush → vendor/rush}/bin/rush +0 -0
- /data/{rush → vendor/rush}/bin/rushd +0 -0
- /data/{rush → vendor/rush}/lib/rush/access.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/array_ext.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/box.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/commands.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/config.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/dir.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/embeddable_shell.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/entry.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/exceptions.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/file.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/find_by.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/fixnum_ext.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/head_tail.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/local.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/process.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/process_set.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/remote.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/search_results.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/server.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/shell.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/ssh_tunnel.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/string_ext.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush.rb +0 -0
- /data/{rush → vendor/rush}/rush.gemspec +0 -0
- /data/{rush → vendor/rush}/spec/access_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/array_ext_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/base.rb +0 -0
- /data/{rush → vendor/rush}/spec/box_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/commands_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/config_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/dir_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/embeddable_shell_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/entry_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/file_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/find_by_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/fixnum_ext_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/local_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/process_set_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/process_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/remote_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/rush_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/search_results_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/shell_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/ssh_tunnel_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/string_ext_spec.rb +0 -0
- /data/{session → vendor/session}/lib/session-2.4.0.rb +0 -0
- /data/{session → vendor/session}/lib/session.rb +0 -0
- /data/{session → vendor/session}/test/session.rb +0 -0
@@ -0,0 +1,623 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
require 'test/capture_stdout'
|
7
|
+
require 'test/rake_test_setup'
|
8
|
+
|
9
|
+
class TestFileList < Test::Unit::TestCase
|
10
|
+
FileList = Rake::FileList
|
11
|
+
include CaptureStdout
|
12
|
+
include TestMethods
|
13
|
+
|
14
|
+
def setup
|
15
|
+
create_test_data
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
# FileList.select_default_ignore_patterns
|
20
|
+
FileUtils.rm_rf("testdata")
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_delgating_methods_do_not_include_to_a_or_to_ary
|
24
|
+
assert ! FileList::DELEGATING_METHODS.include?("to_a"), "should not include to_a"
|
25
|
+
assert ! FileList::DELEGATING_METHODS.include?(:to_a), "should not include to_a"
|
26
|
+
assert ! FileList::DELEGATING_METHODS.include?("to_ary"), "should not include to_ary"
|
27
|
+
assert ! FileList::DELEGATING_METHODS.include?(:to_ary), "should not include to_ary"
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_create
|
31
|
+
fl = FileList.new
|
32
|
+
assert_equal 0, fl.size
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_create_with_args
|
36
|
+
fl = FileList.new("testdata/*.c", "x")
|
37
|
+
assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
|
38
|
+
fl.sort
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_create_with_block
|
42
|
+
fl = FileList.new { |f| f.include("x") }
|
43
|
+
assert_equal ["x"], fl.resolve
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_create_with_brackets
|
47
|
+
fl = FileList["testdata/*.c", "x"]
|
48
|
+
assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
|
49
|
+
fl.sort
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_create_with_brackets_and_filelist
|
53
|
+
fl = FileList[FileList["testdata/*.c", "x"]]
|
54
|
+
assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
|
55
|
+
fl.sort
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_include_with_another_array
|
59
|
+
fl = FileList.new.include(["x", "y", "z"])
|
60
|
+
assert_equal ["x", "y", "z"].sort, fl.sort
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_include_with_another_filelist
|
64
|
+
fl = FileList.new.include(FileList["testdata/*.c", "x"])
|
65
|
+
assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
|
66
|
+
fl.sort
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_append
|
70
|
+
fl = FileList.new
|
71
|
+
fl << "a.rb" << "b.rb"
|
72
|
+
assert_equal ['a.rb', 'b.rb'], fl
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_add_many
|
76
|
+
fl = FileList.new
|
77
|
+
fl.include %w(a d c)
|
78
|
+
fl.include('x', 'y')
|
79
|
+
assert_equal ['a', 'd', 'c', 'x', 'y'], fl
|
80
|
+
assert_equal ['a', 'd', 'c', 'x', 'y'], fl.resolve
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_add_return
|
84
|
+
f = FileList.new
|
85
|
+
g = f << "x"
|
86
|
+
assert_equal f.object_id, g.object_id
|
87
|
+
h = f.include("y")
|
88
|
+
assert_equal f.object_id, h.object_id
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_match
|
92
|
+
fl = FileList.new
|
93
|
+
fl.include('test/lib/*_test.rb')
|
94
|
+
assert fl.include?("test/lib/filelist_test.rb")
|
95
|
+
assert fl.size > 3
|
96
|
+
fl.each { |fn| assert_match(/\.rb$/, fn) }
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_add_matching
|
100
|
+
fl = FileList.new
|
101
|
+
fl << "a.java"
|
102
|
+
fl.include("test/lib/*.rb")
|
103
|
+
assert_equal "a.java", fl[0]
|
104
|
+
assert fl.size > 2
|
105
|
+
assert fl.include?("test/lib/filelist_test.rb")
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_multiple_patterns
|
109
|
+
create_test_data
|
110
|
+
fl = FileList.new
|
111
|
+
fl.include('*.c', '*xist*')
|
112
|
+
assert_equal [], fl
|
113
|
+
fl.include('testdata/*.c', 'testdata/*xist*')
|
114
|
+
assert_equal [
|
115
|
+
'testdata/x.c', 'testdata/xyz.c', 'testdata/abc.c', 'testdata/existing'
|
116
|
+
].sort, fl.sort
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_square_bracket_pattern
|
120
|
+
fl = FileList.new
|
121
|
+
fl.include("testdata/abc.[ch]")
|
122
|
+
assert fl.size == 2
|
123
|
+
assert fl.include?("testdata/abc.c")
|
124
|
+
assert fl.include?("testdata/abc.h")
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_curly_bracket_pattern
|
128
|
+
fl = FileList.new
|
129
|
+
fl.include("testdata/abc.{c,h}")
|
130
|
+
assert fl.size == 2
|
131
|
+
assert fl.include?("testdata/abc.c")
|
132
|
+
assert fl.include?("testdata/abc.h")
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_reject
|
136
|
+
fl = FileList.new
|
137
|
+
fl.include %w(testdata/x.c testdata/abc.c testdata/xyz.c testdata/existing)
|
138
|
+
fl.reject! { |fn| fn =~ %r{/x} }
|
139
|
+
assert_equal [
|
140
|
+
'testdata/abc.c', 'testdata/existing'
|
141
|
+
], fl
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_exclude
|
145
|
+
fl = FileList['testdata/x.c', 'testdata/abc.c', 'testdata/xyz.c', 'testdata/existing']
|
146
|
+
fl.each { |fn| touch fn, :verbose => false }
|
147
|
+
x = fl.exclude(%r{/x.+\.})
|
148
|
+
assert_equal FileList, x.class
|
149
|
+
assert_equal %w(testdata/x.c testdata/abc.c testdata/existing), fl
|
150
|
+
assert_equal fl.object_id, x.object_id
|
151
|
+
fl.exclude('testdata/*.c')
|
152
|
+
assert_equal ['testdata/existing'], fl
|
153
|
+
fl.exclude('testdata/existing')
|
154
|
+
assert_equal [], fl
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_excluding_via_block
|
158
|
+
fl = FileList['testdata/a.c', 'testdata/b.c', 'testdata/xyz.c']
|
159
|
+
fl.exclude { |fn| fn.pathmap('%n') == 'xyz' }
|
160
|
+
assert fl.exclude?("xyz.c"), "Should exclude xyz.c"
|
161
|
+
assert_equal ['testdata/a.c', 'testdata/b.c'], fl
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_exclude_return_on_create
|
165
|
+
fl = FileList['testdata/*'].exclude(/.*\.[hcx]$/)
|
166
|
+
assert_equal ['testdata/existing', 'testdata/cfiles'].sort, fl.sort
|
167
|
+
assert_equal FileList, fl.class
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_exclude_with_string_return_on_create
|
171
|
+
fl = FileList['testdata/*'].exclude('testdata/abc.c')
|
172
|
+
assert_equal %w(testdata/existing testdata/cfiles testdata/x.c testdata/abc.h testdata/abc.x testdata/xyz.c).sort, fl.sort
|
173
|
+
assert_equal FileList, fl.class
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_default_exclude
|
177
|
+
fl = FileList.new
|
178
|
+
fl.clear_exclude
|
179
|
+
fl.include("**/*~", "**/*.bak", "**/core")
|
180
|
+
assert fl.member?("testdata/core"), "Should include core"
|
181
|
+
assert fl.member?("testdata/x.bak"), "Should include .bak files"
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_unique
|
185
|
+
fl = FileList.new
|
186
|
+
fl << "x.c" << "a.c" << "b.rb" << "a.c"
|
187
|
+
assert_equal ['x.c', 'a.c', 'b.rb', 'a.c'], fl
|
188
|
+
fl.uniq!
|
189
|
+
assert_equal ['x.c', 'a.c', 'b.rb'], fl
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_to_string
|
193
|
+
fl = FileList.new
|
194
|
+
fl << "a.java" << "b.java"
|
195
|
+
assert_equal "a.java b.java", fl.to_s
|
196
|
+
assert_equal "a.java b.java", "#{fl}"
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_to_array
|
200
|
+
fl = FileList['a.java', 'b.java']
|
201
|
+
assert_equal ['a.java', 'b.java'], fl.to_a
|
202
|
+
assert_equal Array, fl.to_a.class
|
203
|
+
assert_equal ['a.java', 'b.java'], fl.to_ary
|
204
|
+
assert_equal Array, fl.to_ary.class
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_to_s_pending
|
208
|
+
fl = FileList['testdata/abc.*']
|
209
|
+
result = fl.to_s
|
210
|
+
assert_match(%r{testdata/abc\.c}, result)
|
211
|
+
assert_match(%r{testdata/abc\.h}, result)
|
212
|
+
assert_match(%r{testdata/abc\.x}, result)
|
213
|
+
assert_match(%r{(testdata/abc\..\b ?){2}}, result)
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_inspect_pending
|
217
|
+
fl = FileList['testdata/abc.*']
|
218
|
+
result = fl.inspect
|
219
|
+
assert_match(%r{"testdata/abc\.c"}, result)
|
220
|
+
assert_match(%r{"testdata/abc\.h"}, result)
|
221
|
+
assert_match(%r{"testdata/abc\.x"}, result)
|
222
|
+
assert_match(%r|^\[("testdata/abc\..", ){2}"testdata/abc\.."\]$|, result)
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_sub
|
226
|
+
fl = FileList["testdata/*.c"]
|
227
|
+
f2 = fl.sub(/\.c$/, ".o")
|
228
|
+
assert_equal FileList, f2.class
|
229
|
+
assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort,
|
230
|
+
f2.sort
|
231
|
+
f3 = fl.gsub(/\.c$/, ".o")
|
232
|
+
assert_equal FileList, f3.class
|
233
|
+
assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort,
|
234
|
+
f3.sort
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_claim_to_be_a_kind_of_array
|
238
|
+
fl = FileList['testdata/*.c']
|
239
|
+
assert fl.is_a?(Array)
|
240
|
+
assert fl.kind_of?(Array)
|
241
|
+
end
|
242
|
+
|
243
|
+
def test_claim_to_be_a_kind_of_filelist
|
244
|
+
fl = FileList['testdata/*.c']
|
245
|
+
assert fl.is_a?(FileList)
|
246
|
+
assert fl.kind_of?(FileList)
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_claim_to_be_a_filelist_instance
|
250
|
+
fl = FileList['testdata/*.c']
|
251
|
+
assert fl.instance_of?(FileList)
|
252
|
+
end
|
253
|
+
|
254
|
+
def test_dont_claim_to_be_an_array_instance
|
255
|
+
fl = FileList['testdata/*.c']
|
256
|
+
assert ! fl.instance_of?(Array)
|
257
|
+
end
|
258
|
+
|
259
|
+
def test_sub!
|
260
|
+
f = "x/a.c"
|
261
|
+
fl = FileList[f, "x/b.c"]
|
262
|
+
res = fl.sub!(/\.c$/, ".o")
|
263
|
+
assert_equal ["x/a.o", "x/b.o"].sort, fl.sort
|
264
|
+
assert_equal "x/a.c", f
|
265
|
+
assert_equal fl.object_id, res.object_id
|
266
|
+
end
|
267
|
+
|
268
|
+
def test_sub_with_block
|
269
|
+
fl = FileList["src/org/onestepback/a.java", "src/org/onestepback/b.java"]
|
270
|
+
# The block version doesn't work the way I want it to ...
|
271
|
+
# f2 = fl.sub(%r{^src/(.*)\.java$}) { |x| "classes/" + $1 + ".class" }
|
272
|
+
f2 = fl.sub(%r{^src/(.*)\.java$}, "classes/\\1.class")
|
273
|
+
assert_equal [
|
274
|
+
"classes/org/onestepback/a.class",
|
275
|
+
"classes/org/onestepback/b.class"
|
276
|
+
].sort,
|
277
|
+
f2.sort
|
278
|
+
end
|
279
|
+
|
280
|
+
def test_string_ext
|
281
|
+
assert_equal "one.net", "one.two".ext("net")
|
282
|
+
assert_equal "one.net", "one.two".ext(".net")
|
283
|
+
assert_equal "one.net", "one".ext("net")
|
284
|
+
assert_equal "one.net", "one".ext(".net")
|
285
|
+
assert_equal "one.two.net", "one.two.c".ext(".net")
|
286
|
+
assert_equal "one/two.net", "one/two.c".ext(".net")
|
287
|
+
assert_equal "one.x/two.net", "one.x/two.c".ext(".net")
|
288
|
+
assert_equal "one.x/two.net", "one.x/two".ext(".net")
|
289
|
+
assert_equal ".onerc.net", ".onerc.dot".ext("net")
|
290
|
+
assert_equal ".onerc.net", ".onerc".ext("net")
|
291
|
+
assert_equal ".a/.onerc.net", ".a/.onerc".ext("net")
|
292
|
+
assert_equal "one", "one.two".ext('')
|
293
|
+
assert_equal "one", "one.two".ext
|
294
|
+
assert_equal ".one", ".one.two".ext
|
295
|
+
assert_equal ".one", ".one".ext
|
296
|
+
assert_equal ".", ".".ext("c")
|
297
|
+
assert_equal "..", "..".ext("c")
|
298
|
+
# These only need to work in windows
|
299
|
+
if Rake::Win32.windows?
|
300
|
+
assert_equal "one.x\\two.net", "one.x\\two.c".ext(".net")
|
301
|
+
assert_equal "one.x\\two.net", "one.x\\two".ext(".net")
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
def test_filelist_ext
|
306
|
+
assert_equal FileList['one.c', '.one.c'],
|
307
|
+
FileList['one.net', '.one'].ext('c')
|
308
|
+
end
|
309
|
+
|
310
|
+
def test_gsub
|
311
|
+
create_test_data
|
312
|
+
fl = FileList["testdata/*.c"]
|
313
|
+
f2 = fl.gsub(/a/, "A")
|
314
|
+
assert_equal ["testdAtA/Abc.c", "testdAtA/x.c", "testdAtA/xyz.c"].sort,
|
315
|
+
f2.sort
|
316
|
+
end
|
317
|
+
|
318
|
+
def test_gsub!
|
319
|
+
create_test_data
|
320
|
+
f = FileList["testdata/*.c"]
|
321
|
+
f.gsub!(/a/, "A")
|
322
|
+
assert_equal ["testdAtA/Abc.c", "testdAtA/x.c", "testdAtA/xyz.c"].sort,
|
323
|
+
f.sort
|
324
|
+
end
|
325
|
+
|
326
|
+
def test_egrep_with_output
|
327
|
+
files = FileList['test/lib/*_test.rb']
|
328
|
+
the_line_number = __LINE__ + 1
|
329
|
+
out = capture_stdout do files.egrep(/PUGH/) end
|
330
|
+
assert_match(/:#{the_line_number}:/, out)
|
331
|
+
end
|
332
|
+
|
333
|
+
def test_egrep_with_block
|
334
|
+
files = FileList['test/lib/*_test.rb']
|
335
|
+
found = false
|
336
|
+
the_line_number = __LINE__ + 1
|
337
|
+
files.egrep(/XYZZY/) do |fn, ln, line |
|
338
|
+
assert_equal 'test/lib/filelist_test.rb', fn
|
339
|
+
assert_equal the_line_number, ln
|
340
|
+
assert_match(/files\.egrep/, line)
|
341
|
+
found = true
|
342
|
+
end
|
343
|
+
assert found, "should have found a matching line"
|
344
|
+
end
|
345
|
+
|
346
|
+
def test_existing
|
347
|
+
fl = FileList['testdata/abc.c', 'testdata/notthere.c']
|
348
|
+
assert_equal ["testdata/abc.c"], fl.existing
|
349
|
+
assert fl.existing.is_a?(FileList)
|
350
|
+
end
|
351
|
+
|
352
|
+
def test_existing!
|
353
|
+
fl = FileList['testdata/abc.c', 'testdata/notthere.c']
|
354
|
+
result = fl.existing!
|
355
|
+
assert_equal ["testdata/abc.c"], fl
|
356
|
+
assert_equal fl.object_id, result.object_id
|
357
|
+
end
|
358
|
+
|
359
|
+
def test_ignore_special
|
360
|
+
f = FileList['testdata/*']
|
361
|
+
assert ! f.include?("testdata/CVS"), "Should not contain CVS"
|
362
|
+
assert ! f.include?("testdata/.svn"), "Should not contain .svn"
|
363
|
+
assert ! f.include?("testdata/.dummy"), "Should not contain dot files"
|
364
|
+
assert ! f.include?("testdata/x.bak"), "Should not contain .bak files"
|
365
|
+
assert ! f.include?("testdata/x~"), "Should not contain ~ files"
|
366
|
+
assert ! f.include?("testdata/core"), "Should not contain core files"
|
367
|
+
end
|
368
|
+
|
369
|
+
def test_clear_ignore_patterns
|
370
|
+
f = FileList['testdata/*', 'testdata/.svn']
|
371
|
+
f.clear_exclude
|
372
|
+
assert f.include?("testdata/abc.c")
|
373
|
+
assert f.include?("testdata/xyz.c")
|
374
|
+
assert f.include?("testdata/CVS")
|
375
|
+
assert f.include?("testdata/.svn")
|
376
|
+
assert f.include?("testdata/x.bak")
|
377
|
+
assert f.include?("testdata/x~")
|
378
|
+
end
|
379
|
+
|
380
|
+
def test_exclude_with_alternate_file_seps
|
381
|
+
fl = FileList.new
|
382
|
+
assert fl.exclude?("x/CVS/y")
|
383
|
+
assert fl.exclude?("x\\CVS\\y")
|
384
|
+
assert fl.exclude?("x/.svn/y")
|
385
|
+
assert fl.exclude?("x\\.svn\\y")
|
386
|
+
assert fl.exclude?("x/core")
|
387
|
+
assert fl.exclude?("x\\core")
|
388
|
+
end
|
389
|
+
|
390
|
+
def test_add_default_exclude_list
|
391
|
+
fl = FileList.new
|
392
|
+
fl.exclude(/~\d+$/)
|
393
|
+
assert fl.exclude?("x/CVS/y")
|
394
|
+
assert fl.exclude?("x\\CVS\\y")
|
395
|
+
assert fl.exclude?("x/.svn/y")
|
396
|
+
assert fl.exclude?("x\\.svn\\y")
|
397
|
+
assert fl.exclude?("x/core")
|
398
|
+
assert fl.exclude?("x\\core")
|
399
|
+
assert fl.exclude?("x/abc~1")
|
400
|
+
end
|
401
|
+
|
402
|
+
def test_basic_array_functions
|
403
|
+
f = FileList['b', 'c', 'a']
|
404
|
+
assert_equal 'b', f.first
|
405
|
+
assert_equal 'b', f[0]
|
406
|
+
assert_equal 'a', f.last
|
407
|
+
assert_equal 'a', f[2]
|
408
|
+
assert_equal 'a', f[-1]
|
409
|
+
assert_equal ['a', 'b', 'c'], f.sort
|
410
|
+
f.sort!
|
411
|
+
assert_equal ['a', 'b', 'c'], f
|
412
|
+
end
|
413
|
+
|
414
|
+
def test_flatten
|
415
|
+
assert_equal ['a', 'testdata/x.c', 'testdata/xyz.c', 'testdata/abc.c'].sort,
|
416
|
+
['a', FileList['testdata/*.c']].flatten.sort
|
417
|
+
end
|
418
|
+
|
419
|
+
def test_clone_and_dup
|
420
|
+
a = FileList['a', 'b', 'c']
|
421
|
+
c = a.clone
|
422
|
+
d = a.dup
|
423
|
+
a << 'd'
|
424
|
+
assert_equal ['a', 'b', 'c', 'd'], a
|
425
|
+
assert_equal ['a', 'b', 'c'], c
|
426
|
+
assert_equal ['a', 'b', 'c'], d
|
427
|
+
end
|
428
|
+
|
429
|
+
def test_dup_and_clone_replicate_taint
|
430
|
+
a = FileList['a', 'b', 'c']
|
431
|
+
a.taint
|
432
|
+
c = a.clone
|
433
|
+
d = a.dup
|
434
|
+
assert c.tainted?, "Clone should be tainted"
|
435
|
+
assert d.tainted?, "Dup should be tainted"
|
436
|
+
end
|
437
|
+
|
438
|
+
def test_duped_items_will_thaw
|
439
|
+
a = FileList['a', 'b', 'c']
|
440
|
+
a.freeze
|
441
|
+
d = a.dup
|
442
|
+
d << 'more'
|
443
|
+
assert_equal ['a', 'b', 'c', 'more'], d
|
444
|
+
end
|
445
|
+
|
446
|
+
def test_cloned_items_stay_frozen
|
447
|
+
a = FileList['a', 'b', 'c']
|
448
|
+
a.freeze
|
449
|
+
c = a.clone
|
450
|
+
assert_exception(TypeError, RuntimeError) do
|
451
|
+
c << 'more'
|
452
|
+
end
|
453
|
+
end
|
454
|
+
|
455
|
+
def test_array_comparisons
|
456
|
+
fl = FileList['b', 'b']
|
457
|
+
a = ['b', 'a']
|
458
|
+
b = ['b', 'b']
|
459
|
+
c = ['b', 'c']
|
460
|
+
assert_equal( 1, fl <=> a )
|
461
|
+
assert_equal( 0, fl <=> b )
|
462
|
+
assert_equal( -1, fl <=> c )
|
463
|
+
assert_equal( -1, a <=> fl )
|
464
|
+
assert_equal( 0, b <=> fl )
|
465
|
+
assert_equal( 1, c <=> fl )
|
466
|
+
end
|
467
|
+
|
468
|
+
def test_array_equality
|
469
|
+
a = FileList['a', 'b']
|
470
|
+
b = ['a', 'b']
|
471
|
+
assert a == b
|
472
|
+
assert b == a
|
473
|
+
# assert a.eql?(b)
|
474
|
+
# assert b.eql?(a)
|
475
|
+
assert ! a.equal?(b)
|
476
|
+
assert ! b.equal?(a)
|
477
|
+
end
|
478
|
+
|
479
|
+
def test_enumeration_methods
|
480
|
+
a = FileList['a', 'b']
|
481
|
+
b = a.collect { |it| it.upcase }
|
482
|
+
assert_equal ['A', 'B'], b
|
483
|
+
assert_equal FileList, b.class
|
484
|
+
|
485
|
+
b = a.map { |it| it.upcase }
|
486
|
+
assert_equal ['A', 'B'], b
|
487
|
+
assert_equal FileList, b.class
|
488
|
+
|
489
|
+
b = a.sort
|
490
|
+
assert_equal ['a', 'b'], b
|
491
|
+
assert_equal FileList, b.class
|
492
|
+
|
493
|
+
b = a.sort_by { |it| it }
|
494
|
+
assert_equal ['a', 'b'], b
|
495
|
+
assert_equal FileList, b.class
|
496
|
+
|
497
|
+
b = a.find_all { |it| it == 'b'}
|
498
|
+
assert_equal ['b'], b
|
499
|
+
assert_equal FileList, b.class
|
500
|
+
|
501
|
+
b = a.select { |it| it.size == 1 }
|
502
|
+
assert_equal ['a', 'b'], b
|
503
|
+
assert_equal FileList, b.class
|
504
|
+
|
505
|
+
b = a.reject { |it| it == 'b' }
|
506
|
+
assert_equal ['a'], b
|
507
|
+
assert_equal FileList, b.class
|
508
|
+
|
509
|
+
b = a.grep(/./)
|
510
|
+
assert_equal ['a', 'b'], b
|
511
|
+
assert_equal FileList, b.class
|
512
|
+
|
513
|
+
b = a.partition { |it| it == 'b' }
|
514
|
+
assert_equal [['b'], ['a']], b
|
515
|
+
assert_equal Array, b.class
|
516
|
+
assert_equal FileList, b[0].class
|
517
|
+
assert_equal FileList, b[1].class
|
518
|
+
|
519
|
+
b = a.zip(['x', 'y']).to_a
|
520
|
+
assert_equal [['a', 'x'], ['b', 'y']], b
|
521
|
+
assert_equal Array, b.class
|
522
|
+
assert_equal Array, b[0].class
|
523
|
+
assert_equal Array, b[1].class
|
524
|
+
end
|
525
|
+
|
526
|
+
def test_array_operators
|
527
|
+
a = ['a', 'b']
|
528
|
+
b = ['c', 'd']
|
529
|
+
f = FileList['x', 'y']
|
530
|
+
g = FileList['w', 'z']
|
531
|
+
|
532
|
+
r = f + g
|
533
|
+
assert_equal ['x', 'y', 'w', 'z'], r
|
534
|
+
assert_equal FileList, r.class
|
535
|
+
|
536
|
+
r = a + g
|
537
|
+
assert_equal ['a', 'b', 'w', 'z'], r
|
538
|
+
assert_equal Array, r.class
|
539
|
+
|
540
|
+
r = f + b
|
541
|
+
assert_equal ['x', 'y', 'c', 'd'], r
|
542
|
+
assert_equal FileList, r.class
|
543
|
+
|
544
|
+
r = FileList['w', 'x', 'y', 'z'] - f
|
545
|
+
assert_equal ['w', 'z'], r
|
546
|
+
assert_equal FileList, r.class
|
547
|
+
|
548
|
+
r = FileList['w', 'x', 'y', 'z'] & f
|
549
|
+
assert_equal ['x', 'y'], r
|
550
|
+
assert_equal FileList, r.class
|
551
|
+
|
552
|
+
r = f * 2
|
553
|
+
assert_equal ['x', 'y', 'x', 'y'], r
|
554
|
+
assert_equal FileList, r.class
|
555
|
+
|
556
|
+
r = f * ','
|
557
|
+
assert_equal 'x,y', r
|
558
|
+
assert_equal String, r.class
|
559
|
+
|
560
|
+
r = f | ['a', 'x']
|
561
|
+
assert_equal ['a', 'x', 'y'].sort, r.sort
|
562
|
+
assert_equal FileList, r.class
|
563
|
+
end
|
564
|
+
|
565
|
+
def test_other_array_returning_methods
|
566
|
+
f = FileList['a', nil, 'b']
|
567
|
+
r = f.compact
|
568
|
+
assert_equal ['a', 'b'], r
|
569
|
+
assert_equal FileList, r.class
|
570
|
+
|
571
|
+
f = FileList['a', 'b']
|
572
|
+
r = f.concat(['x', 'y'])
|
573
|
+
assert_equal ['a', 'b', 'x', 'y'], r
|
574
|
+
assert_equal FileList, r.class
|
575
|
+
|
576
|
+
f = FileList['a', ['b', 'c'], FileList['d', 'e']]
|
577
|
+
r = f.flatten
|
578
|
+
assert_equal ['a', 'b', 'c', 'd', 'e'], r
|
579
|
+
assert_equal FileList, r.class
|
580
|
+
|
581
|
+
f = FileList['a', 'b', 'a']
|
582
|
+
r = f.uniq
|
583
|
+
assert_equal ['a', 'b'], r
|
584
|
+
assert_equal FileList, r.class
|
585
|
+
|
586
|
+
f = FileList['a', 'b', 'c', 'd']
|
587
|
+
r = f.values_at(1,3)
|
588
|
+
assert_equal ['b', 'd'], r
|
589
|
+
assert_equal FileList, r.class
|
590
|
+
end
|
591
|
+
|
592
|
+
def test_file_utils_can_use_filelists
|
593
|
+
cfiles = FileList['testdata/*.c']
|
594
|
+
|
595
|
+
cp cfiles, @cdir, :verbose => false
|
596
|
+
|
597
|
+
assert File.exist?(File.join(@cdir, 'abc.c'))
|
598
|
+
assert File.exist?(File.join(@cdir, 'xyz.c'))
|
599
|
+
assert File.exist?(File.join(@cdir, 'x.c'))
|
600
|
+
end
|
601
|
+
|
602
|
+
def create_test_data
|
603
|
+
verbose(false) do
|
604
|
+
|
605
|
+
mkdir "testdata" unless File.exist? "testdata"
|
606
|
+
mkdir "testdata/CVS" rescue nil
|
607
|
+
mkdir "testdata/.svn" rescue nil
|
608
|
+
@cdir = "testdata/cfiles"
|
609
|
+
mkdir @cdir rescue nil
|
610
|
+
touch "testdata/.dummy"
|
611
|
+
touch "testdata/x.bak"
|
612
|
+
touch "testdata/x~"
|
613
|
+
touch "testdata/core"
|
614
|
+
touch "testdata/x.c"
|
615
|
+
touch "testdata/xyz.c"
|
616
|
+
touch "testdata/abc.c"
|
617
|
+
touch "testdata/abc.h"
|
618
|
+
touch "testdata/abc.x"
|
619
|
+
touch "testdata/existing"
|
620
|
+
end
|
621
|
+
end
|
622
|
+
|
623
|
+
end
|