rake 10.5.0 → 13.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +5 -5
  2. data/History.rdoc +2032 -288
  3. data/README.rdoc +40 -24
  4. data/doc/jamis.rb +1 -0
  5. data/doc/rake.1 +139 -124
  6. data/doc/rakefile.rdoc +2 -4
  7. data/{bin → exe}/rake +1 -7
  8. data/lib/rake/application.rb +131 -90
  9. data/lib/rake/backtrace.rb +3 -2
  10. data/lib/rake/clean.rb +7 -5
  11. data/lib/rake/cloneable.rb +1 -0
  12. data/lib/rake/cpu_counter.rb +10 -28
  13. data/lib/rake/default_loader.rb +1 -0
  14. data/lib/rake/dsl_definition.rb +5 -11
  15. data/lib/rake/early_time.rb +1 -0
  16. data/lib/rake/ext/core.rb +1 -0
  17. data/lib/rake/ext/string.rb +22 -21
  18. data/lib/rake/file_creation_task.rb +4 -3
  19. data/lib/rake/file_list.rb +34 -27
  20. data/lib/rake/file_task.rb +12 -4
  21. data/lib/rake/file_utils.rb +38 -32
  22. data/lib/rake/file_utils_ext.rb +8 -18
  23. data/lib/rake/invocation_chain.rb +1 -0
  24. data/lib/rake/invocation_exception_mixin.rb +1 -0
  25. data/lib/rake/late_time.rb +2 -1
  26. data/lib/rake/linked_list.rb +24 -15
  27. data/lib/rake/loaders/makefile.rb +5 -4
  28. data/lib/rake/multi_task.rb +2 -1
  29. data/lib/rake/name_space.rb +1 -1
  30. data/lib/rake/packagetask.rb +40 -17
  31. data/lib/rake/phony.rb +2 -1
  32. data/lib/rake/private_reader.rb +1 -0
  33. data/lib/rake/promise.rb +13 -12
  34. data/lib/rake/pseudo_status.rb +1 -0
  35. data/lib/rake/rake_module.rb +30 -1
  36. data/lib/rake/rake_test_loader.rb +9 -4
  37. data/lib/rake/rule_recursion_overflow_error.rb +2 -2
  38. data/lib/rake/scope.rb +3 -2
  39. data/lib/rake/task.rb +82 -31
  40. data/lib/rake/task_argument_error.rb +1 -0
  41. data/lib/rake/task_arguments.rb +15 -4
  42. data/lib/rake/task_manager.rb +56 -32
  43. data/lib/rake/tasklib.rb +2 -14
  44. data/lib/rake/testtask.rb +37 -61
  45. data/lib/rake/thread_history_display.rb +4 -3
  46. data/lib/rake/thread_pool.rb +16 -17
  47. data/lib/rake/trace_output.rb +2 -1
  48. data/lib/rake/version.rb +4 -1
  49. data/lib/rake/win32.rb +10 -15
  50. data/lib/rake.rb +35 -43
  51. data/rake.gemspec +100 -0
  52. metadata +27 -223
  53. data/.autotest +0 -7
  54. data/.rubocop.yml +0 -27
  55. data/.togglerc +0 -7
  56. data/CONTRIBUTING.rdoc +0 -38
  57. data/Manifest.txt +0 -166
  58. data/Rakefile +0 -81
  59. data/doc/release_notes/rake-0.4.14.rdoc +0 -23
  60. data/doc/release_notes/rake-0.4.15.rdoc +0 -35
  61. data/doc/release_notes/rake-0.5.0.rdoc +0 -53
  62. data/doc/release_notes/rake-0.5.3.rdoc +0 -78
  63. data/doc/release_notes/rake-0.5.4.rdoc +0 -46
  64. data/doc/release_notes/rake-0.6.0.rdoc +0 -141
  65. data/doc/release_notes/rake-0.7.0.rdoc +0 -119
  66. data/doc/release_notes/rake-0.7.1.rdoc +0 -59
  67. data/doc/release_notes/rake-0.7.2.rdoc +0 -121
  68. data/doc/release_notes/rake-0.7.3.rdoc +0 -47
  69. data/doc/release_notes/rake-0.8.0.rdoc +0 -114
  70. data/doc/release_notes/rake-0.8.2.rdoc +0 -165
  71. data/doc/release_notes/rake-0.8.3.rdoc +0 -112
  72. data/doc/release_notes/rake-0.8.4.rdoc +0 -147
  73. data/doc/release_notes/rake-0.8.5.rdoc +0 -53
  74. data/doc/release_notes/rake-0.8.6.rdoc +0 -37
  75. data/doc/release_notes/rake-0.8.7.rdoc +0 -55
  76. data/doc/release_notes/rake-0.9.0.rdoc +0 -112
  77. data/doc/release_notes/rake-0.9.1.rdoc +0 -52
  78. data/doc/release_notes/rake-0.9.2.2.rdoc +0 -55
  79. data/doc/release_notes/rake-0.9.2.rdoc +0 -49
  80. data/doc/release_notes/rake-0.9.3.rdoc +0 -102
  81. data/doc/release_notes/rake-0.9.4.rdoc +0 -60
  82. data/doc/release_notes/rake-0.9.5.rdoc +0 -55
  83. data/doc/release_notes/rake-0.9.6.rdoc +0 -64
  84. data/doc/release_notes/rake-10.0.0.rdoc +0 -178
  85. data/doc/release_notes/rake-10.0.1.rdoc +0 -58
  86. data/doc/release_notes/rake-10.0.2.rdoc +0 -53
  87. data/doc/release_notes/rake-10.0.3.rdoc +0 -191
  88. data/doc/release_notes/rake-10.1.0.rdoc +0 -61
  89. data/lib/rake/alt_system.rb +0 -110
  90. data/lib/rake/contrib/.document +0 -1
  91. data/lib/rake/contrib/compositepublisher.rb +0 -21
  92. data/lib/rake/contrib/ftptools.rb +0 -137
  93. data/lib/rake/contrib/publisher.rb +0 -81
  94. data/lib/rake/contrib/rubyforgepublisher.rb +0 -18
  95. data/lib/rake/contrib/sshpublisher.rb +0 -61
  96. data/lib/rake/contrib/sys.rb +0 -4
  97. data/lib/rake/ext/module.rb +0 -2
  98. data/lib/rake/ext/pathname.rb +0 -25
  99. data/lib/rake/ext/time.rb +0 -18
  100. data/lib/rake/gempackagetask.rb +0 -4
  101. data/lib/rake/pathmap.rb +0 -3
  102. data/lib/rake/rdoctask.rb +0 -4
  103. data/lib/rake/ruby182_test_unit_fix.rb +0 -29
  104. data/lib/rake/runtest.rb +0 -27
  105. data/rakelib/publish.rake +0 -20
  106. data/rakelib/test_times.rake +0 -25
  107. data/test/file_creation.rb +0 -34
  108. data/test/helper.rb +0 -129
  109. data/test/support/rakefile_definitions.rb +0 -478
  110. data/test/support/ruby_runner.rb +0 -34
  111. data/test/test_private_reader.rb +0 -42
  112. data/test/test_rake.rb +0 -40
  113. data/test/test_rake_application.rb +0 -643
  114. data/test/test_rake_application_options.rb +0 -468
  115. data/test/test_rake_backtrace.rb +0 -119
  116. data/test/test_rake_clean.rb +0 -61
  117. data/test/test_rake_cpu_counter.rb +0 -68
  118. data/test/test_rake_definitions.rb +0 -84
  119. data/test/test_rake_directory_task.rb +0 -76
  120. data/test/test_rake_dsl.rb +0 -40
  121. data/test/test_rake_early_time.rb +0 -31
  122. data/test/test_rake_extension.rb +0 -59
  123. data/test/test_rake_file_creation_task.rb +0 -56
  124. data/test/test_rake_file_list.rb +0 -670
  125. data/test/test_rake_file_list_path_map.rb +0 -8
  126. data/test/test_rake_file_task.rb +0 -197
  127. data/test/test_rake_file_utils.rb +0 -314
  128. data/test/test_rake_ftp_file.rb +0 -74
  129. data/test/test_rake_functional.rb +0 -482
  130. data/test/test_rake_invocation_chain.rb +0 -64
  131. data/test/test_rake_late_time.rb +0 -18
  132. data/test/test_rake_linked_list.rb +0 -84
  133. data/test/test_rake_makefile_loader.rb +0 -46
  134. data/test/test_rake_multi_task.rb +0 -64
  135. data/test/test_rake_name_space.rb +0 -57
  136. data/test/test_rake_package_task.rb +0 -79
  137. data/test/test_rake_path_map.rb +0 -168
  138. data/test/test_rake_path_map_explode.rb +0 -34
  139. data/test/test_rake_path_map_partial.rb +0 -18
  140. data/test/test_rake_pathname_extensions.rb +0 -15
  141. data/test/test_rake_pseudo_status.rb +0 -21
  142. data/test/test_rake_rake_test_loader.rb +0 -20
  143. data/test/test_rake_reduce_compat.rb +0 -26
  144. data/test/test_rake_require.rb +0 -40
  145. data/test/test_rake_rules.rb +0 -388
  146. data/test/test_rake_scope.rb +0 -44
  147. data/test/test_rake_task.rb +0 -393
  148. data/test/test_rake_task_argument_parsing.rb +0 -119
  149. data/test/test_rake_task_arguments.rb +0 -127
  150. data/test/test_rake_task_lib.rb +0 -9
  151. data/test/test_rake_task_manager.rb +0 -178
  152. data/test/test_rake_task_manager_argument_resolution.rb +0 -19
  153. data/test/test_rake_task_with_arguments.rb +0 -172
  154. data/test/test_rake_test_task.rb +0 -146
  155. data/test/test_rake_thread_pool.rb +0 -145
  156. data/test/test_rake_top_level_functions.rb +0 -71
  157. data/test/test_rake_win32.rb +0 -72
  158. data/test/test_thread_history_display.rb +0 -101
  159. data/test/test_trace_output.rb +0 -52
