rake 0.4.8 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +183 -0
- data/README +47 -14
- data/Rakefile +212 -44
- data/bin/rake +2 -3
- data/doc/jamis.rb +591 -0
- data/doc/rake.1.gz +0 -0
- data/doc/rakefile.rdoc +180 -3
- data/doc/release_notes/rake-0.4.14.rdoc +23 -0
- data/doc/release_notes/rake-0.4.15.rdoc +35 -0
- data/doc/release_notes/rake-0.5.0.rdoc +53 -0
- data/doc/release_notes/rake-0.5.3.rdoc +78 -0
- data/doc/release_notes/rake-0.5.4.rdoc +46 -0
- data/doc/release_notes/rake-0.6.0.rdoc +141 -0
- data/doc/release_notes/rake-0.7.0.rdoc +119 -0
- data/doc/release_notes/rake-0.7.1.rdoc +59 -0
- data/doc/release_notes/rake-0.7.2.rdoc +121 -0
- data/doc/release_notes/rake-0.7.3.rdoc +47 -0
- data/lib/rake/classic_namespace.rb +8 -0
- data/lib/rake/clean.rb +3 -1
- data/lib/rake/contrib/ftptools.rb +21 -21
- data/lib/rake/contrib/rubyforgepublisher.rb +3 -3
- data/lib/rake/contrib/sshpublisher.rb +1 -1
- data/lib/rake/contrib/sys.rb +20 -21
- data/lib/rake/gempackagetask.rb +12 -9
- data/lib/rake/loaders/makefile.rb +40 -0
- data/lib/rake/packagetask.rb +65 -33
- data/lib/rake/rake_test_loader.rb +5 -0
- data/lib/rake/rdoctask.rb +34 -15
- data/lib/rake/ruby182_test_unit_fix.rb +23 -0
- data/lib/rake/runtest.rb +4 -4
- data/lib/rake/tasklib.rb +3 -9
- data/lib/rake/testtask.rb +67 -24
- data/lib/rake.rb +1600 -552
- data/test/capture_stdout.rb +26 -0
- data/test/data/chains/Rakefile +15 -0
- data/test/data/default/Rakefile +19 -0
- data/test/data/dryrun/Rakefile +22 -0
- data/test/data/file_creation_task/Rakefile +30 -0
- data/test/data/imports/Rakefile +19 -0
- data/test/data/imports/deps.mf +1 -0
- data/test/data/multidesc/Rakefile +14 -0
- data/test/data/namespace/Rakefile +57 -0
- data/test/data/rakelib/test1.rb +3 -0
- data/test/data/sample.mf +9 -0
- data/test/data/unittest/Rakefile +1 -0
- data/test/filecreation.rb +18 -10
- data/test/functional.rb +3 -72
- data/test/reqfile.rb +3 -0
- data/test/reqfile2.rb +3 -0
- data/test/session_functional.rb +218 -0
- data/test/shellcommand.rb +3 -0
- data/test/test_application.rb +425 -0
- data/test/{testclean.rb → test_clean.rb} +1 -0
- data/test/test_definitions.rb +82 -0
- data/test/test_earlytime.rb +35 -0
- data/test/test_file_creation_task.rb +62 -0
- data/test/test_file_task.rb +139 -0
- data/test/test_filelist.rb +574 -0
- data/test/test_fileutils.rb +230 -0
- data/test/test_makefile_loader.rb +23 -0
- data/test/test_multitask.rb +45 -0
- data/test/test_namespace.rb +32 -0
- data/test/test_package_task.rb +130 -0
- data/test/test_pathmap.rb +188 -0
- data/test/test_rake.rb +34 -0
- data/test/test_require.rb +33 -0
- data/test/test_rules.rb +305 -0
- data/test/test_task_manager.rb +148 -0
- data/test/test_tasks.rb +146 -0
- data/test/{testtesttask.rb → test_test_task.rb} +5 -0
- data/test/test_top_level_functions.rb +79 -0
- metadata +134 -68
- data/test/testfilelist.rb +0 -255
- data/test/testfileutils.rb +0 -55
- data/test/testpackagetask.rb +0 -81
- data/test/testtasks.rb +0 -371
- /data/test/{testftp.rb → test_ftp.rb} +0 -0
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
begin
|
|
4
|
+
require 'rubygems'
|
|
5
|
+
rescue LoadError
|
|
6
|
+
# got no gems
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
require 'test/unit'
|
|
10
|
+
require 'rake'
|
|
11
|
+
require 'test/capture_stdout'
|
|
12
|
+
require 'flexmock'
|
|
13
|
+
|
|
14
|
+
TESTING_REQUIRE = [ ]
|
|
15
|
+
|
|
16
|
+
######################################################################
|
|
17
|
+
class TestApplication < Test::Unit::TestCase
|
|
18
|
+
include CaptureStdout
|
|
19
|
+
include FlexMock::TestCase
|
|
20
|
+
|
|
21
|
+
def setup
|
|
22
|
+
@app = Rake::Application.new
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_constant_warning
|
|
26
|
+
err = capture_stderr do @app.instance_eval { const_warning("Task") } end
|
|
27
|
+
assert_match(/warning/i, err)
|
|
28
|
+
assert_match(/deprecated/i, err)
|
|
29
|
+
assert_match(/Task/i, err)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_display_tasks
|
|
33
|
+
@app.options.show_task_pattern = //
|
|
34
|
+
@app.last_comment = "COMMENT"
|
|
35
|
+
@app.define_task(Rake::Task, "t")
|
|
36
|
+
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
|
37
|
+
assert_match(/^rake t/, out)
|
|
38
|
+
assert_match(/# COMMENT/, out)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_finding_rakefile
|
|
42
|
+
assert @app.instance_eval { have_rakefile }
|
|
43
|
+
assert_equal "rakefile", @app.rakefile.downcase
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_not_finding_rakefile
|
|
47
|
+
@app.instance_eval { @rakefiles = ['NEVER_FOUND'] }
|
|
48
|
+
assert( ! @app.instance_eval do have_rakefile end )
|
|
49
|
+
assert_nil @app.rakefile
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_load_rakefile
|
|
53
|
+
original_dir = Dir.pwd
|
|
54
|
+
Dir.chdir("test/data/unittest")
|
|
55
|
+
@app.instance_eval do
|
|
56
|
+
handle_options
|
|
57
|
+
options.silent = true
|
|
58
|
+
load_rakefile
|
|
59
|
+
end
|
|
60
|
+
assert_equal "rakefile", @app.rakefile.downcase
|
|
61
|
+
assert_match(%r(unittest$), Dir.pwd)
|
|
62
|
+
ensure
|
|
63
|
+
Dir.chdir(original_dir)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_load_rakefile_from_subdir
|
|
67
|
+
original_dir = Dir.pwd
|
|
68
|
+
Dir.chdir("test/data/unittest/subdir")
|
|
69
|
+
@app.instance_eval do
|
|
70
|
+
handle_options
|
|
71
|
+
options.silent = true
|
|
72
|
+
load_rakefile
|
|
73
|
+
end
|
|
74
|
+
assert_equal "rakefile", @app.rakefile.downcase
|
|
75
|
+
assert_match(%r(unittest$), Dir.pwd)
|
|
76
|
+
ensure
|
|
77
|
+
Dir.chdir(original_dir)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_load_rakefile_not_found
|
|
81
|
+
original_dir = Dir.pwd
|
|
82
|
+
Dir.chdir("/")
|
|
83
|
+
@app.instance_eval do
|
|
84
|
+
handle_options
|
|
85
|
+
options.silent = true
|
|
86
|
+
end
|
|
87
|
+
ex = assert_raise(RuntimeError) do
|
|
88
|
+
@app.instance_eval do raw_load_rakefile end
|
|
89
|
+
end
|
|
90
|
+
assert_match(/no rakefile found/i, ex.message)
|
|
91
|
+
ensure
|
|
92
|
+
Dir.chdir(original_dir)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_not_caring_about_finding_rakefile
|
|
96
|
+
@app.instance_eval do @rakefiles = [''] end
|
|
97
|
+
assert(@app.instance_eval do have_rakefile end)
|
|
98
|
+
assert_equal '', @app.rakefile
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def test_loading_imports
|
|
102
|
+
mock = flexmock("loader")
|
|
103
|
+
mock.should_receive(:load).with("x.dummy").once
|
|
104
|
+
@app.instance_eval do
|
|
105
|
+
add_loader("dummy", mock)
|
|
106
|
+
add_import("x.dummy")
|
|
107
|
+
load_imports
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_building_imported_files_on_demand
|
|
112
|
+
mock = flexmock("loader")
|
|
113
|
+
mock.should_receive(:load).with("x.dummy").once
|
|
114
|
+
mock.should_receive(:make_dummy).with_no_args.once
|
|
115
|
+
@app.instance_eval do
|
|
116
|
+
intern(Rake::Task, "x.dummy").enhance do mock.make_dummy end
|
|
117
|
+
add_loader("dummy", mock)
|
|
118
|
+
add_import("x.dummy")
|
|
119
|
+
load_imports
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def test_good_run
|
|
124
|
+
ran = false
|
|
125
|
+
@app.options.silent = true
|
|
126
|
+
@app.instance_eval do
|
|
127
|
+
intern(Rake::Task, "default").enhance { ran = true }
|
|
128
|
+
end
|
|
129
|
+
@app.run
|
|
130
|
+
assert ran
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def test_display_task_run
|
|
134
|
+
ran = false
|
|
135
|
+
ARGV.clear
|
|
136
|
+
ARGV << '-f' << '-s' << '--tasks'
|
|
137
|
+
@app.last_comment = "COMMENT"
|
|
138
|
+
@app.define_task(Rake::Task, "default")
|
|
139
|
+
out = capture_stdout { @app.run }
|
|
140
|
+
assert @app.options.show_tasks
|
|
141
|
+
assert ! ran
|
|
142
|
+
assert_match(/rake default/, out)
|
|
143
|
+
assert_match(/# COMMENT/, out)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def test_display_prereqs
|
|
147
|
+
ran = false
|
|
148
|
+
ARGV.clear
|
|
149
|
+
ARGV << '-f' << '-s' << '--prereqs'
|
|
150
|
+
@app.last_comment = "COMMENT"
|
|
151
|
+
t = @app.define_task(Rake::Task, "default")
|
|
152
|
+
t.enhance([:a, :b])
|
|
153
|
+
@app.define_task(Rake::Task, "a")
|
|
154
|
+
@app.define_task(Rake::Task, "b")
|
|
155
|
+
out = capture_stdout { @app.run }
|
|
156
|
+
assert @app.options.show_prereqs
|
|
157
|
+
assert ! ran
|
|
158
|
+
assert_match(/rake a$/, out)
|
|
159
|
+
assert_match(/rake b$/, out)
|
|
160
|
+
assert_match(/rake default\n( *(a|b)\n){2}/m, out)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def test_bad_run
|
|
164
|
+
@app.intern(Rake::Task, "default").enhance { fail }
|
|
165
|
+
ARGV.clear
|
|
166
|
+
ARGV << '-f' << '-s'
|
|
167
|
+
assert_raise(SystemExit) {
|
|
168
|
+
err = capture_stderr { @app.run }
|
|
169
|
+
assert_match(/see full trace/, err)
|
|
170
|
+
}
|
|
171
|
+
ensure
|
|
172
|
+
ARGV.clear
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def test_bad_run_with_trace
|
|
176
|
+
@app.intern(Rake::Task, "default").enhance { fail }
|
|
177
|
+
ARGV.clear
|
|
178
|
+
ARGV << '-f' << '-s' << '-t'
|
|
179
|
+
assert_raise(SystemExit) {
|
|
180
|
+
err = capture_stderr { capture_stdout { @app.run } }
|
|
181
|
+
assert_no_match(/see full trace/, err)
|
|
182
|
+
}
|
|
183
|
+
ensure
|
|
184
|
+
ARGV.clear
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def test_run_with_bad_options
|
|
188
|
+
@app.intern(Rake::Task, "default").enhance { fail }
|
|
189
|
+
ARGV.clear
|
|
190
|
+
ARGV << '-f' << '-s' << '--xyzzy'
|
|
191
|
+
assert_raise(SystemExit) {
|
|
192
|
+
err = capture_stderr { capture_stdout { @app.run } }
|
|
193
|
+
}
|
|
194
|
+
ensure
|
|
195
|
+
ARGV.clear
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
######################################################################
|
|
202
|
+
class TestApplicationOptions < Test::Unit::TestCase
|
|
203
|
+
include CaptureStdout
|
|
204
|
+
|
|
205
|
+
def setup
|
|
206
|
+
clear_argv
|
|
207
|
+
RakeFileUtils.verbose_flag = false
|
|
208
|
+
RakeFileUtils.nowrite_flag = false
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def teardown
|
|
212
|
+
clear_argv
|
|
213
|
+
RakeFileUtils.verbose_flag = false
|
|
214
|
+
RakeFileUtils.nowrite_flag = false
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def clear_argv
|
|
218
|
+
while ! ARGV.empty?
|
|
219
|
+
ARGV.pop
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def test_default_options
|
|
224
|
+
opts = command_line
|
|
225
|
+
assert_nil opts.show_task_pattern
|
|
226
|
+
assert_nil opts.dryrun
|
|
227
|
+
assert_nil opts.trace
|
|
228
|
+
assert_nil opts.nosearch
|
|
229
|
+
assert_nil opts.silent
|
|
230
|
+
assert_nil opts.show_prereqs
|
|
231
|
+
assert_nil opts.show_tasks
|
|
232
|
+
assert_nil opts.classic_namespace
|
|
233
|
+
assert_equal 'rakelib', opts.rakelib
|
|
234
|
+
assert ! RakeFileUtils.verbose_flag
|
|
235
|
+
assert ! RakeFileUtils.nowrite_flag
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def test_trace_option
|
|
239
|
+
flags('--trace', '-t') do |opts|
|
|
240
|
+
assert opts.trace
|
|
241
|
+
assert RakeFileUtils.verbose_flag
|
|
242
|
+
assert ! RakeFileUtils.nowrite_flag
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
def test_dry_run
|
|
247
|
+
flags('--dry-run', '-n') do |opts|
|
|
248
|
+
assert opts.dryrun
|
|
249
|
+
assert opts.trace
|
|
250
|
+
assert RakeFileUtils.verbose_flag
|
|
251
|
+
assert RakeFileUtils.nowrite_flag
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def test_help
|
|
256
|
+
flags('--help', '-H') do |opts, output|
|
|
257
|
+
assert_match(/\Arake/, @out)
|
|
258
|
+
assert_match(/--help/, @out)
|
|
259
|
+
assert_equal :exit, @exit
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def test_usage
|
|
264
|
+
flags('--usage', '-h') do |opts, output|
|
|
265
|
+
assert_match(/\Arake/, @out)
|
|
266
|
+
assert_match(/\boptions\b/, @out)
|
|
267
|
+
assert_match(/\btargets\b/, @out)
|
|
268
|
+
assert_equal :exit, @exit
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def test_libdir
|
|
273
|
+
flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts|
|
|
274
|
+
$:.include?('xx')
|
|
275
|
+
end
|
|
276
|
+
ensure
|
|
277
|
+
$:.delete('xx')
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
def test_nosearch
|
|
281
|
+
flags('--nosearch', '-N') do |opts|
|
|
282
|
+
assert opts.nosearch
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def test_show_prereqs
|
|
287
|
+
flags('--prereqs', '-P') do |opts|
|
|
288
|
+
assert opts.show_prereqs
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
def test_quiet
|
|
293
|
+
flags('--quiet', '-q') do |opts|
|
|
294
|
+
assert ! RakeFileUtils.verbose_flag
|
|
295
|
+
assert ! opts.silent
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
def test_silent
|
|
300
|
+
flags('--silent', '-s') do |opts|
|
|
301
|
+
assert ! RakeFileUtils.verbose_flag
|
|
302
|
+
assert opts.silent
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def test_rakefile
|
|
307
|
+
flags(['--rakefile', 'RF'], ['--rakefile=RF'], ['-f', 'RF'], ['-fRF']) do |opts|
|
|
308
|
+
assert_equal ['RF'], @app.instance_eval { @rakefiles }
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def test_rakelib
|
|
313
|
+
flags(['--rakelibdir', 'A:B:C'], ['--rakelibdir=A:B:C'], ['-R', 'A:B:C'], ['-RA:B:C']) do |opts|
|
|
314
|
+
assert_equal ['A', 'B', 'C'], opts.rakelib
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
def test_require
|
|
319
|
+
flags(['--require', 'test/reqfile'], '-rtest/reqfile2', '-rtest/reqfile3') do |opts|
|
|
320
|
+
end
|
|
321
|
+
assert TESTING_REQUIRE.include?(1)
|
|
322
|
+
assert TESTING_REQUIRE.include?(2)
|
|
323
|
+
assert TESTING_REQUIRE.include?(3)
|
|
324
|
+
assert_equal 3, TESTING_REQUIRE.size
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
def test_missing_require
|
|
328
|
+
ex = assert_raises(LoadError) do
|
|
329
|
+
flags(['--require', 'test/missing']) do |opts|
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
assert_match(/no such file/, ex.message)
|
|
333
|
+
assert_match(/test\/missing/, ex.message)
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
def test_tasks
|
|
337
|
+
flags('--tasks', '-T') do |opts|
|
|
338
|
+
assert opts.show_tasks
|
|
339
|
+
assert_equal(//.to_s, opts.show_task_pattern.to_s)
|
|
340
|
+
end
|
|
341
|
+
flags(['--tasks', 'xyz'], ['-Txyz']) do |opts|
|
|
342
|
+
assert opts.show_tasks
|
|
343
|
+
assert_equal(/xyz/, opts.show_task_pattern)
|
|
344
|
+
end
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
def test_verbose
|
|
348
|
+
flags('--verbose', '-V') do |opts|
|
|
349
|
+
assert RakeFileUtils.verbose_flag
|
|
350
|
+
assert ! opts.silent
|
|
351
|
+
end
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
def test_version
|
|
355
|
+
flags('--version', '-V') do |opts|
|
|
356
|
+
assert_match(/\bversion\b/, @out)
|
|
357
|
+
assert_match(/\b#{RAKEVERSION}\b/, @out)
|
|
358
|
+
assert_equal :exit, @exit
|
|
359
|
+
end
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
def test_classic_namespace
|
|
363
|
+
flags(['--classic-namespace'], ['-C', '-T', '-P', '-n', '-s', '-t']) do |opts|
|
|
364
|
+
assert opts.classic_namespace
|
|
365
|
+
assert_equal opts.show_tasks, $show_tasks
|
|
366
|
+
assert_equal opts.show_prereqs, $show_prereqs
|
|
367
|
+
assert_equal opts.trace, $trace
|
|
368
|
+
assert_equal opts.dryrun, $dryrun
|
|
369
|
+
assert_equal opts.silent, $silent
|
|
370
|
+
end
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
def test_bad_option
|
|
374
|
+
capture_stderr do
|
|
375
|
+
ex = assert_raise(GetoptLong::InvalidOption) do
|
|
376
|
+
flags('--bad-option')
|
|
377
|
+
end
|
|
378
|
+
assert_match(/unrecognized option/, ex.message)
|
|
379
|
+
assert_match(/--bad-option/, ex.message)
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
def test_task_collection
|
|
384
|
+
command_line("a", "b")
|
|
385
|
+
assert_equal ["a", "b"], @tasks.sort
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
def test_default_task_collection
|
|
389
|
+
command_line()
|
|
390
|
+
assert_equal ["default"], @tasks
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
def test_environment_definition
|
|
394
|
+
ENV['TESTKEY'] = nil
|
|
395
|
+
command_line("a", "TESTKEY=12")
|
|
396
|
+
assert_equal ["a"], @tasks.sort
|
|
397
|
+
assert '12', ENV['TESTKEY']
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
private
|
|
401
|
+
|
|
402
|
+
def flags(*sets)
|
|
403
|
+
sets.each do |set|
|
|
404
|
+
@out = capture_stdout {
|
|
405
|
+
@exit = catch(:system_exit) { opts = command_line(*set) }
|
|
406
|
+
}
|
|
407
|
+
yield(@app.options) if block_given?
|
|
408
|
+
end
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
def command_line(*options)
|
|
412
|
+
options.each do |opt| ARGV << opt end
|
|
413
|
+
@app = Rake::Application.new
|
|
414
|
+
def @app.exit(*args)
|
|
415
|
+
throw :system_exit, :exit
|
|
416
|
+
end
|
|
417
|
+
@app.instance_eval do
|
|
418
|
+
handle_options
|
|
419
|
+
collect_tasks
|
|
420
|
+
end
|
|
421
|
+
@tasks = @app.top_level_tasks
|
|
422
|
+
@app.options
|
|
423
|
+
end
|
|
424
|
+
end
|
|
425
|
+
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'test/unit'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
require 'rake'
|
|
6
|
+
require 'test/filecreation'
|
|
7
|
+
|
|
8
|
+
######################################################################
|
|
9
|
+
class TestDefinitions < Test::Unit::TestCase
|
|
10
|
+
include Rake
|
|
11
|
+
EXISTINGFILE = "testdata/existing"
|
|
12
|
+
|
|
13
|
+
def setup
|
|
14
|
+
Task.clear
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_task
|
|
18
|
+
done = false
|
|
19
|
+
task :one => [:two] do done = true end
|
|
20
|
+
task :two
|
|
21
|
+
task :three => [:one, :two]
|
|
22
|
+
check_tasks(:one, :two, :three)
|
|
23
|
+
assert done, "Should be done"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_file_task
|
|
27
|
+
done = false
|
|
28
|
+
file "testdata/one" => "testdata/two" do done = true end
|
|
29
|
+
file "testdata/two"
|
|
30
|
+
file "testdata/three" => ["testdata/one", "testdata/two"]
|
|
31
|
+
check_tasks("testdata/one", "testdata/two", "testdata/three")
|
|
32
|
+
assert done, "Should be done"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def check_tasks(n1, n2, n3)
|
|
36
|
+
t = Task[n1]
|
|
37
|
+
assert Task === t, "Should be a Task"
|
|
38
|
+
assert_equal n1.to_s, t.name
|
|
39
|
+
assert_equal [n2.to_s], t.prerequisites.collect{|n| n.to_s}
|
|
40
|
+
t.invoke
|
|
41
|
+
t2 = Task[n2]
|
|
42
|
+
assert_equal FileList[], t2.prerequisites
|
|
43
|
+
t3 = Task[n3]
|
|
44
|
+
assert_equal [n1.to_s, n2.to_s], t3.prerequisites.collect{|n|n.to_s}
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_incremental_definitions
|
|
48
|
+
runs = []
|
|
49
|
+
task :t1 => [:t2] do runs << "A"; 4321 end
|
|
50
|
+
task :t1 => [:t3] do runs << "B"; 1234 end
|
|
51
|
+
task :t1 => [:t3]
|
|
52
|
+
task :t2
|
|
53
|
+
task :t3
|
|
54
|
+
Task[:t1].invoke
|
|
55
|
+
assert_equal ["A", "B"], runs
|
|
56
|
+
assert_equal ["t2", "t3"], Task[:t1].prerequisites
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_missing_dependencies
|
|
60
|
+
task :x => ["testdata/missing"]
|
|
61
|
+
assert_raises(RuntimeError) { Task[:x].invoke }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_implicit_file_dependencies
|
|
65
|
+
runs = []
|
|
66
|
+
create_existing_file
|
|
67
|
+
task :y => [EXISTINGFILE] do |t| runs << t.name end
|
|
68
|
+
Task[:y].invoke
|
|
69
|
+
assert_equal runs, ['y']
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
private # ----------------------------------------------------------
|
|
73
|
+
|
|
74
|
+
def create_existing_file
|
|
75
|
+
Dir.mkdir File.dirname(EXISTINGFILE) unless
|
|
76
|
+
File.exist?(File.dirname(EXISTINGFILE))
|
|
77
|
+
open(EXISTINGFILE, "w") do |f| f.puts "HI" end unless
|
|
78
|
+
File.exist?(EXISTINGFILE)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
82
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'test/unit'
|
|
4
|
+
require 'rake'
|
|
5
|
+
|
|
6
|
+
class TestEarlyTime < Test::Unit::TestCase
|
|
7
|
+
def test_create
|
|
8
|
+
early = Rake::EarlyTime.instance
|
|
9
|
+
time = Time.mktime(1920, 1, 1, 0, 0, 0)
|
|
10
|
+
assert early <= Time.now
|
|
11
|
+
assert early < Time.now
|
|
12
|
+
assert early != Time.now
|
|
13
|
+
assert Time.now > early
|
|
14
|
+
assert Time.now >= early
|
|
15
|
+
assert Time.now != early
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_equality
|
|
19
|
+
early = Rake::EarlyTime.instance
|
|
20
|
+
assert_equal early, early, "two early times should be equal"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_original_time_compare_is_not_messed_up
|
|
24
|
+
t1 = Time.mktime(1920, 1, 1, 0, 0, 0)
|
|
25
|
+
t2 = Time.now
|
|
26
|
+
assert t1 < t2
|
|
27
|
+
assert t2 > t1
|
|
28
|
+
assert t1 == t1
|
|
29
|
+
assert t2 == t2
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_to_s
|
|
33
|
+
assert_equal "<EARLY TIME>", Rake::EARLY.to_s
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'test/unit'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
require 'rake'
|
|
6
|
+
require 'test/filecreation'
|
|
7
|
+
|
|
8
|
+
######################################################################
|
|
9
|
+
class TestFileCreationTask < Test::Unit::TestCase
|
|
10
|
+
include Rake
|
|
11
|
+
include FileCreation
|
|
12
|
+
|
|
13
|
+
DUMMY_DIR = 'testdata/dummy_dir'
|
|
14
|
+
|
|
15
|
+
def setup
|
|
16
|
+
Task.clear
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def teardown
|
|
20
|
+
FileUtils.rm_rf DUMMY_DIR
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_file_needed
|
|
24
|
+
create_dir DUMMY_DIR
|
|
25
|
+
fc_task = Task[DUMMY_DIR]
|
|
26
|
+
assert_equal DUMMY_DIR, fc_task.name
|
|
27
|
+
FileUtils.rm_rf fc_task.name
|
|
28
|
+
assert fc_task.needed?, "file should be needed"
|
|
29
|
+
FileUtils.mkdir fc_task.name
|
|
30
|
+
assert_equal nil, fc_task.prerequisites.collect{|n| Task[n].timestamp}.max
|
|
31
|
+
assert ! fc_task.needed?, "file should not be needed"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_directory
|
|
35
|
+
directory DUMMY_DIR
|
|
36
|
+
fc_task = Task[DUMMY_DIR]
|
|
37
|
+
assert_equal DUMMY_DIR, fc_task.name
|
|
38
|
+
assert FileCreationTask === fc_task
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_no_retriggers_on_filecreate_task
|
|
42
|
+
create_timed_files(OLDFILE, NEWFILE)
|
|
43
|
+
t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE])
|
|
44
|
+
t2 = Rake.application.intern(FileCreationTask, NEWFILE)
|
|
45
|
+
assert ! t2.needed?, "Should not need to build new file"
|
|
46
|
+
assert ! t1.needed?, "Should not need to rebuild old file because of new"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_no_retriggers_on_file_task
|
|
50
|
+
create_timed_files(OLDFILE, NEWFILE)
|
|
51
|
+
t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE])
|
|
52
|
+
t2 = Rake.application.intern(FileCreationTask, NEWFILE)
|
|
53
|
+
assert ! t2.needed?, "Should not need to build new file"
|
|
54
|
+
assert ! t1.needed?, "Should not need to rebuild old file because of new"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_very_early_timestamp
|
|
58
|
+
t1 = Rake.application.intern(FileCreationTask, OLDFILE)
|
|
59
|
+
assert t1.timestamp < Time.now
|
|
60
|
+
assert t1.timestamp < Time.now - 1000000
|
|
61
|
+
end
|
|
62
|
+
end
|