rake 10.0.0.beta.2 → 13.0.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/macos.yml +22 -0
- data/.github/workflows/ubuntu-rvm.yml +28 -0
- data/.github/workflows/ubuntu.yml +20 -0
- data/.github/workflows/windows.yml +20 -0
- data/CONTRIBUTING.rdoc +43 -0
- data/Gemfile +10 -0
- data/History.rdoc +2359 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +57 -101
- data/Rakefile +22 -354
- data/bin/bundle +105 -0
- data/bin/console +7 -0
- data/bin/rake +19 -27
- data/bin/rdoc +29 -0
- data/bin/rubocop +29 -0
- data/bin/setup +6 -0
- data/doc/command_line_usage.rdoc +30 -18
- 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/exe/rake +27 -0
- data/lib/rake.rb +35 -34
- data/lib/rake/application.rb +355 -188
- data/lib/rake/backtrace.rb +14 -7
- data/lib/rake/clean.rb +54 -8
- data/lib/rake/cloneable.rb +5 -4
- data/lib/rake/cpu_counter.rb +107 -0
- data/lib/rake/default_loader.rb +5 -0
- data/lib/rake/dsl_definition.rb +58 -19
- 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 +10 -22
- 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 +2 -1
- data/lib/rake/name_space.rb +36 -23
- data/lib/rake/packagetask.rb +71 -34
- data/lib/rake/phony.rb +6 -3
- 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 +34 -11
- data/lib/rake/rake_test_loader.rb +18 -13
- data/lib/rake/rule_recursion_overflow_error.rb +2 -2
- data/lib/rake/scope.rb +43 -0
- data/lib/rake/task.rb +166 -82
- data/lib/rake/task_argument_error.rb +1 -0
- data/lib/rake/task_arguments.rb +45 -14
- data/lib/rake/task_manager.rb +82 -50
- data/lib/rake/tasklib.rb +2 -12
- data/lib/rake/testtask.rb +68 -39
- data/lib/rake/thread_history_display.rb +10 -6
- data/lib/rake/thread_pool.rb +60 -86
- data/lib/rake/trace_output.rb +23 -0
- data/lib/rake/version.rb +6 -8
- data/lib/rake/win32.rb +14 -18
- data/rake.gemspec +36 -0
- metadata +64 -166
- data/.gemtest +0 -0
- data/CHANGES +0 -526
- data/TODO +0 -21
- 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.2.rdoc +0 -55
- data/doc/release_notes/rake-0.9.2.rdoc +0 -49
- data/doc/release_notes/rake-0.9.3.rdoc +0 -102
- data/doc/release_notes/rake-10.0.0.rdoc +0 -178
- data/install.rb +0 -90
- data/lib/rake/alt_system.rb +0 -109
- data/lib/rake/contrib/compositepublisher.rb +0 -21
- data/lib/rake/contrib/ftptools.rb +0 -151
- 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/ext/module.rb +0 -0
- data/lib/rake/ext/time.rb +0 -14
- data/lib/rake/pathmap.rb +0 -1
- 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 -522
- data/test/test_rake.rb +0 -40
- data/test/test_rake_application.rb +0 -484
- data/test/test_rake_application_options.rb +0 -427
- data/test/test_rake_backtrace.rb +0 -67
- data/test/test_rake_clean.rb +0 -14
- data/test/test_rake_definitions.rb +0 -80
- data/test/test_rake_directory_task.rb +0 -57
- data/test/test_rake_dsl.rb +0 -40
- 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 -122
- 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 -472
- 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 -59
- 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_reduce_compat.rb +0 -30
- data/test/test_rake_require.rb +0 -40
- data/test/test_rake_rules.rb +0 -327
- data/test/test_rake_task.rb +0 -316
- 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 -19
- data/test/test_rake_task_with_arguments.rb +0 -162
- data/test/test_rake_test_task.rb +0 -120
- data/test/test_rake_thread_pool.rb +0 -146
- data/test/test_rake_top_level_functions.rb +0 -71
- data/test/test_rake_win32.rb +0 -72
- data/test/test_thread_history_display.rb +0 -91
data/test/test_rake.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
|
3
|
-
class TestRake < Rake::TestCase
|
4
|
-
def test_each_dir_parent
|
5
|
-
assert_equal ['a'], alldirs('a')
|
6
|
-
assert_equal ['a/b', 'a'], alldirs('a/b')
|
7
|
-
assert_equal ['/a/b', '/a', '/'], alldirs('/a/b')
|
8
|
-
if File.dirname("c:/foo") == "c:"
|
9
|
-
# Under Unix
|
10
|
-
assert_equal ['c:/a/b', 'c:/a', 'c:'], alldirs('c:/a/b')
|
11
|
-
assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b')
|
12
|
-
else
|
13
|
-
# Under Windows
|
14
|
-
assert_equal ['c:/a/b', 'c:/a', 'c:/'], alldirs('c:/a/b')
|
15
|
-
assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def alldirs(fn)
|
20
|
-
result = []
|
21
|
-
Rake.each_dir_parent(fn) { |d| result << d }
|
22
|
-
result
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_can_override_application
|
26
|
-
old_app = Rake.application
|
27
|
-
fake_app = Object.new
|
28
|
-
Rake.application = fake_app
|
29
|
-
|
30
|
-
assert_equal fake_app, Rake.application
|
31
|
-
|
32
|
-
ensure
|
33
|
-
Rake.application = old_app
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_original_dir_reports_current_dir
|
37
|
-
assert_equal @tempdir, Rake.original_dir
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
@@ -1,484 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
|
3
|
-
class TestRakeApplication < Rake::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
super
|
7
|
-
|
8
|
-
@app = Rake.application
|
9
|
-
@app.options.rakelib = []
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_display_tasks
|
13
|
-
@app.options.show_tasks = :tasks
|
14
|
-
@app.options.show_task_pattern = //
|
15
|
-
@app.last_description = "COMMENT"
|
16
|
-
@app.define_task(Rake::Task, "t")
|
17
|
-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
18
|
-
assert_match(/^rake t/, out)
|
19
|
-
assert_match(/# COMMENT/, out)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_display_tasks_with_long_comments
|
23
|
-
@app.terminal_columns = 80
|
24
|
-
@app.options.show_tasks = :tasks
|
25
|
-
@app.options.show_task_pattern = //
|
26
|
-
@app.last_description = "1234567890" * 8
|
27
|
-
@app.define_task(Rake::Task, "t")
|
28
|
-
|
29
|
-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
30
|
-
|
31
|
-
assert_match(/^rake t/, out)
|
32
|
-
assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_display_tasks_with_task_name_wider_than_tty_display
|
36
|
-
@app.terminal_columns = 80
|
37
|
-
@app.options.show_tasks = :tasks
|
38
|
-
@app.options.show_task_pattern = //
|
39
|
-
task_name = "task name" * 80
|
40
|
-
@app.last_description = "something short"
|
41
|
-
@app.define_task(Rake::Task, task_name )
|
42
|
-
|
43
|
-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
44
|
-
|
45
|
-
# Ensure the entire task name is output and we end up showing no description
|
46
|
-
assert_match(/rake #{task_name} # .../, out)
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment
|
50
|
-
@app.options.show_tasks = :tasks
|
51
|
-
@app.options.show_task_pattern = //
|
52
|
-
@app.tty_output = false
|
53
|
-
description = "something short"
|
54
|
-
task_name = "task name" * 80
|
55
|
-
@app.last_description = "something short"
|
56
|
-
@app.define_task(Rake::Task, task_name )
|
57
|
-
|
58
|
-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
59
|
-
|
60
|
-
# Ensure the entire task name is output and we end up showing no description
|
61
|
-
assert_match(/rake #{task_name} # #{description}/, out)
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment
|
65
|
-
@app.options.show_tasks = :tasks
|
66
|
-
@app.options.show_task_pattern = //
|
67
|
-
@app.tty_output = false
|
68
|
-
@app.last_description = "1234567890" * 8
|
69
|
-
@app.define_task(Rake::Task, "t")
|
70
|
-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
71
|
-
assert_match(/^rake t/, out)
|
72
|
-
assert_match(/# #{@app.last_description}/, out)
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_display_tasks_with_long_comments_to_a_non_tty_with_columns_set_truncates_comments
|
76
|
-
@app.terminal_columns = 80
|
77
|
-
@app.options.show_tasks = :tasks
|
78
|
-
@app.options.show_task_pattern = //
|
79
|
-
@app.tty_output = false
|
80
|
-
@app.last_description = "1234567890" * 8
|
81
|
-
@app.define_task(Rake::Task, "t")
|
82
|
-
|
83
|
-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
84
|
-
|
85
|
-
assert_match(/^rake t/, out)
|
86
|
-
assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_describe_tasks
|
90
|
-
@app.options.show_tasks = :describe
|
91
|
-
@app.options.show_task_pattern = //
|
92
|
-
@app.last_description = "COMMENT"
|
93
|
-
@app.define_task(Rake::Task, "t")
|
94
|
-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
95
|
-
assert_match(/^rake t$/, out)
|
96
|
-
assert_match(/^ {4}COMMENT$/, out)
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_show_lines
|
100
|
-
@app.options.show_tasks = :lines
|
101
|
-
@app.options.show_task_pattern = //
|
102
|
-
@app.last_description = "COMMENT"
|
103
|
-
@app.define_task(Rake::Task, "t")
|
104
|
-
@app['t'].locations << "HERE:1"
|
105
|
-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
106
|
-
assert_match(/^rake t +[^:]+:\d+ *$/, out)
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_finding_rakefile
|
110
|
-
rakefile_default
|
111
|
-
|
112
|
-
assert_match(/Rakefile/i, @app.instance_eval { have_rakefile })
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_not_finding_rakefile
|
116
|
-
@app.instance_eval { @rakefiles = ['NEVER_FOUND'] }
|
117
|
-
assert( ! @app.instance_eval do have_rakefile end )
|
118
|
-
assert_nil @app.rakefile
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_load_rakefile
|
122
|
-
rakefile_unittest
|
123
|
-
|
124
|
-
@app.instance_eval do
|
125
|
-
handle_options
|
126
|
-
options.silent = true
|
127
|
-
load_rakefile
|
128
|
-
end
|
129
|
-
|
130
|
-
assert_equal "rakefile", @app.rakefile.downcase
|
131
|
-
assert_equal @tempdir, Dir.pwd
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_load_rakefile_doesnt_print_rakefile_directory_from_same_dir
|
135
|
-
rakefile_unittest
|
136
|
-
|
137
|
-
_, err = capture_io do
|
138
|
-
@app.instance_eval do
|
139
|
-
# pretend we started from the unittest dir
|
140
|
-
@original_dir = File.expand_path(".")
|
141
|
-
raw_load_rakefile
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
assert_empty err
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_load_rakefile_from_subdir
|
149
|
-
rakefile_unittest
|
150
|
-
Dir.chdir 'subdir'
|
151
|
-
|
152
|
-
@app.instance_eval do
|
153
|
-
handle_options
|
154
|
-
options.silent = true
|
155
|
-
load_rakefile
|
156
|
-
end
|
157
|
-
|
158
|
-
assert_equal "rakefile", @app.rakefile.downcase
|
159
|
-
assert_equal @tempdir, Dir.pwd
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_load_rakefile_prints_rakefile_directory_from_subdir
|
163
|
-
rakefile_unittest
|
164
|
-
Dir.chdir 'subdir'
|
165
|
-
|
166
|
-
app = Rake::Application.new
|
167
|
-
app.options.rakelib = []
|
168
|
-
|
169
|
-
_, err = capture_io do
|
170
|
-
app.instance_eval do
|
171
|
-
raw_load_rakefile
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
assert_equal "(in #{@tempdir}\)\n", err
|
176
|
-
end
|
177
|
-
|
178
|
-
def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent
|
179
|
-
rakefile_unittest
|
180
|
-
Dir.chdir 'subdir'
|
181
|
-
|
182
|
-
_, err = capture_io do
|
183
|
-
@app.instance_eval do
|
184
|
-
handle_options
|
185
|
-
options.silent = true
|
186
|
-
raw_load_rakefile
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
assert_empty err
|
191
|
-
end
|
192
|
-
|
193
|
-
def test_load_rakefile_not_found
|
194
|
-
Dir.chdir @tempdir
|
195
|
-
ENV['RAKE_SYSTEM'] = 'not_exist'
|
196
|
-
|
197
|
-
@app.instance_eval do
|
198
|
-
handle_options
|
199
|
-
options.silent = true
|
200
|
-
end
|
201
|
-
|
202
|
-
ex = assert_raises(RuntimeError) do
|
203
|
-
@app.instance_eval do raw_load_rakefile end
|
204
|
-
end
|
205
|
-
|
206
|
-
assert_match(/no rakefile found/i, ex.message)
|
207
|
-
end
|
208
|
-
|
209
|
-
def test_load_from_system_rakefile
|
210
|
-
rake_system_dir
|
211
|
-
|
212
|
-
@app.instance_eval do
|
213
|
-
handle_options
|
214
|
-
options.silent = true
|
215
|
-
options.load_system = true
|
216
|
-
options.rakelib = []
|
217
|
-
load_rakefile
|
218
|
-
end
|
219
|
-
|
220
|
-
assert_equal @system_dir, @app.system_dir
|
221
|
-
assert_nil @app.rakefile
|
222
|
-
rescue SystemExit
|
223
|
-
flunk 'failed to load rakefile'
|
224
|
-
end
|
225
|
-
|
226
|
-
def test_load_from_calculated_system_rakefile
|
227
|
-
rakefile_default
|
228
|
-
def @app.standard_system_dir
|
229
|
-
"__STD_SYS_DIR__"
|
230
|
-
end
|
231
|
-
|
232
|
-
ENV['RAKE_SYSTEM'] = nil
|
233
|
-
|
234
|
-
@app.instance_eval do
|
235
|
-
handle_options
|
236
|
-
options.silent = true
|
237
|
-
options.load_system = true
|
238
|
-
options.rakelib = []
|
239
|
-
load_rakefile
|
240
|
-
end
|
241
|
-
|
242
|
-
assert_equal "__STD_SYS_DIR__", @app.system_dir
|
243
|
-
rescue SystemExit
|
244
|
-
flunk 'failed to find system rakefile'
|
245
|
-
end
|
246
|
-
|
247
|
-
def test_terminal_columns
|
248
|
-
old_RAKE_COLUMNS = ENV['RAKE_COLUMNS']
|
249
|
-
|
250
|
-
ENV['RAKE_COLUMNS'] = '42'
|
251
|
-
|
252
|
-
app = Rake::Application.new
|
253
|
-
|
254
|
-
assert_equal 42, app.terminal_columns
|
255
|
-
ensure
|
256
|
-
if old_RAKE_COLUMNS then
|
257
|
-
ENV['RAKE_COLUMNS'].delete
|
258
|
-
else
|
259
|
-
ENV['RAKE_COLUMNS'] = old_RAKE_COLUMNS
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
def test_windows
|
264
|
-
assert ! (@app.windows? && @app.unix?)
|
265
|
-
end
|
266
|
-
|
267
|
-
def test_loading_imports
|
268
|
-
loader = util_loader
|
269
|
-
|
270
|
-
@app.instance_eval do
|
271
|
-
add_loader("dummy", loader)
|
272
|
-
add_import("x.dummy")
|
273
|
-
load_imports
|
274
|
-
end
|
275
|
-
|
276
|
-
# HACK no assertions
|
277
|
-
end
|
278
|
-
|
279
|
-
def test_building_imported_files_on_demand
|
280
|
-
loader = util_loader
|
281
|
-
|
282
|
-
@app.instance_eval do
|
283
|
-
intern(Rake::Task, "x.dummy").enhance do loader.make_dummy end
|
284
|
-
add_loader("dummy", loader)
|
285
|
-
add_import("x.dummy")
|
286
|
-
load_imports
|
287
|
-
end
|
288
|
-
|
289
|
-
# HACK no assertions
|
290
|
-
end
|
291
|
-
|
292
|
-
def test_handle_options_should_strip_options_from_ARGV
|
293
|
-
assert !@app.options.trace
|
294
|
-
|
295
|
-
valid_option = '--trace'
|
296
|
-
ARGV.clear
|
297
|
-
ARGV << valid_option
|
298
|
-
|
299
|
-
@app.handle_options
|
300
|
-
|
301
|
-
assert !ARGV.include?(valid_option)
|
302
|
-
assert @app.options.trace
|
303
|
-
end
|
304
|
-
|
305
|
-
def test_good_run
|
306
|
-
ran = false
|
307
|
-
|
308
|
-
ARGV << '--rakelib=""'
|
309
|
-
|
310
|
-
@app.options.silent = true
|
311
|
-
|
312
|
-
@app.instance_eval do
|
313
|
-
intern(Rake::Task, "default").enhance { ran = true }
|
314
|
-
end
|
315
|
-
|
316
|
-
rakefile_default
|
317
|
-
|
318
|
-
out, err = capture_io do
|
319
|
-
@app.run
|
320
|
-
end
|
321
|
-
|
322
|
-
assert ran
|
323
|
-
assert_empty err
|
324
|
-
assert_equal "DEFAULT\n", out
|
325
|
-
end
|
326
|
-
|
327
|
-
def test_display_task_run
|
328
|
-
ran = false
|
329
|
-
ARGV.clear
|
330
|
-
ARGV << '-f' << '-s' << '--tasks' << '--rakelib=""'
|
331
|
-
@app.last_description = "COMMENT"
|
332
|
-
@app.define_task(Rake::Task, "default")
|
333
|
-
out, = capture_io { @app.run }
|
334
|
-
assert @app.options.show_tasks
|
335
|
-
assert ! ran
|
336
|
-
assert_match(/rake default/, out)
|
337
|
-
assert_match(/# COMMENT/, out)
|
338
|
-
end
|
339
|
-
|
340
|
-
def test_display_prereqs
|
341
|
-
ran = false
|
342
|
-
ARGV.clear
|
343
|
-
ARGV << '-f' << '-s' << '--prereqs' << '--rakelib=""'
|
344
|
-
@app.last_description = "COMMENT"
|
345
|
-
t = @app.define_task(Rake::Task, "default")
|
346
|
-
t.enhance([:a, :b])
|
347
|
-
@app.define_task(Rake::Task, "a")
|
348
|
-
@app.define_task(Rake::Task, "b")
|
349
|
-
out, = capture_io { @app.run }
|
350
|
-
assert @app.options.show_prereqs
|
351
|
-
assert ! ran
|
352
|
-
assert_match(/rake a$/, out)
|
353
|
-
assert_match(/rake b$/, out)
|
354
|
-
assert_match(/rake default\n( *(a|b)\n){2}/m, out)
|
355
|
-
end
|
356
|
-
|
357
|
-
def test_bad_run
|
358
|
-
@app.intern(Rake::Task, "default").enhance { fail }
|
359
|
-
ARGV.clear
|
360
|
-
ARGV << '-f' << '-s' << '--rakelib=""'
|
361
|
-
assert_raises(SystemExit) {
|
362
|
-
_, err = capture_io { @app.run }
|
363
|
-
assert_match(/see full trace/, err)
|
364
|
-
}
|
365
|
-
ensure
|
366
|
-
ARGV.clear
|
367
|
-
end
|
368
|
-
|
369
|
-
def test_bad_run_with_trace
|
370
|
-
@app.intern(Rake::Task, "default").enhance { fail }
|
371
|
-
ARGV.clear
|
372
|
-
ARGV << '-f' << '-s' << '-t'
|
373
|
-
assert_raises(SystemExit) {
|
374
|
-
_, err = capture_io { @app.run }
|
375
|
-
refute_match(/see full trace/, err)
|
376
|
-
}
|
377
|
-
ensure
|
378
|
-
ARGV.clear
|
379
|
-
end
|
380
|
-
|
381
|
-
def test_bad_run_with_backtrace
|
382
|
-
@app.intern(Rake::Task, "default").enhance { fail }
|
383
|
-
ARGV.clear
|
384
|
-
ARGV << '-f' << '-s' << '--backtrace'
|
385
|
-
assert_raises(SystemExit) {
|
386
|
-
_, err = capture_io { @app.run }
|
387
|
-
refute_match(/see full trace/, err)
|
388
|
-
}
|
389
|
-
ensure
|
390
|
-
ARGV.clear
|
391
|
-
end
|
392
|
-
|
393
|
-
def test_run_with_bad_options
|
394
|
-
@app.intern(Rake::Task, "default").enhance { fail }
|
395
|
-
ARGV.clear
|
396
|
-
ARGV << '-f' << '-s' << '--xyzzy'
|
397
|
-
assert_raises(SystemExit) {
|
398
|
-
capture_io { @app.run }
|
399
|
-
}
|
400
|
-
ensure
|
401
|
-
ARGV.clear
|
402
|
-
end
|
403
|
-
|
404
|
-
def test_standard_exception_handling_invalid_option
|
405
|
-
out, err = capture_io do
|
406
|
-
e = assert_raises SystemExit do
|
407
|
-
@app.standard_exception_handling do
|
408
|
-
raise OptionParser::InvalidOption, 'blah'
|
409
|
-
end
|
410
|
-
end
|
411
|
-
|
412
|
-
assert_equal 1, e.status
|
413
|
-
end
|
414
|
-
|
415
|
-
assert_empty out
|
416
|
-
assert_equal "invalid option: blah\n", err
|
417
|
-
end
|
418
|
-
|
419
|
-
def test_standard_exception_handling_other
|
420
|
-
out, err = capture_io do
|
421
|
-
e = assert_raises SystemExit do
|
422
|
-
@app.standard_exception_handling do
|
423
|
-
raise 'blah'
|
424
|
-
end
|
425
|
-
end
|
426
|
-
|
427
|
-
assert_equal 1, e.status
|
428
|
-
end
|
429
|
-
|
430
|
-
assert_empty out
|
431
|
-
assert_match "rake aborted!\n", err
|
432
|
-
assert_match "blah\n", err
|
433
|
-
end
|
434
|
-
|
435
|
-
def test_standard_exception_handling_system_exit
|
436
|
-
out, err = capture_io do
|
437
|
-
e = assert_raises SystemExit do
|
438
|
-
@app.standard_exception_handling do
|
439
|
-
exit 0
|
440
|
-
end
|
441
|
-
end
|
442
|
-
|
443
|
-
assert_equal 0, e.status
|
444
|
-
end
|
445
|
-
|
446
|
-
assert_empty out
|
447
|
-
assert_empty err
|
448
|
-
end
|
449
|
-
|
450
|
-
def test_standard_exception_handling_system_exit_nonzero
|
451
|
-
out, err = capture_io do
|
452
|
-
e = assert_raises SystemExit do
|
453
|
-
@app.standard_exception_handling do
|
454
|
-
exit 5
|
455
|
-
end
|
456
|
-
end
|
457
|
-
|
458
|
-
assert_equal 5, e.status
|
459
|
-
end
|
460
|
-
|
461
|
-
assert_empty out
|
462
|
-
assert_empty err
|
463
|
-
end
|
464
|
-
|
465
|
-
def util_loader
|
466
|
-
loader = Object.new
|
467
|
-
|
468
|
-
loader.instance_variable_set :@load_called, false
|
469
|
-
def loader.load arg
|
470
|
-
raise 'called more than once' if @load_called
|
471
|
-
raise ArgumentError, arg unless arg == 'x.dummy'
|
472
|
-
@load_called = true
|
473
|
-
end
|
474
|
-
|
475
|
-
loader.instance_variable_set :@make_dummy_called, false
|
476
|
-
def loader.make_dummy
|
477
|
-
raise 'called more than once' if @make_dummy_called
|
478
|
-
@make_dummy_called = true
|
479
|
-
end
|
480
|
-
|
481
|
-
loader
|
482
|
-
end
|
483
|
-
|
484
|
-
end
|