@@ -1,643 +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 setup_command_line(*options)
13
- ARGV.clear
14
- options.each do |option|
15
- ARGV << option
16
- end
17
- end
18
-
19
- def test_display_exception_details
20
- obj = Object.new
21
- obj.instance_eval("def #{__method__}; raise 'test'; end", "ruby")
22
- begin
23
- obj.__send__(__method__)
24
- rescue => ex
25
- end
26
-
27
- out, err = capture_io do
28
- @app.display_error_message ex
29
- end
30
-
31
- assert_empty out
32
-
33
- assert_match 'rake aborted!', err
34
- assert_match __method__.to_s, err
35
- end
36
-
37
- def test_display_exception_details_cause
38
- skip 'Exception#cause not implemented' unless
39
- Exception.method_defined? :cause
40
-
41
- begin
42
- raise 'cause a'
43
- rescue
44
- begin
45
- raise 'cause b'
46
- rescue => ex
47
- end
48
- end
49
-
50
- out, err = capture_io do
51
- @app.display_error_message ex
52
- end
53
-
54
- assert_empty out
55
-
56
- assert_match 'cause a', err
57
- assert_match 'cause b', err
58
- end
59
-
60
- def test_display_exception_details_cause_loop
61
- skip 'Exception#cause not implemented' unless
62
- Exception.method_defined? :cause
63
-
64
- begin
65
- begin
66
- raise 'cause a'
67
- rescue => a
68
- begin
69
- raise 'cause b'
70
- rescue
71
- raise a
72
- end
73
- end
74
- rescue => ex
75
- end
76
-
77
- out, err = capture_io do
78
- @app.display_error_message ex
79
- end
80
-
81
- assert_empty out
82
-
83
- assert_match 'cause a', err
84
- assert_match 'cause b', err
85
- end
86
-
87
- def test_display_tasks
88
- @app.options.show_tasks = :tasks
89
- @app.options.show_task_pattern = //
90
- @app.last_description = "COMMENT"
91
- @app.define_task(Rake::Task, "t")
92
- out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
93
- assert_match(/^rake t/, out)
94
- assert_match(/# COMMENT/, out)
95
- end
96
-
97
- def test_display_tasks_with_long_comments
98
- @app.terminal_columns = 80
99
- @app.options.show_tasks = :tasks
100
- @app.options.show_task_pattern = //
101
- numbers = "1234567890" * 8
102
- @app.last_description = numbers
103
- @app.define_task(Rake::Task, "t")
104
-
105
- out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
106
-
107
- assert_match(/^rake t/, out)
108
- assert_match(/# #{numbers[0, 65]}\.\.\./, out)
109
- end
110
-
111
- def test_display_tasks_with_task_name_wider_than_tty_display
112
- @app.terminal_columns = 80
113
- @app.options.show_tasks = :tasks
114
- @app.options.show_task_pattern = //
115
- task_name = "task name" * 80
116
- @app.last_description = "something short"
117
- @app.define_task(Rake::Task, task_name)
118
-
119
- out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
120
-
121
- # Ensure the entire task name is output and we end up showing no description
122
- assert_match(/rake #{task_name} # .../, out)
123
- end
124
-
125
- def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment
126
- @app.options.show_tasks = :tasks
127
- @app.options.show_task_pattern = //
128
- @app.tty_output = false
129
- description = "something short"
130
- task_name = "task name" * 80
131
- @app.last_description = "something short"
132
- @app.define_task(Rake::Task, task_name)
133
-
134
- out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
135
-
136
- # Ensure the entire task name is output and we end up showing no description
137
- assert_match(/rake #{task_name} # #{description}/, out)
138
- end
139
-
140
- def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment
141
- @app.options.show_tasks = :tasks
142
- @app.options.show_task_pattern = //
143
- @app.tty_output = false
144
- @app.last_description = "1234567890" * 8
145
- @app.define_task(Rake::Task, "t")
146
- out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
147
- assert_match(/^rake t/, out)
148
- assert_match(/# #{@app.last_description}/, out)
149
- end
150
-
151
- def test_truncating_comments_to_a_non_tty
152
- @app.terminal_columns = 80
153
- @app.options.show_tasks = :tasks
154
- @app.options.show_task_pattern = //
155
- @app.tty_output = false
156
- numbers = "1234567890" * 8
157
- @app.last_description = numbers
158
- @app.define_task(Rake::Task, "t")
159
-
160
- out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
161
-
162
- assert_match(/^rake t/, out)
163
- assert_match(/# #{numbers[0, 65]}\.\.\./, out)
164
- end
165
-
166
- def test_describe_tasks
167
- @app.options.show_tasks = :describe
168
- @app.options.show_task_pattern = //
169
- @app.last_description = "COMMENT"
170
- @app.define_task(Rake::Task, "t")
171
- out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
172
- assert_match(/^rake t$/, out)
173
- assert_match(/^ {4}COMMENT$/, out)
174
- end
175
-
176
- def test_show_lines
177
- @app.options.show_tasks = :lines
178
- @app.options.show_task_pattern = //
179
- @app.last_description = "COMMENT"
180
- @app.define_task(Rake::Task, "t")
181
- @app['t'].locations << "HERE:1"
182
- out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
183
- assert_match(/^rake t +[^:]+:\d+ *$/, out)
184
- end
185
-
186
- def test_finding_rakefile
187
- rakefile_default
188
-
189
- assert_match(/Rakefile/i, @app.instance_eval { have_rakefile })
190
- end
191
-
192
- def test_not_finding_rakefile
193
- @app.instance_eval { @rakefiles = ['NEVER_FOUND'] }
194
- assert(! @app.instance_eval do have_rakefile end)
195
- assert_nil @app.rakefile
196
- end
197
-
198
- def test_load_rakefile
199
- rakefile_unittest
200
-
201
- @app.instance_eval do
202
- handle_options
203
- options.silent = true
204
- load_rakefile
205
- end
206
-
207
- assert_equal "rakefile", @app.rakefile.downcase
208
- assert_equal @tempdir, Dir.pwd
209
- end
210
-
211
- def test_load_rakefile_doesnt_print_rakefile_directory_from_same_dir
212
- rakefile_unittest
213
-
214
- _, err = capture_io do
215
- @app.instance_eval do
216
- # pretend we started from the unittest dir
217
- @original_dir = File.expand_path(".")
218
- raw_load_rakefile
219
- end
220
- end
221
-
222
- assert_empty err
223
- end
224
-
225
- def test_load_rakefile_from_subdir
226
- rakefile_unittest
227
- Dir.chdir 'subdir'
228
-
229
- @app.instance_eval do
230
- handle_options
231
- options.silent = true
232
- load_rakefile
233
- end
234
-
235
- assert_equal "rakefile", @app.rakefile.downcase
236
- assert_equal @tempdir, Dir.pwd
237
- end
238
-
239
- def test_load_rakefile_prints_rakefile_directory_from_subdir
240
- rakefile_unittest
241
- Dir.chdir 'subdir'
242
-
243
- app = Rake::Application.new
244
- app.options.rakelib = []
245
-
246
- _, err = capture_io do
247
- app.instance_eval do
248
- raw_load_rakefile
249
- end
250
- end
251
-
252
- assert_equal "(in #{@tempdir}\)\n", err
253
- end
254
-
255
- def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent
256
- rakefile_unittest
257
- Dir.chdir 'subdir'
258
-
259
- _, err = capture_io do
260
- @app.instance_eval do
261
- handle_options
262
- options.silent = true
263
- raw_load_rakefile
264
- end
265
- end
266
-
267
- assert_empty err
268
- end
269
-
270
- def test_load_rakefile_not_found
271
- ARGV.clear
272
- Dir.chdir @tempdir
273
- ENV['RAKE_SYSTEM'] = 'not_exist'
274
-
275
- @app.instance_eval do
276
- handle_options
277
- options.silent = true
278
- end
279
-
280
-
281
- ex = assert_raises(RuntimeError) do
282
- @app.instance_eval do
283
- raw_load_rakefile
284
- end
285
- end
286
-
287
- assert_match(/no rakefile found/i, ex.message)
288
- end
289
-
290
- def test_load_from_system_rakefile
291
- rake_system_dir
292
-
293
- @app.instance_eval do
294
- handle_options
295
- options.silent = true
296
- options.load_system = true
297
- options.rakelib = []
298
- load_rakefile
299
- end
300
-
301
- assert_equal @system_dir, @app.system_dir
302
- assert_nil @app.rakefile
303
- rescue SystemExit
304
- flunk 'failed to load rakefile'
305
- end
306
-
307
- def test_load_from_calculated_system_rakefile
308
- rakefile_default
309
- def @app.standard_system_dir
310
- "__STD_SYS_DIR__"
311
- end
312
-
313
- ENV['RAKE_SYSTEM'] = nil
314
-
315
- @app.instance_eval do
316
- handle_options
317
- options.silent = true
318
- options.load_system = true
319
- options.rakelib = []
320
- load_rakefile
321
- end
322
-
323
- assert_equal "__STD_SYS_DIR__", @app.system_dir
324
- rescue SystemExit
325
- flunk 'failed to find system rakefile'
326
- end
327
-
328
- def test_terminal_columns
329
- old_rake_columns = ENV['RAKE_COLUMNS']
330
-
331
- ENV['RAKE_COLUMNS'] = '42'
332
-
333
- app = Rake::Application.new
334
-
335
- assert_equal 42, app.terminal_columns
336
- ensure
337
- if old_rake_columns
338
- ENV['RAKE_COLUMNS'].delete
339
- else
340
- ENV['RAKE_COLUMNS'] = old_rake_columns
341
- end
342
- end
343
-
344
- def test_windows
345
- assert ! (@app.windows? && @app.unix?)
346
- end
347
-
348
- def test_loading_imports
349
- loader = util_loader
350
-
351
- @app.instance_eval do
352
- add_loader("dummy", loader)
353
- add_import("x.dummy")
354
- load_imports
355
- end
356
-
357
- # HACK no assertions
358
- end
359
-
360
- def test_building_imported_files_on_demand
361
- loader = util_loader
362
-
363
- @app.instance_eval do
364
- intern(Rake::Task, "x.dummy").enhance do loader.make_dummy end
365
- add_loader("dummy", loader)
366
- add_import("x.dummy")
367
- load_imports
368
- end
369
-
370
- # HACK no assertions
371
- end
372
-
373
- def test_handle_options_should_not_strip_options_from_argv
374
- assert !@app.options.trace
375
-
376
- valid_option = '--trace'
377
- setup_command_line(valid_option)
378
-
379
- @app.handle_options
380
-
381
- assert ARGV.include?(valid_option)
382
- assert @app.options.trace
383
- end
384
-
385
- def test_handle_options_trace_default_is_stderr
386
- setup_command_line("--trace")
387
-
388
- @app.handle_options
389
-
390
- assert_equal STDERR, @app.options.trace_output
391
- assert @app.options.trace
392
- end
393
-
394
- def test_handle_options_trace_overrides_to_stdout
395
- setup_command_line("--trace=stdout")
396
-
397
- @app.handle_options
398
-
399
- assert_equal STDOUT, @app.options.trace_output
400
- assert @app.options.trace
401
- end
402
-
403
- def test_handle_options_trace_does_not_eat_following_task_names
404
- assert !@app.options.trace
405
-
406
- setup_command_line("--trace", "sometask")
407
-
408
- @app.handle_options
409
- assert ARGV.include?("sometask")
410
- assert @app.options.trace
411
- end
412
-
413
- def test_good_run
414
- ran = false
415
-
416
- ARGV << '--rakelib=""'
417
-
418
- @app.options.silent = true
419
-
420
- @app.instance_eval do
421
- intern(Rake::Task, "default").enhance { ran = true }
422
- end
423
-
424
- rakefile_default
425
-
426
- out, err = capture_io do
427
- @app.run
428
- end
429
-
430
- assert ran
431
- assert_empty err
432
- assert_equal "DEFAULT\n", out
433
- end
434
-
435
- def test_display_task_run
436
- ran = false
437
- setup_command_line('-f', '-s', '--tasks', '--rakelib=""')
438
- @app.last_description = "COMMENT"
439
- @app.define_task(Rake::Task, "default")
440
- out, = capture_io { @app.run }
441
- assert @app.options.show_tasks
442
- assert ! ran
443
- assert_match(/rake default/, out)
444
- assert_match(/# COMMENT/, out)
445
- end
446
-
447
- def test_display_prereqs
448
- ran = false
449
- setup_command_line('-f', '-s', '--prereqs', '--rakelib=""')
450
- @app.last_description = "COMMENT"
451
- t = @app.define_task(Rake::Task, "default")
452
- t.enhance([:a, :b])
453
- @app.define_task(Rake::Task, "a")
454
- @app.define_task(Rake::Task, "b")
455
- out, = capture_io { @app.run }
456
- assert @app.options.show_prereqs
457
- assert ! ran
458
- assert_match(/rake a$/, out)
459
- assert_match(/rake b$/, out)
460
- assert_match(/rake default\n( *(a|b)\n){2}/m, out)
461
- end
462
-
463
- def test_bad_run
464
- @app.intern(Rake::Task, "default").enhance { fail }
465
- setup_command_line('-f', '-s', '--rakelib=""')
466
- _, err = capture_io {
467
- assert_raises(SystemExit){ @app.run }
468
- }
469
- assert_match(/see full trace/i, err)
470
- ensure
471
- ARGV.clear
472
- end
473
-
474
- def test_bad_run_with_trace
475
- @app.intern(Rake::Task, "default").enhance { fail }
476
- setup_command_line('-f', '-s', '-t')
477
- _, err = capture_io {
478
- assert_raises(SystemExit) { @app.run }
479
- }
480
- refute_match(/see full trace/i, err)
481
- ensure
482
- ARGV.clear
483
- end
484
-
485
- def test_bad_run_with_backtrace
486
- @app.intern(Rake::Task, "default").enhance { fail }
487
- setup_command_line('-f', '-s', '--backtrace')
488
- _, err = capture_io {
489
- assert_raises(SystemExit) {
490
- @app.run
491
- }
492
- }
493
- refute_match(/see full trace/, err)
494
- ensure
495
- ARGV.clear
496
- end
497
-
498
- CustomError = Class.new(RuntimeError)
499
-
500
- def test_bad_run_includes_exception_name
501
- @app.intern(Rake::Task, "default").enhance {
502
- raise CustomError, "intentional"
503
- }
504
- setup_command_line('-f', '-s')
505
- _, err = capture_io {
506
- assert_raises(SystemExit) {
507
- @app.run
508
- }
509
- }
510
- assert_match(/CustomError: intentional/, err)
511
- end
512
-
513
- def test_rake_error_excludes_exception_name
514
- @app.intern(Rake::Task, "default").enhance {
515
- fail "intentional"
516
- }
517
- setup_command_line('-f', '-s')
518
- _, err = capture_io {
519
- assert_raises(SystemExit) {
520
- @app.run
521
- }
522
- }
523
- refute_match(/RuntimeError/, err)
524
- assert_match(/intentional/, err)
525
- end
526
-
527
- def cause_supported?
528
- ex = StandardError.new
529
- ex.respond_to?(:cause)
530
- end
531
-
532
- def test_printing_original_exception_cause
533
- custom_error = Class.new(StandardError)
534
- @app.intern(Rake::Task, "default").enhance {
535
- begin
536
- raise custom_error, "Original Error"
537
- rescue custom_error
538
- raise custom_error, "Secondary Error"
539
- end
540
- }
541
- setup_command_line('-f', '-s')
542
- _ ,err = capture_io {
543
- assert_raises(SystemExit) {
544
- @app.run
545
- }
546
- }
547
- if cause_supported?
548
- assert_match(/Original Error/, err)
549
- end
550
- assert_match(/Secondary Error/, err)
551
- ensure
552
- ARGV.clear
553
- end
554
-
555
- def test_run_with_bad_options
556
- @app.intern(Rake::Task, "default").enhance { fail }
557
- setup_command_line('-f', '-s', '--xyzzy')
558
- assert_raises(SystemExit) {
559
- capture_io { @app.run }
560
- }
561
- ensure
562
- ARGV.clear
563
- end
564
-
565
- def test_standard_exception_handling_invalid_option
566
- out, err = capture_io do
567
- e = assert_raises SystemExit do
568
- @app.standard_exception_handling do
569
- raise OptionParser::InvalidOption, 'blah'
570
- end
571
- end
572
-
573
- assert_equal 1, e.status
574
- end
575
-
576
- assert_empty out
577
- assert_equal "invalid option: blah\n", err
578
- end
579
-
580
- def test_standard_exception_handling_other
581
- out, err = capture_io do
582
- e = assert_raises SystemExit do
583
- @app.standard_exception_handling do
584
- raise 'blah'
585
- end
586
- end
587
-
588
- assert_equal 1, e.status
589
- end
590
-
591
- assert_empty out
592
- assert_match "rake aborted!\n", err
593
- assert_match "blah\n", err
594
- end
595
-
596
- def test_standard_exception_handling_system_exit
597
- out, err = capture_io do
598
- e = assert_raises SystemExit do
599
- @app.standard_exception_handling do
600
- exit 0
601
- end
602
- end
603
-
604
- assert_equal 0, e.status
605
- end
606
-
607
- assert_empty out
608
- assert_empty err
609
- end
610
-
611
- def test_standard_exception_handling_system_exit_nonzero
612
- out, err = capture_io do
613
- e = assert_raises SystemExit do
614
- @app.standard_exception_handling do
615
- exit 5
616
- end
617
- end
618
-
619
- assert_equal 5, e.status
620
- end
621
-
622
- assert_empty out
623
- assert_empty err
624
- end
625
-
626
- def util_loader
627
- loader = Object.new
628
-
629
- loader.instance_variable_set :@load_called, false
630
- def loader.load arg
631
- raise ArgumentError, arg unless arg == 'x.dummy'
632
- @load_called = true
633
- end
634
-
635
- loader.instance_variable_set :@make_dummy_called, false
636
- def loader.make_dummy
637
- @make_dummy_called = true
638
- end
639
-
640
- loader
641
- end
642
-
643
- end