rake 0.8.0 → 0.8.7
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 +113 -2
- data/README +86 -132
- data/Rakefile +41 -13
- data/bin/rake +0 -0
- data/doc/command_line_usage.rdoc +102 -0
- data/doc/rakefile.rdoc +126 -3
- data/doc/release_notes/rake-0.7.3.rdoc +0 -0
- data/doc/release_notes/rake-0.8.0.rdoc +114 -0
- data/doc/release_notes/rake-0.8.2.rdoc +165 -0
- data/doc/release_notes/rake-0.8.3.rdoc +112 -0
- data/doc/release_notes/rake-0.8.4.rdoc +147 -0
- data/doc/release_notes/rake-0.8.5.rdoc +53 -0
- data/doc/release_notes/rake-0.8.6.rdoc +55 -0
- data/doc/release_notes/rake-0.8.7.rdoc +55 -0
- data/lib/rake/alt_system.rb +108 -0
- data/lib/rake/contrib/ftptools.rb +24 -10
- data/lib/rake/contrib/publisher.rb +1 -1
- data/lib/rake/contrib/sys.rb +5 -2
- data/lib/rake/gempackagetask.rb +0 -6
- data/lib/rake/loaders/makefile.rb +17 -15
- data/lib/rake/rdoctask.rb +83 -21
- data/lib/rake/ruby182_test_unit_fix.rb +0 -0
- data/lib/rake/tasklib.rb +8 -3
- data/lib/rake/testtask.rb +1 -1
- data/lib/rake/win32.rb +55 -0
- data/lib/rake.rb +490 -225
- data/test/check_expansion.rb +5 -0
- data/test/check_no_expansion.rb +5 -0
- data/test/data/file_creation_task/Rakefile +4 -1
- data/test/data/sample.mf +6 -1
- data/test/filecreation.rb +0 -2
- data/test/functional.rb +1 -1
- data/test/in_environment.rb +30 -0
- data/test/rake_test_setup.rb +21 -2
- data/test/session_functional.rb +109 -33
- data/test/shellcommand.rb +0 -0
- data/test/test_application.rb +269 -96
- data/test/test_definitions.rb +4 -1
- data/test/test_earlytime.rb +2 -2
- data/test/test_file_task.rb +20 -16
- data/test/test_filelist.rb +48 -7
- data/test/test_fileutils.rb +59 -38
- data/test/test_ftp.rb +5 -1
- data/test/test_invocation_chain.rb +8 -2
- data/test/test_makefile_loader.rb +5 -2
- data/test/test_namespace.rb +30 -11
- data/test/test_package_task.rb +3 -1
- data/test/test_pathmap.rb +3 -2
- data/test/test_pseudo_status.rb +26 -0
- data/test/test_rake.rb +9 -2
- data/test/test_rdoc_task.rb +88 -0
- data/test/test_require.rb +3 -1
- data/test/test_rules.rb +25 -7
- data/test/test_task_arguments.rb +14 -1
- data/test/test_task_manager.rb +27 -2
- data/test/test_tasklib.rb +12 -0
- data/test/test_tasks.rb +72 -54
- data/test/test_test_task.rb +2 -0
- data/test/test_top_level_functions.rb +4 -2
- data/test/test_win32.rb +72 -0
- metadata +99 -75
- /data/test/contrib/{testsys.rb → test_sys.rb} +0 -0
data/test/test_application.rb
CHANGED
|
@@ -10,12 +10,15 @@ require 'test/unit'
|
|
|
10
10
|
require 'rake'
|
|
11
11
|
require 'test/rake_test_setup'
|
|
12
12
|
require 'test/capture_stdout'
|
|
13
|
+
require 'test/in_environment'
|
|
13
14
|
|
|
14
15
|
TESTING_REQUIRE = [ ]
|
|
15
16
|
|
|
16
17
|
######################################################################
|
|
17
18
|
class TestApplication < Test::Unit::TestCase
|
|
18
19
|
include CaptureStdout
|
|
20
|
+
include InEnvironment
|
|
21
|
+
include TestMethods
|
|
19
22
|
|
|
20
23
|
def setup
|
|
21
24
|
@app = Rake::Application.new
|
|
@@ -39,12 +42,61 @@ class TestApplication < Test::Unit::TestCase
|
|
|
39
42
|
end
|
|
40
43
|
|
|
41
44
|
def test_display_tasks_with_long_comments
|
|
45
|
+
in_environment('RAKE_COLUMNS' => '80') do
|
|
46
|
+
@app.options.show_task_pattern = //
|
|
47
|
+
@app.last_description = "1234567890" * 8
|
|
48
|
+
@app.define_task(Rake::Task, "t")
|
|
49
|
+
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
|
50
|
+
assert_match(/^rake t/, out)
|
|
51
|
+
assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_display_tasks_with_task_name_wider_than_tty_display
|
|
56
|
+
in_environment('RAKE_COLUMNS' => '80') do
|
|
57
|
+
@app.options.show_task_pattern = //
|
|
58
|
+
description = "something short"
|
|
59
|
+
task_name = "task name" * 80
|
|
60
|
+
@app.last_description = "something short"
|
|
61
|
+
@app.define_task(Rake::Task, task_name )
|
|
62
|
+
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
|
63
|
+
# Ensure the entire task name is output and we end up showing no description
|
|
64
|
+
assert_match(/rake #{task_name} # .../, out)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment
|
|
69
|
+
@app.options.show_task_pattern = //
|
|
70
|
+
@app.tty_output = false
|
|
71
|
+
description = "something short"
|
|
72
|
+
task_name = "task name" * 80
|
|
73
|
+
@app.last_description = "something short"
|
|
74
|
+
@app.define_task(Rake::Task, task_name )
|
|
75
|
+
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
|
76
|
+
# Ensure the entire task name is output and we end up showing no description
|
|
77
|
+
assert_match(/rake #{task_name} # #{description}/, out)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment
|
|
42
81
|
@app.options.show_task_pattern = //
|
|
43
|
-
@app.
|
|
82
|
+
@app.tty_output = false
|
|
83
|
+
@app.last_description = "1234567890" * 8
|
|
44
84
|
@app.define_task(Rake::Task, "t")
|
|
45
85
|
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
|
46
86
|
assert_match(/^rake t/, out)
|
|
47
|
-
assert_match(/#
|
|
87
|
+
assert_match(/# #{@app.last_description}/, out)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def test_display_tasks_with_long_comments_to_a_non_tty_with_columns_set_truncates_comments
|
|
91
|
+
in_environment("RAKE_COLUMNS" => '80') do
|
|
92
|
+
@app.options.show_task_pattern = //
|
|
93
|
+
@app.tty_output = false
|
|
94
|
+
@app.last_description = "1234567890" * 8
|
|
95
|
+
@app.define_task(Rake::Task, "t")
|
|
96
|
+
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
|
97
|
+
assert_match(/^rake t/, out)
|
|
98
|
+
assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
|
|
99
|
+
end
|
|
48
100
|
end
|
|
49
101
|
|
|
50
102
|
def test_display_tasks_with_full_descriptions
|
|
@@ -58,8 +110,7 @@ class TestApplication < Test::Unit::TestCase
|
|
|
58
110
|
end
|
|
59
111
|
|
|
60
112
|
def test_finding_rakefile
|
|
61
|
-
|
|
62
|
-
assert_equal "rakefile", @app.rakefile.downcase
|
|
113
|
+
assert_match(/Rakefile/i, @app.instance_eval { have_rakefile })
|
|
63
114
|
end
|
|
64
115
|
|
|
65
116
|
def test_not_finding_rakefile
|
|
@@ -69,52 +120,59 @@ class TestApplication < Test::Unit::TestCase
|
|
|
69
120
|
end
|
|
70
121
|
|
|
71
122
|
def test_load_rakefile
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
123
|
+
in_environment("PWD" => "test/data/unittest") do
|
|
124
|
+
@app.instance_eval do
|
|
125
|
+
handle_options
|
|
126
|
+
options.silent = true
|
|
127
|
+
load_rakefile
|
|
128
|
+
end
|
|
129
|
+
assert_equal "rakefile", @app.rakefile.downcase
|
|
130
|
+
assert_match(%r(unittest$), Dir.pwd)
|
|
78
131
|
end
|
|
79
|
-
assert_equal "rakefile", @app.rakefile.downcase
|
|
80
|
-
assert_match(%r(unittest$), Dir.pwd)
|
|
81
|
-
ensure
|
|
82
|
-
Dir.chdir(original_dir)
|
|
83
132
|
end
|
|
84
133
|
|
|
85
134
|
def test_load_rakefile_from_subdir
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
135
|
+
in_environment("PWD" => "test/data/unittest/subdir") do
|
|
136
|
+
@app.instance_eval do
|
|
137
|
+
handle_options
|
|
138
|
+
options.silent = true
|
|
139
|
+
load_rakefile
|
|
140
|
+
end
|
|
141
|
+
assert_equal "rakefile", @app.rakefile.downcase
|
|
142
|
+
assert_match(%r(unittest$), Dir.pwd)
|
|
92
143
|
end
|
|
93
|
-
assert_equal "rakefile", @app.rakefile.downcase
|
|
94
|
-
assert_match(%r(unittest$), Dir.pwd)
|
|
95
|
-
ensure
|
|
96
|
-
Dir.chdir(original_dir)
|
|
97
144
|
end
|
|
98
145
|
|
|
99
146
|
def test_load_rakefile_not_found
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
147
|
+
in_environment("PWD" => "/", "RAKE_SYSTEM" => 'not_exist') do
|
|
148
|
+
@app.instance_eval do
|
|
149
|
+
handle_options
|
|
150
|
+
options.silent = true
|
|
151
|
+
end
|
|
152
|
+
ex = assert_exception(RuntimeError) do
|
|
153
|
+
@app.instance_eval do raw_load_rakefile end
|
|
154
|
+
end
|
|
155
|
+
assert_match(/no rakefile found/i, ex.message)
|
|
105
156
|
end
|
|
106
|
-
|
|
107
|
-
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def test_load_from_system_rakefile
|
|
160
|
+
in_environment('RAKE_SYSTEM' => 'test/data/sys') do
|
|
161
|
+
@app.options.rakelib = []
|
|
162
|
+
@app.instance_eval do
|
|
163
|
+
handle_options
|
|
164
|
+
options.silent = true
|
|
165
|
+
options.load_system = true
|
|
166
|
+
options.rakelib = []
|
|
167
|
+
load_rakefile
|
|
168
|
+
end
|
|
169
|
+
assert_equal "test/data/sys", @app.system_dir
|
|
170
|
+
assert_nil @app.rakefile
|
|
108
171
|
end
|
|
109
|
-
assert_match(/no rakefile found/i, ex.message)
|
|
110
|
-
ensure
|
|
111
|
-
Dir.chdir(original_dir)
|
|
112
172
|
end
|
|
113
173
|
|
|
114
|
-
def
|
|
115
|
-
@app.
|
|
116
|
-
assert(@app.instance_eval do have_rakefile end)
|
|
117
|
-
assert_equal '', @app.rakefile
|
|
174
|
+
def test_windows
|
|
175
|
+
assert ! (@app.windows? && @app.unix?)
|
|
118
176
|
end
|
|
119
177
|
|
|
120
178
|
def test_loading_imports
|
|
@@ -139,6 +197,19 @@ class TestApplication < Test::Unit::TestCase
|
|
|
139
197
|
end
|
|
140
198
|
end
|
|
141
199
|
|
|
200
|
+
def test_handle_options_should_strip_options_from_ARGV
|
|
201
|
+
assert !@app.options.trace
|
|
202
|
+
|
|
203
|
+
valid_option = '--trace'
|
|
204
|
+
ARGV.clear
|
|
205
|
+
ARGV << valid_option
|
|
206
|
+
|
|
207
|
+
@app.handle_options
|
|
208
|
+
|
|
209
|
+
assert !ARGV.include?(valid_option)
|
|
210
|
+
assert @app.options.trace
|
|
211
|
+
end
|
|
212
|
+
|
|
142
213
|
def test_good_run
|
|
143
214
|
ran = false
|
|
144
215
|
ARGV.clear
|
|
@@ -147,7 +218,9 @@ class TestApplication < Test::Unit::TestCase
|
|
|
147
218
|
@app.instance_eval do
|
|
148
219
|
intern(Rake::Task, "default").enhance { ran = true }
|
|
149
220
|
end
|
|
150
|
-
|
|
221
|
+
in_environment("PWD" => "test/data/default") do
|
|
222
|
+
@app.run
|
|
223
|
+
end
|
|
151
224
|
assert ran
|
|
152
225
|
end
|
|
153
226
|
|
|
@@ -185,7 +258,7 @@ class TestApplication < Test::Unit::TestCase
|
|
|
185
258
|
@app.intern(Rake::Task, "default").enhance { fail }
|
|
186
259
|
ARGV.clear
|
|
187
260
|
ARGV << '-f' << '-s' << '--rakelib=""'
|
|
188
|
-
|
|
261
|
+
assert_exception(SystemExit) {
|
|
189
262
|
err = capture_stderr { @app.run }
|
|
190
263
|
assert_match(/see full trace/, err)
|
|
191
264
|
}
|
|
@@ -197,7 +270,7 @@ class TestApplication < Test::Unit::TestCase
|
|
|
197
270
|
@app.intern(Rake::Task, "default").enhance { fail }
|
|
198
271
|
ARGV.clear
|
|
199
272
|
ARGV << '-f' << '-s' << '-t'
|
|
200
|
-
|
|
273
|
+
assert_exception(SystemExit) {
|
|
201
274
|
err = capture_stderr { capture_stdout { @app.run } }
|
|
202
275
|
assert_no_match(/see full trace/, err)
|
|
203
276
|
}
|
|
@@ -209,24 +282,25 @@ class TestApplication < Test::Unit::TestCase
|
|
|
209
282
|
@app.intern(Rake::Task, "default").enhance { fail }
|
|
210
283
|
ARGV.clear
|
|
211
284
|
ARGV << '-f' << '-s' << '--xyzzy'
|
|
212
|
-
|
|
285
|
+
assert_exception(SystemExit) {
|
|
213
286
|
err = capture_stderr { capture_stdout { @app.run } }
|
|
214
287
|
}
|
|
215
288
|
ensure
|
|
216
289
|
ARGV.clear
|
|
217
290
|
end
|
|
218
|
-
|
|
219
291
|
end
|
|
220
292
|
|
|
221
293
|
|
|
222
294
|
######################################################################
|
|
223
295
|
class TestApplicationOptions < Test::Unit::TestCase
|
|
224
296
|
include CaptureStdout
|
|
297
|
+
include TestMethods
|
|
225
298
|
|
|
226
299
|
def setup
|
|
227
300
|
clear_argv
|
|
228
301
|
RakeFileUtils.verbose_flag = false
|
|
229
302
|
RakeFileUtils.nowrite_flag = false
|
|
303
|
+
TESTING_REQUIRE.clear
|
|
230
304
|
end
|
|
231
305
|
|
|
232
306
|
def teardown
|
|
@@ -243,36 +317,23 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
|
243
317
|
|
|
244
318
|
def test_default_options
|
|
245
319
|
opts = command_line
|
|
246
|
-
assert_nil opts.
|
|
320
|
+
assert_nil opts.classic_namespace
|
|
247
321
|
assert_nil opts.dryrun
|
|
248
|
-
assert_nil opts.
|
|
322
|
+
assert_nil opts.full_description
|
|
323
|
+
assert_nil opts.ignore_system
|
|
324
|
+
assert_nil opts.load_system
|
|
249
325
|
assert_nil opts.nosearch
|
|
250
|
-
|
|
326
|
+
assert_equal ['rakelib'], opts.rakelib
|
|
251
327
|
assert_nil opts.show_prereqs
|
|
328
|
+
assert_nil opts.show_task_pattern
|
|
252
329
|
assert_nil opts.show_tasks
|
|
253
|
-
assert_nil opts.
|
|
330
|
+
assert_nil opts.silent
|
|
331
|
+
assert_nil opts.trace
|
|
254
332
|
assert_equal ['rakelib'], opts.rakelib
|
|
255
333
|
assert ! RakeFileUtils.verbose_flag
|
|
256
334
|
assert ! RakeFileUtils.nowrite_flag
|
|
257
335
|
end
|
|
258
336
|
|
|
259
|
-
def test_bad_options
|
|
260
|
-
assert_raise GetoptLong::InvalidOption do
|
|
261
|
-
capture_stderr do
|
|
262
|
-
flags('--bad', '-t') do |opts|
|
|
263
|
-
end
|
|
264
|
-
end
|
|
265
|
-
end
|
|
266
|
-
end
|
|
267
|
-
|
|
268
|
-
def test_trace_option
|
|
269
|
-
flags('--trace', '-t') do |opts|
|
|
270
|
-
assert opts.trace
|
|
271
|
-
assert RakeFileUtils.verbose_flag
|
|
272
|
-
assert ! RakeFileUtils.nowrite_flag
|
|
273
|
-
end
|
|
274
|
-
end
|
|
275
|
-
|
|
276
337
|
def test_dry_run
|
|
277
338
|
flags('--dry-run', '-n') do |opts|
|
|
278
339
|
assert opts.dryrun
|
|
@@ -282,16 +343,6 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
|
282
343
|
end
|
|
283
344
|
end
|
|
284
345
|
|
|
285
|
-
def test_help
|
|
286
|
-
flags('--help', '-H', '-h') do |opts|
|
|
287
|
-
assert_match(/\Arake/, @out)
|
|
288
|
-
assert_match(/\boptions\b/, @out)
|
|
289
|
-
assert_match(/\btargets\b/, @out)
|
|
290
|
-
assert_equal :exit, @exit
|
|
291
|
-
assert_equal :exit, @exit
|
|
292
|
-
end
|
|
293
|
-
end
|
|
294
|
-
|
|
295
346
|
def test_describe
|
|
296
347
|
flags('--describe') do |opts|
|
|
297
348
|
assert opts.full_description
|
|
@@ -300,40 +351,60 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
|
300
351
|
end
|
|
301
352
|
end
|
|
302
353
|
|
|
303
|
-
def
|
|
304
|
-
flags(
|
|
305
|
-
|
|
354
|
+
def test_describe_with_pattern
|
|
355
|
+
flags('--describe=X') do |opts|
|
|
356
|
+
assert opts.full_description
|
|
357
|
+
assert opts.show_tasks
|
|
358
|
+
assert_equal(/X/.to_s, opts.show_task_pattern.to_s)
|
|
306
359
|
end
|
|
307
|
-
ensure
|
|
308
|
-
$:.delete('xx')
|
|
309
360
|
end
|
|
310
361
|
|
|
311
|
-
def
|
|
312
|
-
|
|
313
|
-
|
|
362
|
+
def test_execute
|
|
363
|
+
$xyzzy = 0
|
|
364
|
+
flags('--execute=$xyzzy=1', '-e $xyzzy=1') do |opts|
|
|
365
|
+
assert_equal 1, $xyzzy
|
|
366
|
+
assert_equal :exit, @exit
|
|
367
|
+
$xyzzy = 0
|
|
314
368
|
end
|
|
315
369
|
end
|
|
316
370
|
|
|
317
|
-
def
|
|
318
|
-
|
|
319
|
-
|
|
371
|
+
def test_execute_and_continue
|
|
372
|
+
$xyzzy = 0
|
|
373
|
+
flags('--execute-continue=$xyzzy=1', '-E $xyzzy=1') do |opts|
|
|
374
|
+
assert_equal 1, $xyzzy
|
|
375
|
+
assert_not_equal :exit, @exit
|
|
376
|
+
$xyzzy = 0
|
|
320
377
|
end
|
|
321
378
|
end
|
|
322
379
|
|
|
323
|
-
def
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
380
|
+
def test_execute_and_print
|
|
381
|
+
$xyzzy = 0
|
|
382
|
+
flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do |opts|
|
|
383
|
+
assert_equal 'pugh', $xyzzy
|
|
384
|
+
assert_equal :exit, @exit
|
|
385
|
+
assert_match(/^pugh$/, @out)
|
|
386
|
+
$xyzzy = 0
|
|
327
387
|
end
|
|
328
388
|
end
|
|
329
389
|
|
|
330
|
-
def
|
|
331
|
-
flags('--
|
|
332
|
-
|
|
333
|
-
|
|
390
|
+
def test_help
|
|
391
|
+
flags('--help', '-H', '-h') do |opts|
|
|
392
|
+
assert_match(/\Arake/, @out)
|
|
393
|
+
assert_match(/\boptions\b/, @out)
|
|
394
|
+
assert_match(/\btargets\b/, @out)
|
|
395
|
+
assert_equal :exit, @exit
|
|
396
|
+
assert_equal :exit, @exit
|
|
334
397
|
end
|
|
335
398
|
end
|
|
336
399
|
|
|
400
|
+
def test_libdir
|
|
401
|
+
flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts|
|
|
402
|
+
$:.include?('xx')
|
|
403
|
+
end
|
|
404
|
+
ensure
|
|
405
|
+
$:.delete('xx')
|
|
406
|
+
end
|
|
407
|
+
|
|
337
408
|
def test_rakefile
|
|
338
409
|
flags(['--rakefile', 'RF'], ['--rakefile=RF'], ['-f', 'RF'], ['-fRF']) do |opts|
|
|
339
410
|
assert_equal ['RF'], @app.instance_eval { @rakefiles }
|
|
@@ -356,7 +427,7 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
|
356
427
|
end
|
|
357
428
|
|
|
358
429
|
def test_missing_require
|
|
359
|
-
ex =
|
|
430
|
+
ex = assert_exception(LoadError) do
|
|
360
431
|
flags(['--require', 'test/missing']) do |opts|
|
|
361
432
|
end
|
|
362
433
|
end
|
|
@@ -364,6 +435,58 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
|
364
435
|
assert_match(/test\/missing/, ex.message)
|
|
365
436
|
end
|
|
366
437
|
|
|
438
|
+
def test_prereqs
|
|
439
|
+
flags('--prereqs', '-P') do |opts|
|
|
440
|
+
assert opts.show_prereqs
|
|
441
|
+
end
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
def test_quiet
|
|
445
|
+
flags('--quiet', '-q') do |opts|
|
|
446
|
+
assert ! RakeFileUtils.verbose_flag
|
|
447
|
+
assert ! opts.silent
|
|
448
|
+
end
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
def test_no_search
|
|
452
|
+
flags('--nosearch', '--no-search', '-N') do |opts|
|
|
453
|
+
assert opts.nosearch
|
|
454
|
+
end
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
def test_silent
|
|
458
|
+
flags('--silent', '-s') do |opts|
|
|
459
|
+
assert ! RakeFileUtils.verbose_flag
|
|
460
|
+
assert opts.silent
|
|
461
|
+
end
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
def test_system
|
|
465
|
+
flags('--system', '-g') do |opts|
|
|
466
|
+
assert opts.load_system
|
|
467
|
+
end
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
def test_no_system
|
|
471
|
+
flags('--no-system', '-G') do |opts|
|
|
472
|
+
assert opts.ignore_system
|
|
473
|
+
end
|
|
474
|
+
end
|
|
475
|
+
|
|
476
|
+
def test_trace
|
|
477
|
+
flags('--trace', '-t') do |opts|
|
|
478
|
+
assert opts.trace
|
|
479
|
+
assert RakeFileUtils.verbose_flag
|
|
480
|
+
assert ! RakeFileUtils.nowrite_flag
|
|
481
|
+
end
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
def test_trace_rules
|
|
485
|
+
flags('--rules') do |opts|
|
|
486
|
+
assert opts.trace_rules
|
|
487
|
+
end
|
|
488
|
+
end
|
|
489
|
+
|
|
367
490
|
def test_tasks
|
|
368
491
|
flags('--tasks', '-T') do |opts|
|
|
369
492
|
assert opts.show_tasks
|
|
@@ -403,13 +526,13 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
|
403
526
|
|
|
404
527
|
def test_bad_option
|
|
405
528
|
capture_stderr do
|
|
406
|
-
ex =
|
|
529
|
+
ex = assert_exception(OptionParser::InvalidOption) do
|
|
407
530
|
flags('--bad-option')
|
|
408
531
|
end
|
|
409
532
|
if ex.message =~ /^While/ # Ruby 1.9 error message
|
|
410
533
|
assert_match(/while parsing/i, ex.message)
|
|
411
534
|
else # Ruby 1.8 error message
|
|
412
|
-
assert_match(/unrecognized option/i, ex.message)
|
|
535
|
+
assert_match(/(invalid|unrecognized) option/i, ex.message)
|
|
413
536
|
assert_match(/--bad-option/, ex.message)
|
|
414
537
|
end
|
|
415
538
|
end
|
|
@@ -436,6 +559,7 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
|
436
559
|
|
|
437
560
|
def flags(*sets)
|
|
438
561
|
sets.each do |set|
|
|
562
|
+
ARGV.clear
|
|
439
563
|
@out = capture_stdout {
|
|
440
564
|
@exit = catch(:system_exit) { opts = command_line(*set) }
|
|
441
565
|
}
|
|
@@ -500,3 +624,52 @@ class TestTaskArgumentParsing < Test::Unit::TestCase
|
|
|
500
624
|
end
|
|
501
625
|
|
|
502
626
|
end
|
|
627
|
+
|
|
628
|
+
class TestTaskArgumentParsing < Test::Unit::TestCase
|
|
629
|
+
include InEnvironment
|
|
630
|
+
|
|
631
|
+
def test_terminal_width_using_env
|
|
632
|
+
app = Rake::Application.new
|
|
633
|
+
in_environment('RAKE_COLUMNS' => '1234') do
|
|
634
|
+
assert_equal 1234, app.terminal_width
|
|
635
|
+
end
|
|
636
|
+
end
|
|
637
|
+
|
|
638
|
+
def test_terminal_width_using_stty
|
|
639
|
+
app = Rake::Application.new
|
|
640
|
+
flexmock(app,
|
|
641
|
+
:unix? => true,
|
|
642
|
+
:dynamic_width_stty => 1235,
|
|
643
|
+
:dynamic_width_tput => 0)
|
|
644
|
+
in_environment('RAKE_COLUMNS' => nil) do
|
|
645
|
+
assert_equal 1235, app.terminal_width
|
|
646
|
+
end
|
|
647
|
+
end
|
|
648
|
+
|
|
649
|
+
def test_terminal_width_using_tput
|
|
650
|
+
app = Rake::Application.new
|
|
651
|
+
flexmock(app,
|
|
652
|
+
:unix? => true,
|
|
653
|
+
:dynamic_width_stty => 0,
|
|
654
|
+
:dynamic_width_tput => 1236)
|
|
655
|
+
in_environment('RAKE_COLUMNS' => nil) do
|
|
656
|
+
assert_equal 1236, app.terminal_width
|
|
657
|
+
end
|
|
658
|
+
end
|
|
659
|
+
|
|
660
|
+
def test_terminal_width_using_hardcoded_80
|
|
661
|
+
app = Rake::Application.new
|
|
662
|
+
flexmock(app, :unix? => false)
|
|
663
|
+
in_environment('RAKE_COLUMNS' => nil) do
|
|
664
|
+
assert_equal 80, app.terminal_width
|
|
665
|
+
end
|
|
666
|
+
end
|
|
667
|
+
|
|
668
|
+
def test_terminal_width_with_failure
|
|
669
|
+
app = Rake::Application.new
|
|
670
|
+
flexmock(app).should_receive(:unix?).and_throw(RuntimeError)
|
|
671
|
+
in_environment('RAKE_COLUMNS' => nil) do
|
|
672
|
+
assert_equal 80, app.terminal_width
|
|
673
|
+
end
|
|
674
|
+
end
|
|
675
|
+
end
|
data/test/test_definitions.rb
CHANGED
|
@@ -4,10 +4,13 @@ require 'test/unit'
|
|
|
4
4
|
require 'fileutils'
|
|
5
5
|
require 'rake'
|
|
6
6
|
require 'test/filecreation'
|
|
7
|
+
require 'test/rake_test_setup'
|
|
7
8
|
|
|
8
9
|
######################################################################
|
|
9
10
|
class TestDefinitions < Test::Unit::TestCase
|
|
10
11
|
include Rake
|
|
12
|
+
include TestMethods
|
|
13
|
+
|
|
11
14
|
EXISTINGFILE = "testdata/existing"
|
|
12
15
|
|
|
13
16
|
def setup
|
|
@@ -58,7 +61,7 @@ class TestDefinitions < Test::Unit::TestCase
|
|
|
58
61
|
|
|
59
62
|
def test_missing_dependencies
|
|
60
63
|
task :x => ["testdata/missing"]
|
|
61
|
-
|
|
64
|
+
assert_exception(RuntimeError) { Task[:x].invoke }
|
|
62
65
|
end
|
|
63
66
|
|
|
64
67
|
def test_implicit_file_dependencies
|
data/test/test_earlytime.rb
CHANGED
|
@@ -6,7 +6,7 @@ require 'rake'
|
|
|
6
6
|
class TestEarlyTime < Test::Unit::TestCase
|
|
7
7
|
def test_create
|
|
8
8
|
early = Rake::EarlyTime.instance
|
|
9
|
-
time = Time.mktime(
|
|
9
|
+
time = Time.mktime(1970, 1, 1, 0, 0, 0)
|
|
10
10
|
assert early <= Time.now
|
|
11
11
|
assert early < Time.now
|
|
12
12
|
assert early != Time.now
|
|
@@ -21,7 +21,7 @@ class TestEarlyTime < Test::Unit::TestCase
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def test_original_time_compare_is_not_messed_up
|
|
24
|
-
t1 = Time.mktime(
|
|
24
|
+
t1 = Time.mktime(1970, 1, 1, 0, 0, 0)
|
|
25
25
|
t2 = Time.now
|
|
26
26
|
assert t1 < t2
|
|
27
27
|
assert t2 > t1
|
data/test/test_file_task.rb
CHANGED
|
@@ -4,11 +4,13 @@ require 'test/unit'
|
|
|
4
4
|
require 'fileutils'
|
|
5
5
|
require 'rake'
|
|
6
6
|
require 'test/filecreation'
|
|
7
|
+
require 'test/rake_test_setup'
|
|
7
8
|
|
|
8
9
|
######################################################################
|
|
9
10
|
class TestFileTask < Test::Unit::TestCase
|
|
10
11
|
include Rake
|
|
11
12
|
include FileCreation
|
|
13
|
+
include TestMethods
|
|
12
14
|
|
|
13
15
|
def setup
|
|
14
16
|
Task.clear
|
|
@@ -118,22 +120,24 @@ class TestDirectoryTask < Test::Unit::TestCase
|
|
|
118
120
|
assert ! File.exist?("testdata/a/b/c")
|
|
119
121
|
end
|
|
120
122
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
123
|
+
if Rake::Win32.windows?
|
|
124
|
+
def test_directory_win32
|
|
125
|
+
desc "WIN32 DESC"
|
|
126
|
+
FileUtils.mkdir_p("testdata")
|
|
127
|
+
Dir.chdir("testdata") do
|
|
128
|
+
directory 'c:/testdata/a/b/c'
|
|
129
|
+
assert_equal FileCreationTask, Task['c:/testdata'].class
|
|
130
|
+
assert_equal FileCreationTask, Task['c:/testdata/a'].class
|
|
131
|
+
assert_equal FileCreationTask, Task['c:/testdata/a/b/c'].class
|
|
132
|
+
assert_nil Task['c:/testdata'].comment
|
|
133
|
+
assert_equal "WIN32 DESC", Task['c:/testdata/a/b/c'].comment
|
|
134
|
+
assert_nil Task['c:/testdata/a/b'].comment
|
|
135
|
+
verbose(false) {
|
|
136
|
+
Task['c:/testdata/a/b'].invoke
|
|
137
|
+
}
|
|
138
|
+
assert File.exist?('c:/testdata/a/b')
|
|
139
|
+
assert ! File.exist?('c:/testdata/a/b/c')
|
|
140
|
+
end
|
|
137
141
|
end
|
|
138
142
|
end
|
|
139
143
|
end
|