rake 10.0.4 → 10.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/doc/command_line_usage.rdoc +1 -1
  4. data/doc/rakefile.rdoc +27 -13
  5. data/doc/release_notes/rake-10.1.0.rdoc +61 -0
  6. data/install.rb +5 -15
  7. data/lib/rake/alt_system.rb +3 -4
  8. data/lib/rake/application.rb +115 -68
  9. data/lib/rake/backtrace.rb +9 -8
  10. data/lib/rake/clean.rb +27 -4
  11. data/lib/rake/contrib/ftptools.rb +6 -18
  12. data/lib/rake/contrib/sys.rb +2 -1
  13. data/lib/rake/dsl_definition.rb +2 -1
  14. data/lib/rake/ext/core.rb +2 -1
  15. data/lib/rake/ext/string.rb +1 -3
  16. data/lib/rake/file_list.rb +24 -18
  17. data/lib/rake/file_task.rb +1 -2
  18. data/lib/rake/file_utils.rb +9 -7
  19. data/lib/rake/file_utils_ext.rb +2 -1
  20. data/lib/rake/gempackagetask.rb +2 -1
  21. data/lib/rake/invocation_chain.rb +24 -18
  22. data/lib/rake/linked_list.rb +103 -0
  23. data/lib/rake/packagetask.rb +11 -6
  24. data/lib/rake/pseudo_status.rb +5 -0
  25. data/lib/rake/rdoctask.rb +2 -1
  26. data/lib/rake/ruby182_test_unit_fix.rb +4 -2
  27. data/lib/rake/runtest.rb +2 -2
  28. data/lib/rake/scope.rb +42 -0
  29. data/lib/rake/task.rb +47 -37
  30. data/lib/rake/task_arguments.rb +13 -2
  31. data/lib/rake/task_manager.rb +25 -24
  32. data/lib/rake/tasklib.rb +1 -1
  33. data/lib/rake/testtask.rb +10 -7
  34. data/lib/rake/thread_history_display.rb +1 -1
  35. data/lib/rake/thread_pool.rb +10 -4
  36. data/lib/rake/version.rb +3 -7
  37. data/lib/rake/win32.rb +3 -2
  38. data/lib/rake.rb +2 -0
  39. data/test/helper.rb +36 -470
  40. data/test/support/rakefile_definitions.rb +444 -0
  41. data/test/support/ruby_runner.rb +33 -0
  42. data/test/test_rake_application.rb +14 -12
  43. data/test/test_rake_application_options.rb +7 -5
  44. data/test/test_rake_backtrace.rb +38 -14
  45. data/test/test_rake_clean.rb +36 -4
  46. data/test/test_rake_definitions.rb +2 -3
  47. data/test/test_rake_file_creation_task.rb +2 -2
  48. data/test/test_rake_file_list.rb +23 -24
  49. data/test/test_rake_file_task.rb +4 -4
  50. data/test/test_rake_file_utils.rb +6 -2
  51. data/test/test_rake_ftp_file.rb +28 -13
  52. data/test/test_rake_functional.rb +6 -36
  53. data/test/test_rake_invocation_chain.rb +15 -3
  54. data/test/test_rake_linked_list.rb +84 -0
  55. data/test/test_rake_makefile_loader.rb +3 -1
  56. data/test/test_rake_multi_task.rb +2 -3
  57. data/test/test_rake_name_space.rb +1 -1
  58. data/test/test_rake_path_map.rb +23 -12
  59. data/test/test_rake_rake_test_loader.rb +2 -3
  60. data/test/test_rake_reduce_compat.rb +2 -6
  61. data/test/test_rake_rules.rb +47 -12
  62. data/test/test_rake_scope.rb +44 -0
  63. data/test/test_rake_task.rb +47 -11
  64. data/test/test_rake_task_arguments.rb +35 -2
  65. data/test/test_rake_task_manager.rb +16 -15
  66. data/test/test_rake_task_with_arguments.rb +2 -2
  67. data/test/test_rake_test_task.rb +1 -2
  68. data/test/test_rake_thread_pool.rb +36 -16
  69. data/test/test_thread_history_display.rb +16 -6
  70. data/test/test_trace_output.rb +2 -0
  71. metadata +10 -2
