rake 0.9.2.2 → 13.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/History.rdoc +2403 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +64 -106
- data/doc/command_line_usage.rdoc +65 -21
- data/doc/glossary.rdoc +40 -49
- data/doc/jamis.rb +1 -0
- data/doc/rake.1 +156 -0
- data/doc/rakefile.rdoc +127 -62
- data/{bin → exe}/rake +1 -7
- data/lib/rake/application.rb +507 -271
- data/lib/rake/backtrace.rb +24 -0
- data/lib/rake/clean.rb +54 -8
- data/lib/rake/cloneable.rb +11 -19
- data/lib/rake/cpu_counter.rb +107 -0
- data/lib/rake/default_loader.rb +5 -0
- data/lib/rake/dsl_definition.rb +67 -48
- data/lib/rake/early_time.rb +5 -1
- data/lib/rake/ext/core.rb +5 -6
- data/lib/rake/ext/string.rb +61 -52
- data/lib/rake/file_creation_task.rb +4 -3
- data/lib/rake/file_list.rb +81 -49
- data/lib/rake/file_task.rb +15 -8
- data/lib/rake/file_utils.rb +63 -43
- data/lib/rake/file_utils_ext.rb +14 -25
- data/lib/rake/invocation_chain.rb +25 -19
- data/lib/rake/invocation_exception_mixin.rb +1 -0
- data/lib/rake/late_time.rb +18 -0
- data/lib/rake/linked_list.rb +112 -0
- data/lib/rake/loaders/makefile.rb +23 -9
- data/lib/rake/multi_task.rb +4 -6
- data/lib/rake/name_space.rb +36 -23
- data/lib/rake/packagetask.rb +71 -34
- data/lib/rake/phony.rb +16 -0
- data/lib/rake/private_reader.rb +21 -0
- data/lib/rake/promise.rb +100 -0
- data/lib/rake/pseudo_status.rb +8 -2
- data/lib/rake/rake_module.rb +41 -3
- data/lib/rake/rake_test_loader.rb +9 -4
- data/lib/rake/rule_recursion_overflow_error.rb +2 -2
- data/lib/rake/scope.rb +43 -0
- data/lib/rake/task.rb +186 -79
- data/lib/rake/task_argument_error.rb +1 -0
- data/lib/rake/task_arguments.rb +46 -15
- data/lib/rake/task_manager.rb +91 -67
- data/lib/rake/tasklib.rb +2 -12
- data/lib/rake/testtask.rb +61 -63
- data/lib/rake/thread_history_display.rb +49 -0
- data/lib/rake/thread_pool.rb +163 -0
- data/lib/rake/trace_output.rb +23 -0
- data/lib/rake/version.rb +5 -3
- data/lib/rake/win32.rb +14 -18
- data/lib/rake.rb +35 -33
- data/rake.gemspec +100 -0
- metadata +74 -176
- data/.gemtest +0 -0
- data/CHANGES +0 -522
- data/Rakefile +0 -369
- data/TODO +0 -20
- data/doc/rake.1.gz +0 -0
- data/doc/release_notes/rake-0.4.14.rdoc +0 -23
- data/doc/release_notes/rake-0.4.15.rdoc +0 -35
- data/doc/release_notes/rake-0.5.0.rdoc +0 -53
- data/doc/release_notes/rake-0.5.3.rdoc +0 -78
- data/doc/release_notes/rake-0.5.4.rdoc +0 -46
- data/doc/release_notes/rake-0.6.0.rdoc +0 -141
- data/doc/release_notes/rake-0.7.0.rdoc +0 -119
- data/doc/release_notes/rake-0.7.1.rdoc +0 -59
- data/doc/release_notes/rake-0.7.2.rdoc +0 -121
- data/doc/release_notes/rake-0.7.3.rdoc +0 -47
- data/doc/release_notes/rake-0.8.0.rdoc +0 -114
- data/doc/release_notes/rake-0.8.2.rdoc +0 -165
- data/doc/release_notes/rake-0.8.3.rdoc +0 -112
- data/doc/release_notes/rake-0.8.4.rdoc +0 -147
- data/doc/release_notes/rake-0.8.5.rdoc +0 -53
- data/doc/release_notes/rake-0.8.6.rdoc +0 -55
- data/doc/release_notes/rake-0.8.7.rdoc +0 -55
- data/doc/release_notes/rake-0.9.0.rdoc +0 -112
- data/doc/release_notes/rake-0.9.1.rdoc +0 -52
- data/doc/release_notes/rake-0.9.2.rdoc +0 -49
- data/install.rb +0 -90
- data/lib/rake/alt_system.rb +0 -109
- data/lib/rake/classic_namespace.rb +0 -11
- data/lib/rake/contrib/compositepublisher.rb +0 -21
- data/lib/rake/contrib/ftptools.rb +0 -150
- data/lib/rake/contrib/publisher.rb +0 -73
- data/lib/rake/contrib/rubyforgepublisher.rb +0 -16
- data/lib/rake/contrib/sshpublisher.rb +0 -50
- data/lib/rake/contrib/sys.rb +0 -191
- data/lib/rake/ext/module.rb +0 -39
- data/lib/rake/ext/time.rb +0 -14
- data/lib/rake/gempackagetask.rb +0 -15
- data/lib/rake/pathmap.rb +0 -1
- data/lib/rake/rdoctask.rb +0 -234
- data/lib/rake/ruby182_test_unit_fix.rb +0 -25
- data/lib/rake/runtest.rb +0 -21
- data/test/file_creation.rb +0 -34
- data/test/helper.rb +0 -492
- data/test/test_rake.rb +0 -40
- data/test/test_rake_application.rb +0 -489
- data/test/test_rake_application_options.rb +0 -335
- data/test/test_rake_clean.rb +0 -14
- data/test/test_rake_definitions.rb +0 -80
- data/test/test_rake_directory_task.rb +0 -46
- data/test/test_rake_dsl.rb +0 -77
- data/test/test_rake_early_time.rb +0 -31
- data/test/test_rake_extension.rb +0 -59
- data/test/test_rake_file_creation_task.rb +0 -56
- data/test/test_rake_file_list.rb +0 -628
- data/test/test_rake_file_list_path_map.rb +0 -8
- data/test/test_rake_file_task.rb +0 -102
- data/test/test_rake_file_utils.rb +0 -305
- data/test/test_rake_ftp_file.rb +0 -59
- data/test/test_rake_functional.rb +0 -450
- data/test/test_rake_invocation_chain.rb +0 -52
- data/test/test_rake_makefile_loader.rb +0 -44
- data/test/test_rake_multi_task.rb +0 -51
- data/test/test_rake_name_space.rb +0 -43
- data/test/test_rake_package_task.rb +0 -79
- data/test/test_rake_path_map.rb +0 -157
- data/test/test_rake_path_map_explode.rb +0 -34
- data/test/test_rake_path_map_partial.rb +0 -18
- data/test/test_rake_pseudo_status.rb +0 -21
- data/test/test_rake_rake_test_loader.rb +0 -21
- data/test/test_rake_rdoc_task.rb +0 -83
- data/test/test_rake_require.rb +0 -40
- data/test/test_rake_rules.rb +0 -327
- data/test/test_rake_task.rb +0 -267
- data/test/test_rake_task_argument_parsing.rb +0 -103
- data/test/test_rake_task_arguments.rb +0 -88
- data/test/test_rake_task_lib.rb +0 -9
- data/test/test_rake_task_manager.rb +0 -157
- data/test/test_rake_task_manager_argument_resolution.rb +0 -36
- data/test/test_rake_task_with_arguments.rb +0 -173
- data/test/test_rake_test_task.rb +0 -120
- data/test/test_rake_top_level_functions.rb +0 -111
- data/test/test_rake_win32.rb +0 -72
- data/test/test_sys.rb +0 -20
data/test/test_rake_rules.rb
DELETED
@@ -1,327 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
class TestRakeRules < Rake::TestCase
|
5
|
-
include Rake
|
6
|
-
|
7
|
-
SRCFILE = "abc.c"
|
8
|
-
SRCFILE2 = "xyz.c"
|
9
|
-
FTNFILE = "abc.f"
|
10
|
-
OBJFILE = "abc.o"
|
11
|
-
FOOFILE = "foo"
|
12
|
-
DOTFOOFILE = ".foo"
|
13
|
-
|
14
|
-
def setup
|
15
|
-
super
|
16
|
-
|
17
|
-
Task.clear
|
18
|
-
@runs = []
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_multiple_rules1
|
22
|
-
create_file(FTNFILE)
|
23
|
-
delete_file(SRCFILE)
|
24
|
-
delete_file(OBJFILE)
|
25
|
-
rule(/\.o$/ => ['.c']) do @runs << :C end
|
26
|
-
rule(/\.o$/ => ['.f']) do @runs << :F end
|
27
|
-
t = Task[OBJFILE]
|
28
|
-
t.invoke
|
29
|
-
Task[OBJFILE].invoke
|
30
|
-
assert_equal [:F], @runs
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_multiple_rules2
|
34
|
-
create_file(FTNFILE)
|
35
|
-
delete_file(SRCFILE)
|
36
|
-
delete_file(OBJFILE)
|
37
|
-
rule(/\.o$/ => ['.f']) do @runs << :F end
|
38
|
-
rule(/\.o$/ => ['.c']) do @runs << :C end
|
39
|
-
Task[OBJFILE].invoke
|
40
|
-
assert_equal [:F], @runs
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_create_with_source
|
44
|
-
create_file(SRCFILE)
|
45
|
-
rule(/\.o$/ => ['.c']) do |t|
|
46
|
-
@runs << t.name
|
47
|
-
assert_equal OBJFILE, t.name
|
48
|
-
assert_equal SRCFILE, t.source
|
49
|
-
end
|
50
|
-
Task[OBJFILE].invoke
|
51
|
-
assert_equal [OBJFILE], @runs
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_single_dependent
|
55
|
-
create_file(SRCFILE)
|
56
|
-
rule(/\.o$/ => '.c') do |t|
|
57
|
-
@runs << t.name
|
58
|
-
end
|
59
|
-
Task[OBJFILE].invoke
|
60
|
-
assert_equal [OBJFILE], @runs
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_rule_can_be_created_by_string
|
64
|
-
create_file(SRCFILE)
|
65
|
-
rule '.o' => ['.c'] do |t|
|
66
|
-
@runs << t.name
|
67
|
-
end
|
68
|
-
Task[OBJFILE].invoke
|
69
|
-
assert_equal [OBJFILE], @runs
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_rule_prereqs_can_be_created_by_string
|
73
|
-
create_file(SRCFILE)
|
74
|
-
rule '.o' => '.c' do |t|
|
75
|
-
@runs << t.name
|
76
|
-
end
|
77
|
-
Task[OBJFILE].invoke
|
78
|
-
assert_equal [OBJFILE], @runs
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_plain_strings_as_dependents_refer_to_files
|
82
|
-
create_file(SRCFILE)
|
83
|
-
rule '.o' => SRCFILE do |t|
|
84
|
-
@runs << t.name
|
85
|
-
end
|
86
|
-
Task[OBJFILE].invoke
|
87
|
-
assert_equal [OBJFILE], @runs
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_file_names_beginning_with_dot_can_be_tricked_into_referring_to_file
|
91
|
-
verbose(false) do
|
92
|
-
create_file('.foo')
|
93
|
-
rule '.o' => "./.foo" do |t|
|
94
|
-
@runs << t.name
|
95
|
-
end
|
96
|
-
Task[OBJFILE].invoke
|
97
|
-
assert_equal [OBJFILE], @runs
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_file_names_beginning_with_dot_can_be_wrapped_in_lambda
|
102
|
-
verbose(false) do
|
103
|
-
|
104
|
-
create_file(".foo")
|
105
|
-
rule '.o' => lambda{".foo"} do |t|
|
106
|
-
@runs << "#{t.name} - #{t.source}"
|
107
|
-
end
|
108
|
-
Task[OBJFILE].invoke
|
109
|
-
assert_equal ["#{OBJFILE} - .foo"], @runs
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_file_names_containing_percent_can_be_wrapped_in_lambda
|
114
|
-
verbose(false) do
|
115
|
-
create_file("foo%x")
|
116
|
-
rule '.o' => lambda{"foo%x"} do |t|
|
117
|
-
@runs << "#{t.name} - #{t.source}"
|
118
|
-
end
|
119
|
-
Task[OBJFILE].invoke
|
120
|
-
assert_equal ["#{OBJFILE} - foo%x"], @runs
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_non_extension_rule_name_refers_to_file
|
125
|
-
verbose(false) do
|
126
|
-
create_file("abc.c")
|
127
|
-
rule "abc" => '.c' do |t|
|
128
|
-
@runs << t.name
|
129
|
-
end
|
130
|
-
Task["abc"].invoke
|
131
|
-
assert_equal ["abc"], @runs
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_pathmap_automatically_applies_to_name
|
136
|
-
verbose(false) do
|
137
|
-
create_file("zzabc.c")
|
138
|
-
rule ".o" => 'zz%{x,a}n.c' do |t|
|
139
|
-
@runs << "#{t.name} - #{t.source}"
|
140
|
-
end
|
141
|
-
Task["xbc.o"].invoke
|
142
|
-
assert_equal ["xbc.o - zzabc.c"], @runs
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_plain_strings_are_just_filenames
|
147
|
-
verbose(false) do
|
148
|
-
create_file("plainname")
|
149
|
-
rule ".o" => 'plainname' do |t|
|
150
|
-
@runs << "#{t.name} - #{t.source}"
|
151
|
-
end
|
152
|
-
Task["xbc.o"].invoke
|
153
|
-
assert_equal ["xbc.o - plainname"], @runs
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def test_rule_runs_when_explicit_task_has_no_actions
|
158
|
-
create_file(SRCFILE)
|
159
|
-
create_file(SRCFILE2)
|
160
|
-
delete_file(OBJFILE)
|
161
|
-
rule '.o' => '.c' do |t|
|
162
|
-
@runs << t.source
|
163
|
-
end
|
164
|
-
file OBJFILE => [SRCFILE2]
|
165
|
-
Task[OBJFILE].invoke
|
166
|
-
assert_equal [SRCFILE], @runs
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_close_matches_on_name_do_not_trigger_rule
|
170
|
-
create_file("x.c")
|
171
|
-
rule '.o' => ['.c'] do |t|
|
172
|
-
@runs << t.name
|
173
|
-
end
|
174
|
-
assert_raises(RuntimeError) { Task['x.obj'].invoke }
|
175
|
-
assert_raises(RuntimeError) { Task['x.xyo'].invoke }
|
176
|
-
end
|
177
|
-
|
178
|
-
def test_rule_rebuilds_obj_when_source_is_newer
|
179
|
-
create_timed_files(OBJFILE, SRCFILE)
|
180
|
-
rule(/\.o$/ => ['.c']) do
|
181
|
-
@runs << :RULE
|
182
|
-
end
|
183
|
-
Task[OBJFILE].invoke
|
184
|
-
assert_equal [:RULE], @runs
|
185
|
-
end
|
186
|
-
|
187
|
-
def test_rule_with_two_sources_runs_if_both_sources_are_present
|
188
|
-
create_timed_files(OBJFILE, SRCFILE, SRCFILE2)
|
189
|
-
rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
|
190
|
-
@runs << :RULE
|
191
|
-
end
|
192
|
-
Task[OBJFILE].invoke
|
193
|
-
assert_equal [:RULE], @runs
|
194
|
-
end
|
195
|
-
|
196
|
-
def test_rule_with_two_sources_but_one_missing_does_not_run
|
197
|
-
create_timed_files(OBJFILE, SRCFILE)
|
198
|
-
delete_file(SRCFILE2)
|
199
|
-
rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
|
200
|
-
@runs << :RULE
|
201
|
-
end
|
202
|
-
Task[OBJFILE].invoke
|
203
|
-
assert_equal [], @runs
|
204
|
-
end
|
205
|
-
|
206
|
-
def test_rule_with_two_sources_builds_both_sources
|
207
|
-
task 'x.aa'
|
208
|
-
task 'x.bb'
|
209
|
-
rule '.a' => '.aa' do
|
210
|
-
@runs << "A"
|
211
|
-
end
|
212
|
-
rule '.b' => '.bb' do
|
213
|
-
@runs << "B"
|
214
|
-
end
|
215
|
-
rule ".c" => ['.a', '.b'] do
|
216
|
-
@runs << "C"
|
217
|
-
end
|
218
|
-
Task["x.c"].invoke
|
219
|
-
assert_equal ["A", "B", "C"], @runs.sort
|
220
|
-
end
|
221
|
-
|
222
|
-
def test_second_rule_runs_when_first_rule_doesnt
|
223
|
-
create_timed_files(OBJFILE, SRCFILE)
|
224
|
-
delete_file(SRCFILE2)
|
225
|
-
rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
|
226
|
-
@runs << :RULE1
|
227
|
-
end
|
228
|
-
rule OBJFILE => [lambda{SRCFILE}] do
|
229
|
-
@runs << :RULE2
|
230
|
-
end
|
231
|
-
Task[OBJFILE].invoke
|
232
|
-
assert_equal [:RULE2], @runs
|
233
|
-
end
|
234
|
-
|
235
|
-
def test_second_rule_doest_run_if_first_triggers
|
236
|
-
create_timed_files(OBJFILE, SRCFILE, SRCFILE2)
|
237
|
-
rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
|
238
|
-
@runs << :RULE1
|
239
|
-
end
|
240
|
-
rule OBJFILE => [lambda{SRCFILE}] do
|
241
|
-
@runs << :RULE2
|
242
|
-
end
|
243
|
-
Task[OBJFILE].invoke
|
244
|
-
assert_equal [:RULE1], @runs
|
245
|
-
end
|
246
|
-
|
247
|
-
def test_second_rule_doest_run_if_first_triggers_with_reversed_rules
|
248
|
-
create_timed_files(OBJFILE, SRCFILE, SRCFILE2)
|
249
|
-
rule OBJFILE => [lambda{SRCFILE}] do
|
250
|
-
@runs << :RULE1
|
251
|
-
end
|
252
|
-
rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
|
253
|
-
@runs << :RULE2
|
254
|
-
end
|
255
|
-
Task[OBJFILE].invoke
|
256
|
-
assert_equal [:RULE1], @runs
|
257
|
-
end
|
258
|
-
|
259
|
-
def test_rule_with_proc_dependent_will_trigger
|
260
|
-
mkdir_p("src/jw")
|
261
|
-
create_file("src/jw/X.java")
|
262
|
-
rule %r(classes/.*\.class) => [
|
263
|
-
proc { |fn| fn.pathmap("%{classes,src}d/%n.java") }
|
264
|
-
] do |task|
|
265
|
-
assert_equal task.name, 'classes/jw/X.class'
|
266
|
-
assert_equal task.source, 'src/jw/X.java'
|
267
|
-
@runs << :RULE
|
268
|
-
end
|
269
|
-
Task['classes/jw/X.class'].invoke
|
270
|
-
assert_equal [:RULE], @runs
|
271
|
-
ensure
|
272
|
-
rm_r("src", :verbose=>false) rescue nil
|
273
|
-
end
|
274
|
-
|
275
|
-
def test_proc_returning_lists_are_flattened_into_prereqs
|
276
|
-
ran = false
|
277
|
-
mkdir_p("flatten")
|
278
|
-
create_file("flatten/a.txt")
|
279
|
-
task 'flatten/b.data' do |t|
|
280
|
-
ran = true
|
281
|
-
touch t.name, :verbose => false
|
282
|
-
end
|
283
|
-
rule '.html' =>
|
284
|
-
proc { |fn|
|
285
|
-
[
|
286
|
-
fn.ext("txt"),
|
287
|
-
"flatten/b.data"
|
288
|
-
]
|
289
|
-
} do |task|
|
290
|
-
end
|
291
|
-
Task['flatten/a.html'].invoke
|
292
|
-
assert ran, "Should have triggered flattened dependency"
|
293
|
-
ensure
|
294
|
-
rm_r("flatten", :verbose=>false) rescue nil
|
295
|
-
end
|
296
|
-
|
297
|
-
def test_recursive_rules_will_work_as_long_as_they_terminate
|
298
|
-
actions = []
|
299
|
-
create_file("abc.xml")
|
300
|
-
rule '.y' => '.xml' do actions << 'y' end
|
301
|
-
rule '.c' => '.y' do actions << 'c'end
|
302
|
-
rule '.o' => '.c' do actions << 'o'end
|
303
|
-
rule '.exe' => '.o' do actions << 'exe'end
|
304
|
-
Task["abc.exe"].invoke
|
305
|
-
assert_equal ['y', 'c', 'o', 'exe'], actions
|
306
|
-
end
|
307
|
-
|
308
|
-
def test_recursive_rules_that_dont_terminate_will_overflow
|
309
|
-
create_file("a.a")
|
310
|
-
prev = 'a'
|
311
|
-
('b'..'z').each do |letter|
|
312
|
-
rule ".#{letter}" => ".#{prev}" do |t| puts "#{t.name}" end
|
313
|
-
prev = letter
|
314
|
-
end
|
315
|
-
ex = assert_raises(Rake::RuleRecursionOverflowError) {
|
316
|
-
Task["a.z"].invoke
|
317
|
-
}
|
318
|
-
assert_match(/a\.z => a.y/, ex.message)
|
319
|
-
end
|
320
|
-
|
321
|
-
def test_rules_with_bad_dependents_will_fail
|
322
|
-
rule "a" => [ 1 ] do |t| puts t.name end
|
323
|
-
assert_raises(RuntimeError) do Task['a'].invoke end
|
324
|
-
end
|
325
|
-
|
326
|
-
end
|
327
|
-
|
data/test/test_rake_task.rb
DELETED
@@ -1,267 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
class TestRakeTask < Rake::TestCase
|
5
|
-
include Rake
|
6
|
-
|
7
|
-
def setup
|
8
|
-
super
|
9
|
-
|
10
|
-
Task.clear
|
11
|
-
Rake::TaskManager.record_task_metadata = true
|
12
|
-
end
|
13
|
-
|
14
|
-
def teardown
|
15
|
-
Rake::TaskManager.record_task_metadata = false
|
16
|
-
|
17
|
-
super
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_create
|
21
|
-
arg = nil
|
22
|
-
t = task(:name) { |task| arg = task; 1234 }
|
23
|
-
assert_equal "name", t.name
|
24
|
-
assert_equal [], t.prerequisites
|
25
|
-
assert t.needed?
|
26
|
-
t.execute(0)
|
27
|
-
assert_equal t, arg
|
28
|
-
assert_nil t.source
|
29
|
-
assert_equal [], t.sources
|
30
|
-
assert_equal 1, t.locations.size
|
31
|
-
assert_match(/#{Regexp.quote(__FILE__)}/, t.locations.first)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_inspect
|
35
|
-
# t = task(:foo, :needs => [:bar, :baz])
|
36
|
-
t = task(:foo => [:bar, :baz])
|
37
|
-
assert_equal "<Rake::Task foo => [bar, baz]>", t.inspect
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_invoke
|
41
|
-
runlist = []
|
42
|
-
t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
|
43
|
-
t2 = task(:t2) { |t| runlist << t.name }
|
44
|
-
t3 = task(:t3) { |t| runlist << t.name }
|
45
|
-
assert_equal ["t2", "t3"], t1.prerequisites
|
46
|
-
t1.invoke
|
47
|
-
assert_equal ["t2", "t3", "t1"], runlist
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_invoke_with_circular_dependencies
|
51
|
-
runlist = []
|
52
|
-
t1 = task(:t1 => [:t2]) { |t| runlist << t.name; 3321 }
|
53
|
-
t2 = task(:t2 => [:t1]) { |t| runlist << t.name }
|
54
|
-
assert_equal ["t2"], t1.prerequisites
|
55
|
-
assert_equal ["t1"], t2.prerequisites
|
56
|
-
ex = assert_raises RuntimeError do
|
57
|
-
t1.invoke
|
58
|
-
end
|
59
|
-
assert_match(/circular dependency/i, ex.message)
|
60
|
-
assert_match(/t1 => t2 => t1/, ex.message)
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_dry_run_prevents_actions
|
64
|
-
Rake.application.options.dryrun = true
|
65
|
-
runlist = []
|
66
|
-
t1 = task(:t1) { |t| runlist << t.name; 3321 }
|
67
|
-
_, err = capture_io { t1.invoke }
|
68
|
-
assert_match(/execute .*t1/i, err)
|
69
|
-
assert_match(/dry run/i, err)
|
70
|
-
refute_match(/invoke/i, err)
|
71
|
-
assert_equal [], runlist
|
72
|
-
ensure
|
73
|
-
Rake.application.options.dryrun = false
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_tasks_can_be_traced
|
77
|
-
Rake.application.options.trace = true
|
78
|
-
t1 = task(:t1)
|
79
|
-
_, err = capture_io {
|
80
|
-
t1.invoke
|
81
|
-
}
|
82
|
-
assert_match(/invoke t1/i, err)
|
83
|
-
assert_match(/execute t1/i, err)
|
84
|
-
ensure
|
85
|
-
Rake.application.options.trace = false
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_no_double_invoke
|
89
|
-
runlist = []
|
90
|
-
t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
|
91
|
-
t2 = task(:t2 => [:t3]) { |t| runlist << t.name }
|
92
|
-
t3 = task(:t3) { |t| runlist << t.name }
|
93
|
-
t1.invoke
|
94
|
-
assert_equal ["t3", "t2", "t1"], runlist
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_can_double_invoke_with_reenable
|
98
|
-
runlist = []
|
99
|
-
t1 = task(:t1) { |t| runlist << t.name }
|
100
|
-
t1.invoke
|
101
|
-
t1.reenable
|
102
|
-
t1.invoke
|
103
|
-
assert_equal ["t1", "t1"], runlist
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_clear
|
107
|
-
t = task("t" => "a") { }
|
108
|
-
t.clear
|
109
|
-
assert t.prerequisites.empty?, "prerequisites should be empty"
|
110
|
-
assert t.actions.empty?, "actions should be empty"
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_clear_prerequisites
|
114
|
-
t = task("t" => ["a", "b"])
|
115
|
-
assert_equal ['a', 'b'], t.prerequisites
|
116
|
-
t.clear_prerequisites
|
117
|
-
assert_equal [], t.prerequisites
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_clear_actions
|
121
|
-
t = task("t") { }
|
122
|
-
t.clear_actions
|
123
|
-
assert t.actions.empty?, "actions should be empty"
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_find
|
127
|
-
task :tfind
|
128
|
-
assert_equal "tfind", Task[:tfind].name
|
129
|
-
ex = assert_raises(RuntimeError) { Task[:leaves] }
|
130
|
-
assert_equal "Don't know how to build task 'leaves'", ex.message
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_defined
|
134
|
-
assert ! Task.task_defined?(:a)
|
135
|
-
task :a
|
136
|
-
assert Task.task_defined?(:a)
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_multi_invocations
|
140
|
-
runs = []
|
141
|
-
p = proc do |t| runs << t.name end
|
142
|
-
task({:t1=>[:t2,:t3]}, &p)
|
143
|
-
task({:t2=>[:t3]}, &p)
|
144
|
-
task(:t3, &p)
|
145
|
-
Task[:t1].invoke
|
146
|
-
assert_equal ["t1", "t2", "t3"], runs.sort
|
147
|
-
end
|
148
|
-
|
149
|
-
def test_task_list
|
150
|
-
task :t2
|
151
|
-
task :t1 => [:t2]
|
152
|
-
assert_equal ["t1", "t2"], Task.tasks.collect {|t| t.name}
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_task_gives_name_on_to_s
|
156
|
-
task :abc
|
157
|
-
assert_equal "abc", Task[:abc].to_s
|
158
|
-
end
|
159
|
-
|
160
|
-
def test_symbols_can_be_prerequisites
|
161
|
-
task :a => :b
|
162
|
-
assert_equal ["b"], Task[:a].prerequisites
|
163
|
-
end
|
164
|
-
|
165
|
-
def test_strings_can_be_prerequisites
|
166
|
-
task :a => "b"
|
167
|
-
assert_equal ["b"], Task[:a].prerequisites
|
168
|
-
end
|
169
|
-
|
170
|
-
def test_arrays_can_be_prerequisites
|
171
|
-
task :a => ["b", "c"]
|
172
|
-
assert_equal ["b", "c"], Task[:a].prerequisites
|
173
|
-
end
|
174
|
-
|
175
|
-
def test_filelists_can_be_prerequisites
|
176
|
-
task :a => FileList.new.include("b", "c")
|
177
|
-
assert_equal ["b", "c"], Task[:a].prerequisites
|
178
|
-
end
|
179
|
-
|
180
|
-
def test_prerequiste_tasks_returns_tasks_not_strings
|
181
|
-
a = task :a => ["b", "c"]
|
182
|
-
b = task :b
|
183
|
-
c = task :c
|
184
|
-
assert_equal [b, c], a.prerequisite_tasks
|
185
|
-
end
|
186
|
-
|
187
|
-
def test_prerequiste_tasks_fails_if_prerequisites_are_undefined
|
188
|
-
a = task :a => ["b", "c"]
|
189
|
-
b = task :b
|
190
|
-
assert_raises(RuntimeError) do
|
191
|
-
a.prerequisite_tasks
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
def test_prerequiste_tasks_honors_namespaces
|
196
|
-
a = b = nil
|
197
|
-
namespace "X" do
|
198
|
-
a = task :a => ["b", "c"]
|
199
|
-
b = task :b
|
200
|
-
end
|
201
|
-
c = task :c
|
202
|
-
|
203
|
-
assert_equal [b, c], a.prerequisite_tasks
|
204
|
-
end
|
205
|
-
|
206
|
-
def test_timestamp_returns_now_if_all_prereqs_have_no_times
|
207
|
-
a = task :a => ["b", "c"]
|
208
|
-
b = task :b
|
209
|
-
c = task :c
|
210
|
-
|
211
|
-
assert_in_delta Time.now, a.timestamp, 0.1, 'computer too slow?'
|
212
|
-
end
|
213
|
-
|
214
|
-
def test_timestamp_returns_latest_prereq_timestamp
|
215
|
-
a = task :a => ["b", "c"]
|
216
|
-
b = task :b
|
217
|
-
c = task :c
|
218
|
-
|
219
|
-
now = Time.now
|
220
|
-
def b.timestamp() Time.now + 10 end
|
221
|
-
def c.timestamp() Time.now + 5 end
|
222
|
-
|
223
|
-
assert_in_delta now + 10, a.timestamp, 0.1, 'computer too slow?'
|
224
|
-
end
|
225
|
-
|
226
|
-
def test_investigation_output
|
227
|
-
t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
|
228
|
-
task(:t2)
|
229
|
-
task(:t3)
|
230
|
-
out = t1.investigation
|
231
|
-
assert_match(/class:\s*Rake::Task/, out)
|
232
|
-
assert_match(/needed:\s*true/, out)
|
233
|
-
assert_match(/pre-requisites:\s*--t[23]/, out)
|
234
|
-
end
|
235
|
-
|
236
|
-
|
237
|
-
def test_extended_comments
|
238
|
-
desc %{
|
239
|
-
This is a comment.
|
240
|
-
|
241
|
-
And this is the extended comment.
|
242
|
-
name -- Name of task to execute.
|
243
|
-
rev -- Software revision to use.
|
244
|
-
}
|
245
|
-
t = task(:t, :name, :rev)
|
246
|
-
assert_equal "[name,rev]", t.arg_description
|
247
|
-
assert_equal "This is a comment.", t.comment
|
248
|
-
assert_match(/^\s*name -- Name/, t.full_comment)
|
249
|
-
assert_match(/^\s*rev -- Software/, t.full_comment)
|
250
|
-
assert_match(/\A\s*This is a comment\.$/, t.full_comment)
|
251
|
-
end
|
252
|
-
|
253
|
-
def test_multiple_comments
|
254
|
-
desc "line one"
|
255
|
-
t = task(:t)
|
256
|
-
desc "line two"
|
257
|
-
task(:t)
|
258
|
-
assert_equal "line one / line two", t.comment
|
259
|
-
end
|
260
|
-
|
261
|
-
def test_settable_comments
|
262
|
-
t = task(:t)
|
263
|
-
t.comment = "HI"
|
264
|
-
assert_equal "HI", t.comment
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
@@ -1,103 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
|
3
|
-
class TestRakeTaskArgumentParsing < Rake::TestCase
|
4
|
-
def setup
|
5
|
-
super
|
6
|
-
|
7
|
-
@app = Rake::Application.new
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_name_only
|
11
|
-
name, args = @app.parse_task_string("name")
|
12
|
-
assert_equal "name", name
|
13
|
-
assert_equal [], args
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_empty_args
|
17
|
-
name, args = @app.parse_task_string("name[]")
|
18
|
-
assert_equal "name", name
|
19
|
-
assert_equal [], args
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_one_argument
|
23
|
-
name, args = @app.parse_task_string("name[one]")
|
24
|
-
assert_equal "name", name
|
25
|
-
assert_equal ["one"], args
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_two_arguments
|
29
|
-
name, args = @app.parse_task_string("name[one,two]")
|
30
|
-
assert_equal "name", name
|
31
|
-
assert_equal ["one", "two"], args
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_can_handle_spaces_between_args
|
35
|
-
name, args = @app.parse_task_string("name[one, two,\tthree , \tfour]")
|
36
|
-
assert_equal "name", name
|
37
|
-
assert_equal ["one", "two", "three", "four"], args
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_keeps_embedded_spaces
|
41
|
-
name, args = @app.parse_task_string("name[a one ana, two]")
|
42
|
-
assert_equal "name", name
|
43
|
-
assert_equal ["a one ana", "two"], args
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_terminal_width_using_env
|
47
|
-
app = Rake::Application.new
|
48
|
-
app.terminal_columns = 1234
|
49
|
-
|
50
|
-
assert_equal 1234, app.terminal_width
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_terminal_width_using_stty
|
54
|
-
def @app.unix?() true end
|
55
|
-
def @app.dynamic_width_stty() 1235 end
|
56
|
-
def @app.dynamic_width_tput() 0 end
|
57
|
-
|
58
|
-
assert_equal 1235, @app.terminal_width
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_terminal_width_using_tput
|
62
|
-
def @app.unix?() true end
|
63
|
-
def @app.dynamic_width_stty() 0 end
|
64
|
-
def @app.dynamic_width_tput() 1236 end
|
65
|
-
|
66
|
-
assert_equal 1236, @app.terminal_width
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_terminal_width_using_hardcoded_80
|
70
|
-
def @app.unix?() false end
|
71
|
-
|
72
|
-
assert_equal 80, @app.terminal_width
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_terminal_width_with_failure
|
76
|
-
def @app.unix?() raise end
|
77
|
-
|
78
|
-
assert_equal 80, @app.terminal_width
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_no_rakeopt
|
82
|
-
ARGV << '--trace'
|
83
|
-
app = Rake::Application.new
|
84
|
-
app.init
|
85
|
-
assert !app.options.silent
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_rakeopt_with_blank_options
|
89
|
-
ARGV << '--trace'
|
90
|
-
app = Rake::Application.new
|
91
|
-
app.init
|
92
|
-
assert !app.options.silent
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_rakeopt_with_silent_options
|
96
|
-
ENV['RAKEOPT'] = '-s'
|
97
|
-
app = Rake::Application.new
|
98
|
-
|
99
|
-
app.init
|
100
|
-
|
101
|
-
assert app.options.silent
|
102
|
-
end
|
103
|
-
end
|