rake 11.1.2 → 11.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rake might be problematic. Click here for more details.

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