@@ -0,0 +1,444 @@
1
+ module RakefileDefinitions
2
+ include FileUtils
3
+
4
+ def rakefile_access
5
+ rakefile <<-ACCESS
6
+ TOP_LEVEL_CONSTANT = 0
7
+
8
+ def a_top_level_function
9
+ end
10
+
11
+ task :default => [:work, :obj, :const]
12
+
13
+ task :work do
14
+ begin
15
+ a_top_level_function
16
+ puts "GOOD:M Top level methods can be called in tasks"
17
+ rescue NameError => ex
18
+ puts "BAD:M Top level methods can not be called in tasks"
19
+ end
20
+ end
21
+
22
+ # TODO: remove `disabled_' when DeprecatedObjectDSL removed
23
+ task :obj
24
+ task :disabled_obj do
25
+ begin
26
+ Object.new.instance_eval { task :xyzzy }
27
+ puts "BAD:D Rake DSL are polluting objects"
28
+ rescue StandardError => ex
29
+ puts "GOOD:D Rake DSL are not polluting objects"
30
+ end
31
+ end
32
+
33
+ task :const do
34
+ begin
35
+ TOP_LEVEL_CONSTANT
36
+ puts "GOOD:C Top level constants are available in tasks"
37
+ rescue StandardError => ex
38
+ puts "BAD:C Top level constants are NOT available in tasks"
39
+ end
40
+ end
41
+ ACCESS
42
+ end
43
+
44
+ def rakefile_chains
45
+ rakefile <<-DEFAULT
46
+ task :default => "play.app"
47
+
48
+ file "play.scpt" => "base" do |t|
49
+ cp t.prerequisites.first, t.name
50
+ end
51
+
52
+ rule ".app" => ".scpt" do |t|
53
+ cp t.source, t.name
54
+ end
55
+
56
+ file 'base' do
57
+ touch 'base'
58
+ end
59
+ DEFAULT
60
+ end
61
+
62
+ def rakefile_comments
63
+ rakefile <<-COMMENTS
64
+ # comment for t1
65
+ task :t1 do
66
+ end
67
+
68
+ # no comment or task because there's a blank line
69
+
70
+ task :t2 do
71
+ end
72
+
73
+ desc "override comment for t3"
74
+ # this is not the description
75
+ multitask :t3 do
76
+ end
77
+
78
+ # this is not the description
79
+ desc "override comment for t4"
80
+ file :t4 do
81
+ end
82
+ COMMENTS
83
+ end
84
+
85
+ def rakefile_default
86
+ rakefile <<-DEFAULT
87
+ if ENV['TESTTOPSCOPE']
88
+ puts "TOPSCOPE"
89
+ end
90
+
91
+ task :default do
92
+ puts "DEFAULT"
93
+ end
94
+
95
+ task :other => [:default] do
96
+ puts "OTHER"
97
+ end
98
+
99
+ task :task_scope do
100
+ if ENV['TESTTASKSCOPE']
101
+ puts "TASKSCOPE"
102
+ end
103
+ end
104
+ DEFAULT
105
+ end
106
+
107
+ def rakefile_dryrun
108
+ rakefile <<-DRYRUN
109
+ task :default => ["temp_main"]
110
+
111
+ file "temp_main" => [:all_apps] do touch "temp_main" end
112
+
113
+ task :all_apps => [:one, :two]
114
+ task :one => ["temp_one"]
115
+ task :two => ["temp_two"]
116
+
117
+ file "temp_one" do |t|
118
+ touch "temp_one"
119
+ end
120
+ file "temp_two" do |t|
121
+ touch "temp_two"
122
+ end
123
+
124
+ task :clean do
125
+ ["temp_one", "temp_two", "temp_main"].each do |file|
126
+ rm_f file
127
+ end
128
+ end
129
+ DRYRUN
130
+
131
+ FileUtils.touch 'temp_main'
132
+ FileUtils.touch 'temp_two'
133
+ end
134
+
135
+ def rakefile_extra
136
+ rakefile 'task :default'
137
+
138
+ FileUtils.mkdir_p 'rakelib'
139
+
140
+ open File.join('rakelib', 'extra.rake'), 'w' do |io|
141
+ io << <<-EXTRA_RAKE
142
+ # Added for testing
143
+
144
+ namespace :extra do
145
+ desc "An Extra Task"
146
+ task :extra do
147
+ puts "Read all about it"
148
+ end
149
+ end
150
+ EXTRA_RAKE
151
+ end
152
+ end
153
+
154
+ def rakefile_file_creation
155
+ rakefile <<-'FILE_CREATION'
156
+ N = 2
157
+
158
+ task :default => :run
159
+
160
+ BUILD_DIR = 'build'
161
+ task :clean do
162
+ rm_rf 'build'
163
+ rm_rf 'src'
164
+ end
165
+
166
+ task :run
167
+
168
+ TARGET_DIR = 'build/copies'
169
+
170
+ FileList['src/*'].each do |src|
171
+ directory TARGET_DIR
172
+ target = File.join TARGET_DIR, File.basename(src)
173
+ file target => [src, TARGET_DIR] do
174
+ cp src, target
175
+ end
176
+ task :run => target
177
+ end
178
+
179
+ task :prep => :clean do
180
+ mkdir_p 'src'
181
+ N.times do |n|
182
+ touch "src/foo#{n}"
183
+ end
184
+ end
185
+ FILE_CREATION
186
+ end
187
+
188
+ def rakefile_imports
189
+ rakefile <<-IMPORTS
190
+ require 'rake/loaders/makefile'
191
+
192
+ task :default
193
+
194
+ task :other do
195
+ puts "OTHER"
196
+ end
197
+
198
+ file "dynamic_deps" do |t|
199
+ open(t.name, "w") do |f| f.puts "puts 'DYNAMIC'" end
200
+ end
201
+
202
+ import "dynamic_deps"
203
+ import "static_deps"
204
+ import "static_deps"
205
+ import "deps.mf"
206
+ puts "FIRST"
207
+ IMPORTS
208
+
209
+ open 'deps.mf', 'w' do |io|
210
+ io << <<-DEPS
211
+ default: other
212
+ DEPS
213
+ end
214
+
215
+ open "static_deps", "w" do |f|
216
+ f.puts 'puts "STATIC"'
217
+ end
218
+ end
219
+
220
+ def rakefile_multidesc
221
+ rakefile <<-MULTIDESC
222
+ task :b
223
+
224
+ desc "A"
225
+ task :a
226
+
227
+ desc "B"
228
+ task :b
229
+
230
+ desc "A2"
231
+ task :a
232
+
233
+ task :c
234
+
235
+ desc "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
236
+ task :d
237
+ MULTIDESC
238
+ end
239
+
240
+ def rakefile_namespace
241
+ rakefile <<-NAMESPACE
242
+ desc "copy"
243
+ task :copy do
244
+ puts "COPY"
245
+ end
246
+
247
+ namespace "nest" do
248
+ desc "nest copy"
249
+ task :copy do
250
+ puts "NEST COPY"
251
+ end
252
+ task :xx => :copy
253
+ end
254
+
255
+ anon_ns = namespace do
256
+ desc "anonymous copy task"
257
+ task :copy do
258
+ puts "ANON COPY"
259
+ end
260
+ end
261
+
262
+ desc "Top level task to run the anonymous version of copy"
263
+ task :anon => anon_ns[:copy]
264
+
265
+ namespace "very" do
266
+ namespace "nested" do
267
+ task "run" => "rake:copy"
268
+ end
269
+ end
270
+
271
+ namespace "a" do
272
+ desc "Run task in the 'a' namespace"
273
+ task "run" do
274
+ puts "IN A"
275
+ end
276
+ end
277
+
278
+ namespace "b" do
279
+ desc "Run task in the 'b' namespace"
280
+ task "run" => "a:run" do
281
+ puts "IN B"
282
+ end
283
+ end
284
+
285
+ namespace "file1" do
286
+ file "xyz.rb" do
287
+ puts "XYZ1"
288
+ end
289
+ end
290
+
291
+ namespace "file2" do
292
+ file "xyz.rb" do
293
+ puts "XYZ2"
294
+ end
295
+ end
296
+
297
+ namespace "scopedep" do
298
+ task :prepare do
299
+ touch "scopedep.rb"
300
+ puts "PREPARE"
301
+ end
302
+ file "scopedep.rb" => [:prepare] do
303
+ puts "SCOPEDEP"
304
+ end
305
+ end
306
+ NAMESPACE
307
+ end
308
+
309
+ def rakefile_nosearch
310
+ FileUtils.touch 'dummy'
311
+ end
312
+
313
+ def rakefile_rakelib
314
+ FileUtils.mkdir_p 'rakelib'
315
+
316
+ Dir.chdir 'rakelib' do
317
+ open 'test1.rb', 'w' do |io|
318
+ io << <<-TEST1
319
+ task :default do
320
+ puts "TEST1"
321
+ end
322
+ TEST1
323
+ end
324
+
325
+ open 'test2.rake', 'w' do |io|
326
+ io << <<-TEST1
327
+ task :default do
328
+ puts "TEST2"
329
+ end
330
+ TEST1
331
+ end
332
+ end
333
+ end
334
+
335
+ def rakefile_rbext
336
+ open 'rakefile.rb', 'w' do |io|
337
+ io << 'task :default do puts "OK" end'
338
+ end
339
+ end
340
+
341
+ def rakefile_unittest
342
+ rakefile '# Empty Rakefile for Unit Test'
343
+
344
+ readme = File.join 'subdir', 'README'
345
+ FileUtils.mkdir_p File.dirname readme
346
+
347
+ FileUtils.touch readme
348
+ end
349
+
350
+ def rakefile_verbose
351
+ rakefile <<-VERBOSE
352
+ task :standalone_verbose_true do
353
+ verbose true
354
+ sh "#{RUBY} -e '0'"
355
+ end
356
+
357
+ task :standalone_verbose_false do
358
+ verbose false
359
+ sh "#{RUBY} -e '0'"
360
+ end
361
+
362
+ task :inline_verbose_default do
363
+ sh "#{RUBY} -e '0'"
364
+ end
365
+
366
+ task :inline_verbose_false do
367
+ sh "#{RUBY} -e '0'", :verbose => false
368
+ end
369
+
370
+ task :inline_verbose_true do
371
+ sh "#{RUBY} -e '0'", :verbose => true
372
+ end
373
+
374
+ task :block_verbose_true do
375
+ verbose(true) do
376
+ sh "#{RUBY} -e '0'"
377
+ end
378
+ end
379
+
380
+ task :block_verbose_false do
381
+ verbose(false) do
382
+ sh "#{RUBY} -e '0'"
383
+ end
384
+ end
385
+ VERBOSE
386
+ end
387
+
388
+ def rakefile_test_signal
389
+ rakefile <<-TEST_SIGNAL
390
+ require 'rake/testtask'
391
+
392
+ Rake::TestTask.new(:a) do |t|
393
+ t.test_files = ['a_test.rb']
394
+ end
395
+
396
+ Rake::TestTask.new(:b) do |t|
397
+ t.test_files = ['b_test.rb']
398
+ end
399
+
400
+ task :test do
401
+ Rake::Task[:a].invoke
402
+ Rake::Task[:b].invoke
403
+ end
404
+
405
+ task :default => :test
406
+ TEST_SIGNAL
407
+ open 'a_test.rb', 'w' do |io|
408
+ io << 'puts "ATEST"' << "\n"
409
+ io << '$stdout.flush' << "\n"
410
+ io << 'Process.kill("TERM", $$)' << "\n"
411
+ end
412
+ open 'b_test.rb', 'w' do |io|
413
+ io << 'puts "BTEST"' << "\n"
414
+ io << '$stdout.flush' << "\n"
415
+ end
416
+ end
417
+
418
+ def rakefile_failing_test_task
419
+ rakefile <<-TEST_TASK
420
+ require 'rake/testtask'
421
+
422
+ task :default => :test
423
+ Rake::TestTask.new(:test) do |t|
424
+ t.test_files = ['a_test.rb']
425
+ end
426
+ TEST_TASK
427
+ open 'a_test.rb', 'w' do |io|
428
+ io << "require 'minitest/autorun'\n"
429
+ io << "class ExitTaskTest < MiniTest::Unit::TestCase\n"
430
+ io << " def test_exit\n"
431
+ io << " assert false, 'this should fail'\n"
432
+ io << " end\n"
433
+ io << "end\n"
434
+ end
435
+ end
436
+
437
+ def rakefile_stand_alone_filelist
438
+ open 'stand_alone_filelist.rb', 'w' do |io|
439
+ io << "require 'rake/file_list'\n"
440
+ io << "FL = Rake::FileList['*.rb']\n"
441
+ io << "puts FL\n"
442
+ end
443
+ end
444
+ end
@@ -0,0 +1,33 @@
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
+ inn, out, err, wait = Open3.popen3(RUBY, *option_list)
22
+ inn.close
23
+
24
+ @exit = wait ? wait.value : $?
25
+ @out = out.read
26
+ @err = err.read
27
+
28
+ puts "OUTPUT: [#{@out}]" if @verbose
29
+ puts "ERROR: [#{@err}]" if @verbose
30
+ puts "EXIT: [#{@exit.inspect}]" if @verbose
31
+ puts "PWD: [#{Dir.pwd}]" if @verbose
32
+ end
33
+ end
@@ -23,13 +23,14 @@ class TestRakeApplication < Rake::TestCase
23
23
  @app.terminal_columns = 80
