drake 0.8.7.0.2.4 → 0.9.0.0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/CHANGES +77 -9
- data/{CHANGES.drake → CHANGES-drake} +6 -2
- data/MIT-LICENSE +2 -0
- data/{README → README.rdoc} +30 -18
- data/Rakefile +144 -130
- data/Rakefile-drake +67 -0
- data/TODO +1 -1
- data/bin/drake +2 -0
- data/doc/command_line_usage.rdoc +25 -11
- data/doc/glossary.rdoc +2 -2
- data/doc/jamis.rb +2 -2
- data/doc/parallel.rdoc +37 -29
- data/doc/proto_rake.rdoc +22 -22
- data/doc/rake.1.gz +0 -0
- data/doc/rakefile.rdoc +56 -33
- data/doc/rational.rdoc +6 -6
- data/doc/release_notes/rake-0.4.15.rdoc +1 -1
- data/doc/release_notes/rake-0.5.0.rdoc +1 -1
- data/doc/release_notes/rake-0.7.0.rdoc +1 -1
- data/doc/release_notes/rake-0.7.2.rdoc +3 -3
- data/doc/release_notes/rake-0.7.3.rdoc +2 -2
- data/doc/release_notes/rake-0.8.0.rdoc +1 -1
- data/doc/release_notes/rake-0.8.2.rdoc +3 -3
- data/doc/release_notes/rake-0.8.3.rdoc +2 -2
- data/doc/release_notes/rake-0.8.4.rdoc +1 -1
- data/doc/release_notes/rake-0.8.5.rdoc +1 -1
- data/doc/release_notes/rake-0.8.6.rdoc +1 -1
- data/doc/release_notes/rake-0.8.7.rdoc +1 -1
- data/doc/release_notes/rake-0.9.0.rdoc +112 -0
- data/install.rb +14 -12
- data/lib/rake.rb +31 -2527
- data/lib/rake/alt_system.rb +7 -6
- data/lib/rake/application.rb +626 -0
- data/lib/rake/classic_namespace.rb +1 -0
- data/lib/rake/clean.rb +2 -4
- data/lib/rake/cloneable.rb +25 -0
- data/lib/rake/contrib/compositepublisher.rb +2 -5
- data/lib/rake/contrib/ftptools.rb +5 -8
- data/lib/rake/contrib/publisher.rb +2 -8
- data/lib/rake/contrib/rubyforgepublisher.rb +2 -4
- data/lib/rake/contrib/sshpublisher.rb +4 -6
- data/lib/rake/contrib/sys.rb +7 -25
- data/lib/rake/default_loader.rb +10 -0
- data/lib/rake/dsl.rb +2 -0
- data/lib/rake/dsl_definition.rb +143 -0
- data/lib/rake/early_time.rb +18 -0
- data/lib/rake/ext/core.rb +27 -0
- data/lib/rake/ext/module.rb +39 -0
- data/lib/rake/ext/string.rb +167 -0
- data/lib/rake/ext/time.rb +14 -0
- data/lib/rake/file_creation_task.rb +24 -0
- data/lib/rake/file_list.rb +403 -0
- data/lib/rake/file_task.rb +47 -0
- data/lib/rake/file_utils.rb +112 -0
- data/lib/rake/file_utils_ext.rb +142 -0
- data/lib/rake/gempackagetask.rb +6 -90
- data/lib/rake/invocation_chain.rb +51 -0
- data/lib/rake/invocation_exception_mixin.rb +16 -0
- data/lib/rake/loaders/makefile.rb +13 -15
- data/lib/rake/multi_task.rb +16 -0
- data/lib/rake/name_space.rb +25 -0
- data/lib/rake/packagetask.rb +13 -12
- data/lib/rake/parallel.rb +17 -28
- data/lib/rake/pathmap.rb +1 -0
- data/lib/rake/pseudo_status.rb +24 -0
- data/lib/rake/rake_module.rb +29 -0
- data/lib/rake/rake_test_loader.rb +10 -2
- data/lib/rake/rdoctask.rb +211 -190
- data/lib/rake/ruby182_test_unit_fix.rb +9 -7
- data/lib/rake/rule_recursion_overflow_error.rb +20 -0
- data/lib/rake/runtest.rb +4 -6
- data/lib/rake/task.rb +351 -0
- data/lib/rake/task_argument_error.rb +7 -0
- data/lib/rake/task_arguments.rb +74 -0
- data/lib/rake/task_manager.rb +307 -0
- data/lib/rake/tasklib.rb +1 -2
- data/lib/rake/testtask.rb +57 -27
- data/lib/rake/version.rb +13 -0
- data/lib/rake/win32.rb +4 -4
- data/test/contrib/test_sys.rb +8 -31
- data/test/data/access/Rakefile +33 -0
- data/test/data/comments/Rakefile +18 -0
- data/test/data/default/Rakefile +1 -1
- data/test/data/deprecated_import/Rakefile +1 -0
- data/test/data/dryrun/Rakefile +1 -1
- data/test/data/file_creation_task/Rakefile +1 -1
- data/test/data/namespace/Rakefile +9 -0
- data/test/data/rakelib/test1.rb +1 -0
- data/test/data/verbose/Rakefile +34 -0
- data/test/{filecreation.rb → file_creation.rb} +11 -7
- data/test/functional/functional_test.rb +25 -0
- data/test/{session_functional.rb → functional/session_based_tests.rb} +141 -23
- data/test/in_environment.rb +7 -5
- data/test/{test_application.rb → lib/application_test.rb} +331 -143
- data/test/{test_clean.rb → lib/clean_test.rb} +1 -0
- data/test/{test_definitions.rb → lib/definitions_test.rb} +4 -4
- data/test/lib/dsl_test.rb +52 -0
- data/test/{test_earlytime.rb → lib/earlytime_test.rb} +1 -2
- data/test/{test_extension.rb → lib/extension_test.rb} +2 -2
- data/test/{test_file_creation_task.rb → lib/file_creation_task_test.rb} +1 -1
- data/test/{test_file_task.rb → lib/file_task_test.rb} +9 -5
- data/test/{test_filelist.rb → lib/filelist_test.rb} +38 -24
- data/test/{test_fileutils.rb → lib/fileutils_test.rb} +27 -22
- data/test/{test_ftp.rb → lib/ftp_test.rb} +0 -0
- data/test/{test_invocation_chain.rb → lib/invocation_chain_test.rb} +0 -0
- data/test/{test_makefile_loader.rb → lib/makefile_loader_test.rb} +0 -0
- data/test/{test_multitask.rb → lib/multitask_test.rb} +3 -2
- data/test/{test_namespace.rb → lib/namespace_test.rb} +0 -0
- data/test/lib/package_task_test.rb +82 -0
- data/test/{test_parallel.rb → lib/parallel_test.rb} +5 -5
- data/test/{test_pathmap.rb → lib/pathmap_test.rb} +3 -2
- data/test/{test_pseudo_status.rb → lib/pseudo_status_test.rb} +0 -0
- data/test/{test_rake.rb → lib/rake_test.rb} +1 -1
- data/test/{test_rdoc_task.rb → lib/rdoc_task_test.rb} +19 -23
- data/test/{test_require.rb → lib/require_test.rb} +8 -2
- data/test/{test_rules.rb → lib/rules_test.rb} +4 -5
- data/test/{test_task_arguments.rb → lib/task_arguments_test.rb} +5 -5
- data/test/{test_task_manager.rb → lib/task_manager_test.rb} +15 -5
- data/test/{test_tasks.rb → lib/task_test.rb} +91 -28
- data/test/{test_tasklib.rb → lib/tasklib_test.rb} +0 -0
- data/test/{test_test_task.rb → lib/test_task_test.rb} +3 -3
- data/test/lib/testtask_test.rb +49 -0
- data/test/{test_top_level_functions.rb → lib/top_level_functions_test.rb} +5 -3
- data/test/{test_win32.rb → lib/win32_test.rb} +19 -0
- data/test/rake_test_setup.rb +6 -10
- data/test/ruby_version_test.rb +3 -0
- data/test/test_helper.rb +19 -0
- metadata +108 -66
- data/Rakefile.drake +0 -73
- data/test/functional.rb +0 -15
- data/test/test_package_task.rb +0 -118
data/test/in_environment.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
module InEnvironment
|
2
2
|
private
|
3
|
-
|
3
|
+
|
4
4
|
# Create an environment for a test. At the completion of the yielded
|
5
5
|
# block, the environment is restored to its original conditions.
|
6
|
-
def in_environment(settings)
|
7
|
-
|
8
|
-
|
6
|
+
def in_environment(settings=nil)
|
7
|
+
settings ||= {}
|
8
|
+
full_settings = {"RAKEOPT" => nil}.merge(settings)
|
9
|
+
original_settings = set_env(full_settings)
|
10
|
+
yield
|
9
11
|
ensure
|
10
|
-
set_env(original_settings)
|
12
|
+
set_env(original_settings) rescue nil
|
11
13
|
end
|
12
14
|
|
13
15
|
# Set the environment according to the settings hash.
|
@@ -21,19 +21,27 @@ class TestApplication < Test::Unit::TestCase
|
|
21
21
|
include TestMethods
|
22
22
|
|
23
23
|
def setup
|
24
|
+
super
|
24
25
|
@app = Rake::Application.new
|
25
26
|
@app.options.threads = Rake.application.options.threads
|
26
27
|
@app.options.rakelib = []
|
28
|
+
Rake::TaskManager.record_task_metadata = true
|
29
|
+
end
|
30
|
+
|
31
|
+
def teardown
|
32
|
+
Rake::TaskManager.record_task_metadata = false
|
33
|
+
super
|
27
34
|
end
|
28
35
|
|
29
36
|
def test_constant_warning
|
30
|
-
|
31
|
-
assert_match(/warning/i,
|
32
|
-
assert_match(/deprecated/i,
|
33
|
-
assert_match(/Task/i,
|
37
|
+
error_messages = capture_stderr do @app.instance_eval { const_warning("Task") } end
|
38
|
+
assert_match(/warning/i, error_messages)
|
39
|
+
assert_match(/deprecated/i, error_messages)
|
40
|
+
assert_match(/Task/i, error_messages)
|
34
41
|
end
|
35
42
|
|
36
43
|
def test_display_tasks
|
44
|
+
@app.options.show_tasks = :tasks
|
37
45
|
@app.options.show_task_pattern = //
|
38
46
|
@app.last_description = "COMMENT"
|
39
47
|
@app.define_task(Rake::Task, "t")
|
@@ -44,6 +52,7 @@ class TestApplication < Test::Unit::TestCase
|
|
44
52
|
|
45
53
|
def test_display_tasks_with_long_comments
|
46
54
|
in_environment('RAKE_COLUMNS' => '80') do
|
55
|
+
@app.options.show_tasks = :tasks
|
47
56
|
@app.options.show_task_pattern = //
|
48
57
|
@app.last_description = "1234567890" * 8
|
49
58
|
@app.define_task(Rake::Task, "t")
|
@@ -55,8 +64,8 @@ class TestApplication < Test::Unit::TestCase
|
|
55
64
|
|
56
65
|
def test_display_tasks_with_task_name_wider_than_tty_display
|
57
66
|
in_environment('RAKE_COLUMNS' => '80') do
|
67
|
+
@app.options.show_tasks = :tasks
|
58
68
|
@app.options.show_task_pattern = //
|
59
|
-
description = "something short"
|
60
69
|
task_name = "task name" * 80
|
61
70
|
@app.last_description = "something short"
|
62
71
|
@app.define_task(Rake::Task, task_name )
|
@@ -67,6 +76,7 @@ class TestApplication < Test::Unit::TestCase
|
|
67
76
|
end
|
68
77
|
|
69
78
|
def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment
|
79
|
+
@app.options.show_tasks = :tasks
|
70
80
|
@app.options.show_task_pattern = //
|
71
81
|
@app.tty_output = false
|
72
82
|
description = "something short"
|
@@ -79,6 +89,7 @@ class TestApplication < Test::Unit::TestCase
|
|
79
89
|
end
|
80
90
|
|
81
91
|
def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment
|
92
|
+
@app.options.show_tasks = :tasks
|
82
93
|
@app.options.show_task_pattern = //
|
83
94
|
@app.tty_output = false
|
84
95
|
@app.last_description = "1234567890" * 8
|
@@ -90,6 +101,7 @@ class TestApplication < Test::Unit::TestCase
|
|
90
101
|
|
91
102
|
def test_display_tasks_with_long_comments_to_a_non_tty_with_columns_set_truncates_comments
|
92
103
|
in_environment("RAKE_COLUMNS" => '80') do
|
104
|
+
@app.options.show_tasks = :tasks
|
93
105
|
@app.options.show_task_pattern = //
|
94
106
|
@app.tty_output = false
|
95
107
|
@app.last_description = "1234567890" * 8
|
@@ -100,9 +112,9 @@ class TestApplication < Test::Unit::TestCase
|
|
100
112
|
end
|
101
113
|
end
|
102
114
|
|
103
|
-
def
|
115
|
+
def test_describe_tasks
|
116
|
+
@app.options.show_tasks = :describe
|
104
117
|
@app.options.show_task_pattern = //
|
105
|
-
@app.options.full_description = true
|
106
118
|
@app.last_description = "COMMENT"
|
107
119
|
@app.define_task(Rake::Task, "t")
|
108
120
|
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
@@ -110,6 +122,16 @@ class TestApplication < Test::Unit::TestCase
|
|
110
122
|
assert_match(/^ {4}COMMENT$/, out)
|
111
123
|
end
|
112
124
|
|
125
|
+
def test_show_lines
|
126
|
+
@app.options.show_tasks = :lines
|
127
|
+
@app.options.show_task_pattern = //
|
128
|
+
@app.last_description = "COMMENT"
|
129
|
+
@app.define_task(Rake::Task, "t")
|
130
|
+
@app['t'].locations << "HERE:1"
|
131
|
+
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
132
|
+
assert_match(/^rake t +[^:]+:\d+ *$/, out)
|
133
|
+
end
|
134
|
+
|
113
135
|
def test_finding_rakefile
|
114
136
|
assert_match(/Rakefile/i, @app.instance_eval { have_rakefile })
|
115
137
|
end
|
@@ -122,7 +144,7 @@ class TestApplication < Test::Unit::TestCase
|
|
122
144
|
|
123
145
|
def test_load_rakefile
|
124
146
|
in_environment("PWD" => "test/data/unittest") do
|
125
|
-
@app.instance_eval do
|
147
|
+
@app.instance_eval do
|
126
148
|
handle_options
|
127
149
|
options.silent = true
|
128
150
|
load_rakefile
|
@@ -132,6 +154,19 @@ class TestApplication < Test::Unit::TestCase
|
|
132
154
|
end
|
133
155
|
end
|
134
156
|
|
157
|
+
def test_load_rakefile_doesnt_print_rakefile_directory_from_same_dir
|
158
|
+
in_environment("PWD" => "test/data/unittest") do
|
159
|
+
error_messages = capture_stderr do
|
160
|
+
@app.instance_eval do
|
161
|
+
@original_dir = File.expand_path(".") # pretend we started from the unittest dir
|
162
|
+
raw_load_rakefile
|
163
|
+
end
|
164
|
+
end
|
165
|
+
_, location = @app.find_rakefile_location
|
166
|
+
assert_no_match(/\(in #{location}\)/, error_messages)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
135
170
|
def test_load_rakefile_from_subdir
|
136
171
|
in_environment("PWD" => "test/data/unittest/subdir") do
|
137
172
|
@app.instance_eval do
|
@@ -144,14 +179,40 @@ class TestApplication < Test::Unit::TestCase
|
|
144
179
|
end
|
145
180
|
end
|
146
181
|
|
182
|
+
def test_load_rakefile_prints_rakefile_directory_from_subdir
|
183
|
+
in_environment("PWD" => "test/data/unittest/subdir") do
|
184
|
+
error_messages = capture_stderr do
|
185
|
+
@app.instance_eval do
|
186
|
+
raw_load_rakefile
|
187
|
+
end
|
188
|
+
end
|
189
|
+
_, location = @app.find_rakefile_location
|
190
|
+
assert_match(/\(in #{location}\)/, error_messages)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent
|
195
|
+
in_environment("PWD" => "test/data/unittest/subdir") do
|
196
|
+
error_messages = capture_stderr do
|
197
|
+
@app.instance_eval do
|
198
|
+
handle_options
|
199
|
+
options.silent = true
|
200
|
+
raw_load_rakefile
|
201
|
+
end
|
202
|
+
end
|
203
|
+
_, location = @app.find_rakefile_location
|
204
|
+
assert_no_match(/\(in #{location}\)/, error_messages)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
147
208
|
def test_load_rakefile_not_found
|
148
209
|
in_environment("PWD" => "/", "RAKE_SYSTEM" => 'not_exist') do
|
149
210
|
@app.instance_eval do
|
150
211
|
handle_options
|
151
212
|
options.silent = true
|
152
213
|
end
|
153
|
-
ex = assert_exception(RuntimeError) do
|
154
|
-
@app.instance_eval do raw_load_rakefile end
|
214
|
+
ex = assert_exception(RuntimeError) do
|
215
|
+
@app.instance_eval do raw_load_rakefile end
|
155
216
|
end
|
156
217
|
assert_match(/no rakefile found/i, ex.message)
|
157
218
|
end
|
@@ -172,6 +233,21 @@ class TestApplication < Test::Unit::TestCase
|
|
172
233
|
end
|
173
234
|
end
|
174
235
|
|
236
|
+
def test_load_from_calculated_system_rakefile
|
237
|
+
flexmock(@app, :standard_system_dir => "__STD_SYS_DIR__")
|
238
|
+
in_environment('RAKE_SYSTEM' => nil) do
|
239
|
+
@app.options.rakelib = []
|
240
|
+
@app.instance_eval do
|
241
|
+
handle_options
|
242
|
+
options.silent = true
|
243
|
+
options.load_system = true
|
244
|
+
options.rakelib = []
|
245
|
+
load_rakefile
|
246
|
+
end
|
247
|
+
assert_equal "__STD_SYS_DIR__", @app.system_dir
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
175
251
|
def test_windows
|
176
252
|
assert ! (@app.windows? && @app.unix?)
|
177
253
|
end
|
@@ -260,8 +336,8 @@ class TestApplication < Test::Unit::TestCase
|
|
260
336
|
ARGV.clear
|
261
337
|
ARGV << '-f' << '-s' << '--rakelib=""'
|
262
338
|
assert_exception(SystemExit) {
|
263
|
-
|
264
|
-
assert_match(/see full trace/,
|
339
|
+
error_messages = capture_stderr { @app.run }
|
340
|
+
assert_match(/see full trace/, error_messages)
|
265
341
|
}
|
266
342
|
ensure
|
267
343
|
ARGV.clear
|
@@ -272,8 +348,8 @@ class TestApplication < Test::Unit::TestCase
|
|
272
348
|
ARGV.clear
|
273
349
|
ARGV << '-f' << '-s' << '-t'
|
274
350
|
assert_exception(SystemExit) {
|
275
|
-
|
276
|
-
assert_no_match(/see full trace/,
|
351
|
+
error_messages = capture_stderr { capture_stdout { @app.run } }
|
352
|
+
assert_no_match(/see full trace/, error_messages)
|
277
353
|
}
|
278
354
|
ensure
|
279
355
|
ARGV.clear
|
@@ -284,11 +360,22 @@ class TestApplication < Test::Unit::TestCase
|
|
284
360
|
ARGV.clear
|
285
361
|
ARGV << '-f' << '-s' << '--xyzzy'
|
286
362
|
assert_exception(SystemExit) {
|
287
|
-
|
363
|
+
capture_stderr { capture_stdout { @app.run } }
|
288
364
|
}
|
289
365
|
ensure
|
290
366
|
ARGV.clear
|
291
367
|
end
|
368
|
+
|
369
|
+
def test_deprecation_message
|
370
|
+
in_environment do
|
371
|
+
error_messages = capture_stderr do
|
372
|
+
@app.deprecate("a", "b", "c")
|
373
|
+
end
|
374
|
+
assert_match(/'a' is deprecated/i, error_messages)
|
375
|
+
assert_match(/use 'b' instead/i, error_messages)
|
376
|
+
assert_match(/at c$/i, error_messages)
|
377
|
+
end
|
378
|
+
end
|
292
379
|
end
|
293
380
|
|
294
381
|
|
@@ -296,20 +383,21 @@ end
|
|
296
383
|
class TestApplicationOptions < Test::Unit::TestCase
|
297
384
|
include CaptureStdout
|
298
385
|
include TestMethods
|
386
|
+
include InEnvironment
|
299
387
|
|
300
388
|
def setup
|
301
389
|
clear_argv
|
302
|
-
|
303
|
-
|
390
|
+
Rake::FileUtilsExt.verbose_flag = false
|
391
|
+
Rake::FileUtilsExt.nowrite_flag = false
|
304
392
|
TESTING_REQUIRE.clear
|
305
393
|
end
|
306
394
|
|
307
395
|
def teardown
|
308
396
|
clear_argv
|
309
|
-
|
310
|
-
|
397
|
+
Rake::FileUtilsExt.verbose_flag = false
|
398
|
+
Rake::FileUtilsExt.nowrite_flag = false
|
311
399
|
end
|
312
|
-
|
400
|
+
|
313
401
|
def clear_argv
|
314
402
|
while ! ARGV.empty?
|
315
403
|
ARGV.pop
|
@@ -317,225 +405,299 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
317
405
|
end
|
318
406
|
|
319
407
|
def test_default_options
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
408
|
+
in_environment("RAKEOPT" => nil) do
|
409
|
+
opts = command_line
|
410
|
+
assert_nil opts.classic_namespace
|
411
|
+
assert_nil opts.dryrun
|
412
|
+
assert_nil opts.ignore_system
|
413
|
+
assert_nil opts.load_system
|
414
|
+
assert_nil opts.nosearch
|
415
|
+
assert_equal ['rakelib'], opts.rakelib
|
416
|
+
assert_nil opts.show_prereqs
|
417
|
+
assert_nil opts.show_task_pattern
|
418
|
+
assert_nil opts.show_tasks
|
419
|
+
assert_nil opts.silent
|
420
|
+
assert_nil opts.trace
|
421
|
+
assert_equal ['rakelib'], opts.rakelib
|
422
|
+
assert ! Rake::FileUtilsExt.verbose_flag
|
423
|
+
assert ! Rake::FileUtilsExt.nowrite_flag
|
424
|
+
end
|
336
425
|
end
|
337
426
|
|
338
427
|
def test_dry_run
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
428
|
+
in_environment do
|
429
|
+
flags('--dry-run', '-n') do |opts|
|
430
|
+
assert opts.dryrun
|
431
|
+
assert opts.trace
|
432
|
+
assert Rake::FileUtilsExt.verbose_flag
|
433
|
+
assert Rake::FileUtilsExt.nowrite_flag
|
434
|
+
end
|
344
435
|
end
|
345
436
|
end
|
346
437
|
|
347
438
|
def test_describe
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
439
|
+
in_environment do
|
440
|
+
flags('--describe') do |opts|
|
441
|
+
assert_equal :describe, opts.show_tasks
|
442
|
+
assert_equal(//.to_s, opts.show_task_pattern.to_s)
|
443
|
+
end
|
352
444
|
end
|
353
445
|
end
|
354
446
|
|
355
447
|
def test_describe_with_pattern
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
448
|
+
in_environment do
|
449
|
+
flags('--describe=X') do |opts|
|
450
|
+
assert_equal :describe, opts.show_tasks
|
451
|
+
assert_equal(/X/.to_s, opts.show_task_pattern.to_s)
|
452
|
+
end
|
360
453
|
end
|
361
454
|
end
|
362
455
|
|
363
456
|
def test_execute
|
364
|
-
|
365
|
-
flags('--execute=$xyzzy=1', '-e $xyzzy=1') do |opts|
|
366
|
-
assert_equal 1, $xyzzy
|
367
|
-
assert_equal :exit, @exit
|
457
|
+
in_environment do
|
368
458
|
$xyzzy = 0
|
459
|
+
flags('--execute=$xyzzy=1', '-e $xyzzy=1') do |opts|
|
460
|
+
assert_equal 1, $xyzzy
|
461
|
+
assert_equal :exit, @exit
|
462
|
+
$xyzzy = 0
|
463
|
+
end
|
369
464
|
end
|
370
465
|
end
|
371
466
|
|
372
467
|
def test_execute_and_continue
|
373
|
-
|
374
|
-
flags('--execute-continue=$xyzzy=1', '-E $xyzzy=1') do |opts|
|
375
|
-
assert_equal 1, $xyzzy
|
376
|
-
assert_not_equal :exit, @exit
|
468
|
+
in_environment do
|
377
469
|
$xyzzy = 0
|
470
|
+
flags('--execute-continue=$xyzzy=1', '-E $xyzzy=1') do |opts|
|
471
|
+
assert_equal 1, $xyzzy
|
472
|
+
assert_not_equal :exit, @exit
|
473
|
+
$xyzzy = 0
|
474
|
+
end
|
378
475
|
end
|
379
476
|
end
|
380
477
|
|
381
478
|
def test_execute_and_print
|
382
|
-
|
383
|
-
flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do |opts|
|
384
|
-
assert_equal 'pugh', $xyzzy
|
385
|
-
assert_equal :exit, @exit
|
386
|
-
assert_match(/^pugh$/, @out)
|
479
|
+
in_environment do
|
387
480
|
$xyzzy = 0
|
481
|
+
flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do |opts|
|
482
|
+
assert_equal 'pugh', $xyzzy
|
483
|
+
assert_equal :exit, @exit
|
484
|
+
assert_match(/^pugh$/, @out)
|
485
|
+
$xyzzy = 0
|
486
|
+
end
|
388
487
|
end
|
389
488
|
end
|
390
489
|
|
391
490
|
def test_help
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
491
|
+
in_environment do
|
492
|
+
flags('--help', '-H', '-h') do |opts|
|
493
|
+
assert_match(/\Adrake/, @out)
|
494
|
+
assert_match(/\boptions\b/, @out)
|
495
|
+
assert_match(/\btargets\b/, @out)
|
496
|
+
assert_equal :exit, @exit
|
497
|
+
assert_equal :exit, @exit
|
498
|
+
end
|
398
499
|
end
|
399
500
|
end
|
400
501
|
|
401
502
|
def test_libdir
|
402
|
-
|
403
|
-
|
503
|
+
in_environment do
|
504
|
+
flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts|
|
505
|
+
$:.include?('xx')
|
506
|
+
end
|
404
507
|
end
|
405
508
|
ensure
|
406
509
|
$:.delete('xx')
|
407
510
|
end
|
408
511
|
|
409
512
|
def test_rakefile
|
410
|
-
|
411
|
-
|
513
|
+
in_environment do
|
514
|
+
flags(['--rakefile', 'RF'], ['--rakefile=RF'], ['-f', 'RF'], ['-fRF']) do |opts|
|
515
|
+
assert_equal ['RF'], @app.instance_eval { @rakefiles }
|
516
|
+
end
|
412
517
|
end
|
413
518
|
end
|
414
519
|
|
415
520
|
def test_rakelib
|
416
|
-
|
417
|
-
|
521
|
+
in_environment do
|
522
|
+
flags(['--rakelibdir', 'A:B:C'], ['--rakelibdir=A:B:C'], ['-R', 'A:B:C'], ['-RA:B:C']) do |opts|
|
523
|
+
assert_equal ['A', 'B', 'C'], opts.rakelib
|
524
|
+
end
|
418
525
|
end
|
419
526
|
end
|
420
527
|
|
421
528
|
def test_require
|
422
|
-
|
529
|
+
in_environment do
|
530
|
+
flags(['--require', 'test/reqfile'], '-rtest/reqfile2', '-rtest/reqfile3') do |opts|
|
531
|
+
end
|
532
|
+
assert TESTING_REQUIRE.include?(1)
|
533
|
+
assert TESTING_REQUIRE.include?(2)
|
534
|
+
assert TESTING_REQUIRE.include?(3)
|
535
|
+
assert_equal 3, TESTING_REQUIRE.size
|
423
536
|
end
|
424
|
-
assert TESTING_REQUIRE.include?(1)
|
425
|
-
assert TESTING_REQUIRE.include?(2)
|
426
|
-
assert TESTING_REQUIRE.include?(3)
|
427
|
-
assert_equal 3, TESTING_REQUIRE.size
|
428
537
|
end
|
429
538
|
|
430
539
|
def test_missing_require
|
431
|
-
|
432
|
-
|
540
|
+
in_environment do
|
541
|
+
ex = assert_exception(LoadError) do
|
542
|
+
flags(['--require', 'test/missing']) do |opts|
|
543
|
+
end
|
433
544
|
end
|
545
|
+
assert_match(/such file/, ex.message)
|
546
|
+
assert_match(/test\/missing/, ex.message)
|
434
547
|
end
|
435
|
-
assert_match(/no such file/, ex.message)
|
436
|
-
assert_match(/test\/missing/, ex.message)
|
437
548
|
end
|
438
549
|
|
439
550
|
def test_prereqs
|
440
|
-
|
441
|
-
|
551
|
+
in_environment do
|
552
|
+
flags('--prereqs', '-P') do |opts|
|
553
|
+
assert opts.show_prereqs
|
554
|
+
end
|
442
555
|
end
|
443
556
|
end
|
444
557
|
|
445
558
|
def test_quiet
|
446
|
-
|
447
|
-
|
448
|
-
|
559
|
+
in_environment do
|
560
|
+
flags('--quiet', '-q') do |opts|
|
561
|
+
assert ! Rake::FileUtilsExt.verbose_flag
|
562
|
+
assert ! opts.silent
|
563
|
+
end
|
449
564
|
end
|
450
565
|
end
|
451
566
|
|
452
567
|
def test_no_search
|
453
|
-
|
454
|
-
|
568
|
+
in_environment do
|
569
|
+
flags('--nosearch', '--no-search', '-N') do |opts|
|
570
|
+
assert opts.nosearch
|
571
|
+
end
|
455
572
|
end
|
456
573
|
end
|
457
574
|
|
458
575
|
def test_silent
|
459
|
-
|
460
|
-
|
461
|
-
|
576
|
+
in_environment do
|
577
|
+
flags('--silent', '-s') do |opts|
|
578
|
+
assert ! Rake::FileUtilsExt.verbose_flag
|
579
|
+
assert opts.silent
|
580
|
+
end
|
462
581
|
end
|
463
582
|
end
|
464
583
|
|
465
584
|
def test_system
|
466
|
-
|
467
|
-
|
585
|
+
in_environment do
|
586
|
+
flags('--system', '-g') do |opts|
|
587
|
+
assert opts.load_system
|
588
|
+
end
|
468
589
|
end
|
469
590
|
end
|
470
591
|
|
471
592
|
def test_no_system
|
472
|
-
|
473
|
-
|
593
|
+
in_environment do
|
594
|
+
flags('--no-system', '-G') do |opts|
|
595
|
+
assert opts.ignore_system
|
596
|
+
end
|
474
597
|
end
|
475
598
|
end
|
476
599
|
|
477
600
|
def test_trace
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
601
|
+
in_environment do
|
602
|
+
flags('--trace', '-t') do |opts|
|
603
|
+
assert opts.trace
|
604
|
+
assert Rake::FileUtilsExt.verbose_flag
|
605
|
+
assert ! Rake::FileUtilsExt.nowrite_flag
|
606
|
+
end
|
482
607
|
end
|
483
608
|
end
|
484
609
|
|
485
610
|
def test_trace_rules
|
486
|
-
|
487
|
-
|
611
|
+
in_environment do
|
612
|
+
flags('--rules') do |opts|
|
613
|
+
assert opts.trace_rules
|
614
|
+
end
|
488
615
|
end
|
489
616
|
end
|
490
617
|
|
491
618
|
def test_tasks
|
492
|
-
|
493
|
-
|
494
|
-
|
619
|
+
in_environment do
|
620
|
+
flags('--tasks', '-T') do |opts|
|
621
|
+
assert_equal :tasks, opts.show_tasks
|
622
|
+
assert_equal(//.to_s, opts.show_task_pattern.to_s)
|
623
|
+
end
|
624
|
+
flags(['--tasks', 'xyz'], ['-Txyz']) do |opts|
|
625
|
+
assert_equal :tasks, opts.show_tasks
|
626
|
+
assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
|
627
|
+
end
|
495
628
|
end
|
496
|
-
|
497
|
-
|
498
|
-
|
629
|
+
end
|
630
|
+
|
631
|
+
def test_where
|
632
|
+
in_environment do
|
633
|
+
flags('--where', '-W') do |opts|
|
634
|
+
assert_equal :lines, opts.show_tasks
|
635
|
+
assert_equal(//.to_s, opts.show_task_pattern.to_s)
|
636
|
+
end
|
637
|
+
flags(['--where', 'xyz'], ['-Wxyz']) do |opts|
|
638
|
+
assert_equal :lines, opts.show_tasks
|
639
|
+
assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
|
640
|
+
end
|
641
|
+
end
|
642
|
+
end
|
643
|
+
|
644
|
+
def test_no_deprecated_messages
|
645
|
+
in_environment do
|
646
|
+
flags('--no-deprecation-warnings', '-X') do |opts|
|
647
|
+
assert opts.ignore_deprecate
|
648
|
+
end
|
499
649
|
end
|
500
650
|
end
|
501
651
|
|
502
652
|
def test_verbose
|
503
|
-
|
504
|
-
|
505
|
-
|
653
|
+
in_environment do
|
654
|
+
flags('--verbose', '-V') do |opts|
|
655
|
+
assert Rake::FileUtilsExt.verbose_flag
|
656
|
+
assert ! opts.silent
|
657
|
+
end
|
506
658
|
end
|
507
659
|
end
|
508
660
|
|
509
661
|
def test_version
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
662
|
+
in_environment do
|
663
|
+
flags('--version', '-V') do |opts|
|
664
|
+
assert_match(/\bversion\b/, @out)
|
665
|
+
assert_match(/\b#{RAKEVERSION}\b/, @out)
|
666
|
+
assert_equal :exit, @exit
|
667
|
+
end
|
514
668
|
end
|
515
669
|
end
|
516
|
-
|
670
|
+
|
517
671
|
def test_classic_namespace
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
672
|
+
in_environment do
|
673
|
+
error_messages = capture_stderr do
|
674
|
+
flags(['--classic-namespace'], ['-C', '-T', '-P', '-n', '-s', '-t']) do |opts|
|
675
|
+
assert opts.classic_namespace
|
676
|
+
assert_equal opts.show_tasks, $show_tasks
|
677
|
+
assert_equal opts.show_prereqs, $show_prereqs
|
678
|
+
assert_equal opts.trace, $trace
|
679
|
+
assert_equal opts.dryrun, $dryrun
|
680
|
+
assert_equal opts.silent, $silent
|
681
|
+
end
|
682
|
+
end
|
683
|
+
assert_match(/deprecated/, error_messages)
|
525
684
|
end
|
526
685
|
end
|
527
686
|
|
528
687
|
def test_bad_option
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
688
|
+
in_environment do
|
689
|
+
error_messages = capture_stderr do
|
690
|
+
ex = assert_exception(OptionParser::InvalidOption) do
|
691
|
+
flags('--bad-option')
|
692
|
+
end
|
693
|
+
if ex.message =~ /^While/ # Ruby 1.9 error message
|
694
|
+
assert_match(/while parsing/i, ex.message)
|
695
|
+
else # Ruby 1.8 error message
|
696
|
+
assert_match(/(invalid|unrecognized) option/i, ex.message)
|
697
|
+
assert_match(/--bad-option/, ex.message)
|
698
|
+
end
|
538
699
|
end
|
700
|
+
assert_equal '', error_messages
|
539
701
|
end
|
540
702
|
end
|
541
703
|
|
@@ -543,12 +705,12 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
543
705
|
command_line("a", "b")
|
544
706
|
assert_equal ["a", "b"], @tasks.sort
|
545
707
|
end
|
546
|
-
|
708
|
+
|
547
709
|
def test_default_task_collection
|
548
710
|
command_line()
|
549
711
|
assert_equal ["default"], @tasks
|
550
712
|
end
|
551
|
-
|
713
|
+
|
552
714
|
def test_environment_definition
|
553
715
|
ENV.delete('TESTKEY')
|
554
716
|
command_line("a", "TESTKEY=12")
|
@@ -556,13 +718,13 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
556
718
|
assert '12', ENV['TESTKEY']
|
557
719
|
end
|
558
720
|
|
559
|
-
private
|
721
|
+
private
|
560
722
|
|
561
723
|
def flags(*sets)
|
562
724
|
sets.each do |set|
|
563
725
|
ARGV.clear
|
564
|
-
@out = capture_stdout {
|
565
|
-
@exit = catch(:system_exit) {
|
726
|
+
@out = capture_stdout {
|
727
|
+
@exit = catch(:system_exit) { command_line(*set) }
|
566
728
|
}
|
567
729
|
yield(@app.options) if block_given?
|
568
730
|
end
|
@@ -589,31 +751,31 @@ class TestTaskArgumentParsing < Test::Unit::TestCase
|
|
589
751
|
@app = Rake::Application.new
|
590
752
|
@app.options.threads = Rake.application.options.threads
|
591
753
|
end
|
592
|
-
|
754
|
+
|
593
755
|
def test_name_only
|
594
756
|
name, args = @app.parse_task_string("name")
|
595
757
|
assert_equal "name", name
|
596
758
|
assert_equal [], args
|
597
759
|
end
|
598
|
-
|
760
|
+
|
599
761
|
def test_empty_args
|
600
762
|
name, args = @app.parse_task_string("name[]")
|
601
763
|
assert_equal "name", name
|
602
764
|
assert_equal [], args
|
603
765
|
end
|
604
|
-
|
766
|
+
|
605
767
|
def test_one_argument
|
606
768
|
name, args = @app.parse_task_string("name[one]")
|
607
769
|
assert_equal "name", name
|
608
770
|
assert_equal ["one"], args
|
609
771
|
end
|
610
|
-
|
772
|
+
|
611
773
|
def test_two_arguments
|
612
774
|
name, args = @app.parse_task_string("name[one,two]")
|
613
775
|
assert_equal "name", name
|
614
776
|
assert_equal ["one", "two"], args
|
615
777
|
end
|
616
|
-
|
778
|
+
|
617
779
|
def test_can_handle_spaces_between_args
|
618
780
|
name, args = @app.parse_task_string("name[one, two,\tthree , \tfour]")
|
619
781
|
assert_equal "name", name
|
@@ -680,4 +842,30 @@ class TestTaskArgumentParsing < Test::Unit::TestCase
|
|
680
842
|
assert_equal 80, app.terminal_width
|
681
843
|
end
|
682
844
|
end
|
845
|
+
|
846
|
+
def test_no_rakeopt
|
847
|
+
in_environment do
|
848
|
+
ARGV << '--trace'
|
849
|
+
app = Rake::Application.new
|
850
|
+
app.init
|
851
|
+
assert !app.options.silent
|
852
|
+
end
|
853
|
+
end
|
854
|
+
|
855
|
+
def test_rakeopt_with_blank_options
|
856
|
+
in_environment("RAKEOPT" => "") do
|
857
|
+
ARGV << '--trace'
|
858
|
+
app = Rake::Application.new
|
859
|
+
app.init
|
860
|
+
assert !app.options.silent
|
861
|
+
end
|
862
|
+
end
|
863
|
+
|
864
|
+
def test_rakeopt_with_silent_options
|
865
|
+
in_environment("RAKEOPT" => "-s") do
|
866
|
+
app = Rake::Application.new
|
867
|
+
app.init
|
868
|
+
assert app.options.silent
|
869
|
+
end
|
870
|
+
end
|
683
871
|
end
|