24
24
  @app.options.show_tasks = :tasks
25
25
  @app.options.show_task_pattern = //
26
- @app.last_description = "1234567890" * 8
26
+ numbers = "1234567890" * 8
27
+ @app.last_description = numbers
27
28
  @app.define_task(Rake::Task, "t")
28
29
 
29
30
  out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
30
31
 
31
32
  assert_match(/^rake t/, out)
32
- assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
33
+ assert_match(/# #{numbers[0, 65]}\.\.\./, out)
33
34
  end
34
35
 
35
36
  def test_display_tasks_with_task_name_wider_than_tty_display
@@ -38,7 +39,7 @@ class TestRakeApplication < Rake::TestCase
38
39
  @app.options.show_task_pattern = //
39
40
  task_name = "task name" * 80
40
41
  @app.last_description = "something short"
41
- @app.define_task(Rake::Task, task_name )
42
+ @app.define_task(Rake::Task, task_name)
42
43
 
43
44
  out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
44
45
 
@@ -53,7 +54,7 @@ class TestRakeApplication < Rake::TestCase
53
54
  description = "something short"
54
55
  task_name = "task name" * 80
55
56
  @app.last_description = "something short"
56
- @app.define_task(Rake::Task, task_name )
57
+ @app.define_task(Rake::Task, task_name)
57
58
 
58
59
  out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
59
60
 
@@ -72,18 +73,19 @@ class TestRakeApplication < Rake::TestCase
72
73
  assert_match(/# #{@app.last_description}/, out)
73
74
  end
74
75
 
75
- def test_display_tasks_with_long_comments_to_a_non_tty_with_columns_set_truncates_comments
76
+ def test_truncating_comments_to_a_non_tty
76
77
  @app.terminal_columns = 80
77
78
  @app.options.show_tasks = :tasks
78
79
  @app.options.show_task_pattern = //
79
80
  @app.tty_output = false
80
- @app.last_description = "1234567890" * 8
81
+ numbers = "1234567890" * 8
82
+ @app.last_description = numbers
81
83
  @app.define_task(Rake::Task, "t")
82
84
 
83
85
  out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
84
86
 
85
87
  assert_match(/^rake t/, out)
86
- assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
88
+ assert_match(/# #{numbers[0, 65]}\.\.\./, out)
87
89
  end
88
90
 
89
91
  def test_describe_tasks
@@ -114,7 +116,7 @@ class TestRakeApplication < Rake::TestCase
114
116
 
115
117
  def test_not_finding_rakefile
116
118
  @app.instance_eval { @rakefiles = ['NEVER_FOUND'] }
117
- assert( ! @app.instance_eval do have_rakefile end )
119
+ assert(! @app.instance_eval do have_rakefile end)
118
120
  assert_nil @app.rakefile
119
121
  end
120
122
 
@@ -245,7 +247,7 @@ class TestRakeApplication < Rake::TestCase
245
247
  end
246
248
 
247
249
  def test_terminal_columns
248
- old_RAKE_COLUMNS = ENV['RAKE_COLUMNS']
250
+ old_rake_columns = ENV['RAKE_COLUMNS']
249
251
 
250
252
  ENV['RAKE_COLUMNS'] = '42'
251
253
 
@@ -253,10 +255,10 @@ class TestRakeApplication < Rake::TestCase
253
255
 
254
256
  assert_equal 42, app.terminal_columns
255
257
  ensure
256
- if old_RAKE_COLUMNS then
258
+ if old_rake_columns
257
259
  ENV['RAKE_COLUMNS'].delete
258
260
  else
259
- ENV['RAKE_COLUMNS'] = old_RAKE_COLUMNS
261
+ ENV['RAKE_COLUMNS'] = old_rake_columns
260
262
  end
261
263
  end
262
264
 
@@ -289,7 +291,7 @@ class TestRakeApplication < Rake::TestCase
289
291
  # HACK no assertions
290
292
  end
291
293
 
292
- def test_handle_options_should_strip_options_from_ARGV
294
+ def test_handle_options_should_strip_options_from_argv
293
295
  assert !@app.options.trace
294
296
 
295
297
  valid_option = '--trace'
@@ -1,6 +1,6 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
2
 
3
- TESTING_REQUIRE = [ ]
3
+ TESTING_REQUIRE = []
4
4
 
5
5
  class TestRakeApplicationOptions < Rake::TestCase
6
6
 
@@ -22,9 +22,7 @@ class TestRakeApplicationOptions < Rake::TestCase
22
22
  end
23
23
 
24
24
  def clear_argv
25
- while ! ARGV.empty?
26
- ARGV.pop
27
- end
25
+ ARGV.pop until ARGV.empty?
28
26
  end
29
27
 
30
28
  def test_default_options
@@ -146,7 +144,11 @@ class TestRakeApplicationOptions < Rake::TestCase
146
144
 
147
145
  def test_rakelib
148
146
  dirs = %w(A B C).join(File::PATH_SEPARATOR)
149
- flags(['--rakelibdir', dirs], ["--rakelibdir=#{dirs}"], ['-R', dirs], ["-R#{dirs}"]) do |opts|
147
+ flags(
148
+ ['--rakelibdir', dirs],
149
+ ["--rakelibdir=#{dirs}"],
150
+ ['-R', dirs],
151
+ ["-R#{dirs}"]) do |opts|
150
152
  assert_equal ['A', 'B', 'C'], opts.rakelib
151
153
  end
152
154
  end
@@ -1,7 +1,36 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
2
  require 'open3'
3
3
 
4
+ class TestBacktraceSuppression < Rake::TestCase
5
+ def test_bin_rake_suppressed
6
+ paths = ["something/bin/rake:12"]
7
+
8
+ actual = Rake::Backtrace.collapse(paths)
9
+
10
+ assert_equal [], actual
11
+ end
12
+
13
+ def test_system_dir_suppressed
14
+ path = RbConfig::CONFIG['rubylibprefix']
15
+ paths = [path + ":12"]
16
+
17
+ actual = Rake::Backtrace.collapse(paths)
18
+
19
+ assert_equal [], actual
20
+ end
21
+
22
+ def test_near_system_dir_isnt_suppressed
23
+ path = RbConfig::CONFIG['rubylibprefix']
24
+ paths = [" " + path + ":12"]
25
+
26
+ actual = Rake::Backtrace.collapse(paths)
27
+
28
+ assert_equal paths, actual
29
+ end
30
+ end
31
+
4
32
  class TestRakeBacktrace < Rake::TestCase
33
+ include RubyRunner
5
34
 
6
35
  def setup
7
36
  super
@@ -10,15 +39,9 @@ class TestRakeBacktrace < Rake::TestCase
10
39
  Dir.pwd =~ Rake::Backtrace::SUPPRESS_PATTERN
11
40
  end
12
41
 
13
- # TODO: factor out similar code in test_rake_functional.rb
14
- def rake(*args)
15
- Open3.popen3(RUBY, "-I", @rake_lib, @rake_exec, *args) { |_, _, err, _|
16
- err.read
17
- }
18
- end
19
-
20
- def invoke(task_name)
21
- rake task_name.to_s
42
+ def invoke(*args)
43
+ rake(*args)
44
+ @err
22
45
  end
23
46
 
24
47
  def test_single_collapse
@@ -28,7 +51,7 @@ class TestRakeBacktrace < Rake::TestCase
28
51
  end
29
52
  }
30
53
 
31
- lines = invoke(:foo).split("\n")
54
+ lines = invoke("foo").split("\n")
32
55
 
33
56
  assert_equal "rake aborted!", lines[0]
34
57
  assert_equal "foooo!", lines[1]
@@ -46,7 +69,7 @@ class TestRakeBacktrace < Rake::TestCase
46
69
  end
47
70
  }
48
71
 
49
- lines = invoke(:foo).split("\n")
72
+ lines = invoke("foo").split("\n")
50
73
 
51
74
  assert_equal "rake aborted!", lines[0]
52
75
  assert_equal "barrr!", lines[1]
@@ -62,12 +85,12 @@ class TestRakeBacktrace < Rake::TestCase
62
85
  end
63
86
  }
64
87
 
65
- lines = rake("baz").split("\n")
88
+ lines = invoke("baz").split("\n")
66
89
  assert_equal "rake aborted!", lines[0]
67
90
  assert_equal "bazzz!", lines[1]
68
91
  assert_something_matches %r!Rakefile!i, lines
69
92
 
70
- lines = rake("--suppress-backtrace", ".ak.file", "baz").split("\n")
93
+ lines = invoke("--suppress-backtrace", ".ak.file", "baz").split("\n")
71
94
  assert_equal "rake aborted!", lines[0]
72
95
  assert_equal "bazzz!", lines[1]
73
96
  refute_match %r!Rakefile!i, lines[2]
@@ -83,7 +106,8 @@ class TestRakeBacktrace < Rake::TestCase
83
106
  return
84
107
  end
85
108
  end
86
- flunk "expected #{pattern.inspect} to match something in:\n #{lines.join("\n ")}"
109
+ flunk "expected #{pattern.inspect} to match something in:\n" +
110
+ "#{lines.join("\n ")}"
87
111
  end
88
112
 
89
113
  end