rake 0.8.1 → 0.8.2

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.

@@ -6,7 +6,7 @@ require 'rake'
6
6
  class TestEarlyTime < Test::Unit::TestCase
7
7
  def test_create
8
8
  early = Rake::EarlyTime.instance
9
- time = Time.mktime(1920, 1, 1, 0, 0, 0)
9
+ time = Time.mktime(1970, 1, 1, 0, 0, 0)
10
10
  assert early <= Time.now
11
11
  assert early < Time.now
12
12
  assert early != Time.now
@@ -21,7 +21,7 @@ class TestEarlyTime < Test::Unit::TestCase
21
21
  end
22
22
 
23
23
  def test_original_time_compare_is_not_messed_up
24
- t1 = Time.mktime(1920, 1, 1, 0, 0, 0)
24
+ t1 = Time.mktime(1970, 1, 1, 0, 0, 0)
25
25
  t2 = Time.now
26
26
  assert t1 < t2
27
27
  assert t2 > t1
@@ -204,12 +204,20 @@ class TestFileList < Test::Unit::TestCase
204
204
 
205
205
  def test_to_s_pending
206
206
  fl = FileList['testdata/abc.*']
207
- assert_equal %{testdata/abc.c testdata/abc.h testdata/abc.x}, fl.to_s
207
+ result = fl.to_s
208
+ assert_match(%r{testdata/abc\.c}, result)
209
+ assert_match(%r{testdata/abc\.h}, result)
210
+ assert_match(%r{testdata/abc\.x}, result)
211
+ assert_match(%r{(testdata/abc\..\b ?){2}}, result)
208
212
  end
209
213
 
210
214
  def test_inspect_pending
211
215
  fl = FileList['testdata/abc.*']
212
- assert_equal %{["testdata/abc.c", "testdata/abc.h", "testdata/abc.x"]}, fl.inspect
216
+ result = fl.inspect
217
+ assert_match(%r{"testdata/abc\.c"}, result)
218
+ assert_match(%r{"testdata/abc\.h"}, result)
219
+ assert_match(%r{"testdata/abc\.x"}, result)
220
+ assert_match(%r|^\[("testdata/abc\..", ){2}"testdata/abc\.."\]$|, result)
213
221
  end
214
222
 
215
223
  def test_sub
@@ -403,12 +411,40 @@ class TestFileList < Test::Unit::TestCase
403
411
  ['a', FileList['testdata/*.c']].flatten.sort
404
412
  end
405
413
 
406
- def test_clone
414
+ def test_clone_and_dup
407
415
  a = FileList['a', 'b', 'c']
408
- b = a.clone
416
+ c = a.clone
417
+ d = a.dup
409
418
  a << 'd'
410
419
  assert_equal ['a', 'b', 'c', 'd'], a
411
- assert_equal ['a', 'b', 'c'], b
420
+ assert_equal ['a', 'b', 'c'], c
421
+ assert_equal ['a', 'b', 'c'], d
422
+ end
423
+
424
+ def test_dup_and_clone_replicate_taint
425
+ a = FileList['a', 'b', 'c']
426
+ a.taint
427
+ c = a.clone
428
+ d = a.dup
429
+ assert c.tainted?, "Clone should be tainted"
430
+ assert d.tainted?, "Dup should be tainted"
431
+ end
432
+
433
+ def test_duped_items_will_thaw
434
+ a = FileList['a', 'b', 'c']
435
+ a.freeze
436
+ d = a.dup
437
+ d << 'more'
438
+ assert_equal ['a', 'b', 'c', 'more'], d
439
+ end
440
+
441
+ def test_cloned_items_stay_frozen
442
+ a = FileList['a', 'b', 'c']
443
+ a.freeze
444
+ c = a.clone
445
+ assert_raise(TypeError, RuntimeError) do
446
+ c << 'more'
447
+ end
412
448
  end
413
449
 
414
450
  def test_array_comparisons
@@ -119,36 +119,37 @@ class TestFileUtils < Test::Unit::TestCase
119
119
  end
120
120
 
121
121
  def test_sh
122
- verbose(false) { sh %{test/shellcommand.rb} }
122
+ verbose(false) { sh %{ruby test/shellcommand.rb} }
123
123
  assert true, "should not fail"
124
124
  end
125
125
 
126
126
  def test_sh_multiple_arguments
127
127
  ENV['RAKE_TEST_SH'] = 'someval'
128
+ expanded = windows? ? '%RAKE_TEST_SH%' : '$RAKE_TEST_SH'
128
129
  # This one gets expanded by the shell
129
- verbose(false) { sh %{test $RAKE_TEST_SH = someval} }
130
+ verbose(false) { sh %{ruby test/check_expansion.rb #{expanded} someval} }
130
131
  assert true, "should not fail"
131
132
  assert_raises(RuntimeError) {
132
133
  # This one does not get expanded
133
- verbose(false) { sh 'test','$RAKE_TEST_SH', '=', 'someval' }
134
+ verbose(false) { sh 'ruby', 'test/check_expansion.rb', expanded, 'someval' }
134
135
  }
135
136
  end
136
137
 
137
138
  def test_sh_failure
138
139
  assert_raises(RuntimeError) {
139
- verbose(false) { sh %{test/shellcommand.rb 1} }
140
+ verbose(false) { sh %{ruby test/shellcommand.rb 1} }
140
141
  }
141
142
  end
142
143
 
143
144
  def test_sh_special_handling
144
145
  count = 0
145
146
  verbose(false) {
146
- sh(%{test/shellcommand.rb}) do |ok, res|
147
+ sh(%{ruby test/shellcommand.rb}) do |ok, res|
147
148
  assert(ok)
148
149
  assert_equal 0, res.exitstatus
149
150
  count += 1
150
151
  end
151
- sh(%{test/shellcommand.rb 1}) do |ok, res|
152
+ sh(%{ruby test/shellcommand.rb 1}) do |ok, res|
152
153
  assert(!ok)
153
154
  assert_equal 1, res.exitstatus
154
155
  count += 1
@@ -178,7 +179,16 @@ class TestFileUtils < Test::Unit::TestCase
178
179
  assert_match(/^test\/shellcommand\.rb$/, out)
179
180
  end
180
181
 
181
- def test_sh_default_verbosity_is_false
182
+ def test_sh_no_verbose
183
+ out = redirect_stderr {
184
+ verbose(false) {
185
+ sh %{test/shellcommand.rb}, :noop=>true
186
+ }
187
+ }
188
+ assert_equal '', out
189
+ end
190
+
191
+ def test_sh_default_is_no_verbose
182
192
  out = redirect_stderr {
183
193
  sh %{test/shellcommand.rb}, :noop=>true
184
194
  }
@@ -190,21 +200,26 @@ class TestFileUtils < Test::Unit::TestCase
190
200
  ENV['RAKE_TEST_RUBY'] = "123"
191
201
  block_run = false
192
202
  # This one gets expanded by the shell
193
- ruby %{-e "exit $RAKE_TEST_RUBY"} do |ok, status|
203
+ env_var = windows? ? '%RAKE_TEST_RUBY%' : '$RAKE_TEST_RUBY'
204
+ ruby %{-e "exit #{env_var}"} do |ok, status| # " (emacs wart)
194
205
  assert(!ok)
195
206
  assert_equal 123, status.exitstatus
196
207
  block_run = true
197
208
  end
198
209
  assert block_run, "The block must be run"
199
210
 
200
- # This one does not get expanded
201
- block_run = false
202
- ruby '-e', 'exit "$RAKE_TEST_RUBY".length' do |ok, status|
203
- assert(!ok)
204
- assert_equal 15, status.exitstatus
205
- block_run = true
211
+ if windows?
212
+ puts "SKIPPING test_ruby/part 2 when in windows"
213
+ else
214
+ # This one does not get expanded
215
+ block_run = false
216
+ ruby '-e', %{exit "#{env_var}".length} do |ok, status| # " (emacs wart)
217
+ assert(!ok)
218
+ assert_equal 15, status.exitstatus
219
+ block_run = true
220
+ end
221
+ assert block_run, "The block must be run"
206
222
  end
207
- assert block_run, "The block must be run"
208
223
  end
209
224
  end
210
225
 
@@ -227,4 +242,9 @@ class TestFileUtils < Test::Unit::TestCase
227
242
  ensure
228
243
  $stderr = old_err
229
244
  end
245
+
246
+ def windows?
247
+ ! File::ALT_SEPARATOR.nil?
248
+ end
249
+
230
250
  end
@@ -7,7 +7,7 @@ require 'rake/loaders/makefile'
7
7
  class TestMakefileLoader < Test::Unit::TestCase
8
8
  include Rake
9
9
 
10
- def test_create
10
+ def test_parse
11
11
  Task.clear
12
12
  loader = Rake::MakefileLoader.new
13
13
  loader.load("test/data/sample.mf")
@@ -18,6 +18,8 @@ class TestMakefileLoader < Test::Unit::TestCase
18
18
  assert_equal %w(b1 b2 b3 b4 b5 b6 b7).sort, Task['b'].prerequisites.sort
19
19
  assert_equal %w(c1).sort, Task['c'].prerequisites.sort
20
20
  assert_equal %w(d1 d2).sort, Task['d'].prerequisites.sort
21
- assert_equal 4, Task.tasks.size
21
+ assert_equal %w(e1 f1).sort, Task['e'].prerequisites.sort
22
+ assert_equal %w(e1 f1).sort, Task['f'].prerequisites.sort
23
+ assert_equal 6, Task.tasks.size
22
24
  end
23
25
  end
@@ -8,8 +8,15 @@ class TestRake < Test::Unit::TestCase
8
8
  assert_equal ['a'], alldirs('a')
9
9
  assert_equal ['a/b', 'a'], alldirs('a/b')
10
10
  assert_equal ['/a/b', '/a', '/'], alldirs('/a/b')
11
- assert_equal ['c:/a/b', 'c:/a', 'c:'], alldirs('c:/a/b')
12
- assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b')
11
+ if File.dirname("c:/foo") == "c:"
12
+ # Under Unix
13
+ assert_equal ['c:/a/b', 'c:/a', 'c:'], alldirs('c:/a/b')
14
+ assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b')
15
+ else
16
+ # Under Windows
17
+ assert_equal ['c:/a/b', 'c:/a', 'c:/'], alldirs('c:/a/b')
18
+ assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b')
19
+ end
13
20
  end
14
21
 
15
22
  def alldirs(fn)
@@ -222,6 +222,22 @@ class TestRules < Test::Unit::TestCase
222
222
  assert_equal [], @runs
223
223
  end
224
224
 
225
+ def test_rule_with_two_sources_builds_both_sources
226
+ task 'x.aa'
227
+ task 'x.bb'
228
+ rule '.a' => '.aa' do
229
+ @runs << "A"
230
+ end
231
+ rule '.b' => '.bb' do
232
+ @runs << "B"
233
+ end
234
+ rule ".c" => ['.a', '.b'] do
235
+ @runs << "C"
236
+ end
237
+ Task["x.c"].invoke
238
+ assert_equal ["A", "B", "C"], @runs.sort
239
+ end
240
+
225
241
  def test_second_rule_runs_when_first_rule_doesnt
226
242
  create_timed_files(OBJFILE, SRCFILE)
227
243
  delete_file(SRCFILE2)
@@ -61,7 +61,7 @@ class TestTaskArguments < Test::Unit::TestCase
61
61
  def test_creating_new_argument_scopes
62
62
  parent = Rake::TaskArguments.new(['p'], [1])
63
63
  child = parent.new_scope(['c', 'p'])
64
- assert_equal({:c => nil, :p=>1}, child.to_hash)
64
+ assert_equal({:p=>1}, child.to_hash)
65
65
  assert_equal 1, child.p
66
66
  assert_equal 1, child["p"]
67
67
  assert_equal 1, child[:p]
@@ -73,4 +73,17 @@ class TestTaskArguments < Test::Unit::TestCase
73
73
  child = Rake::TaskArguments.new(['aa'], [2], parent)
74
74
  assert_equal 2, child.aa
75
75
  end
76
+
77
+ def test_default_arguments_values_can_be_merged
78
+ ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"])
79
+ ta.with_defaults({ :aa => 'default_val' })
80
+ assert_equal 'default_val', ta[:aa]
81
+ assert_equal 'original_val', ta[:bb]
82
+ end
83
+
84
+ def test_default_arguements_that_dont_match_names_are_ignored
85
+ ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"])
86
+ ta.with_defaults({ "cc" => "default_val" })
87
+ assert_nil ta[:cc]
88
+ end
76
89
  end
@@ -53,7 +53,7 @@ class TestTaskManager < Test::Unit::TestCase
53
53
  assert_equal ["fn"], @tm.tasks.collect { |t| t.name }
54
54
  end
55
55
 
56
- def testS_namespace_yields_same_namespace_as_returned
56
+ def test_namespace_yields_same_namespace_as_returned
57
57
  yielded_namespace = nil
58
58
  returned_namespace = @tm.in_namespace("x") do |ns|
59
59
  yielded_namespace = ns
@@ -146,3 +146,25 @@ class TestTaskManager < Test::Unit::TestCase
146
146
  end
147
147
 
148
148
  end
149
+
150
+ class TestTaskManagerArgumentResolution < Test::Unit::TestCase
151
+ def test_good_arg_patterns
152
+ assert_equal [:t, [], []], task(:t)
153
+ assert_equal [:t, [], [:x]], task(:t => :x)
154
+ assert_equal [:t, [], [:x, :y]], task(:t => [:x, :y])
155
+
156
+ assert_equal [:t, [:a, :b], []], task(:t, :a, :b)
157
+ assert_equal [:t, [], [:x]], task(:t, :needs => :x)
158
+ assert_equal [:t, [:a, :b], [:x]], task(:t, :a, :b, :needs => :x)
159
+ assert_equal [:t, [:a, :b], [:x, :y]], task(:t, :a, :b, :needs => [:x, :y])
160
+
161
+ assert_equal [:t, [:a, :b], []], task(:t, [:a, :b])
162
+ assert_equal [:t, [:a, :b], [:x]], task(:t, [:a, :b] => :x)
163
+ assert_equal [:t, [:a, :b], [:x, :y]], task(:t, [:a, :b] => [:x, :y])
164
+ end
165
+
166
+ def task(*args)
167
+ tm = TaskManager.new
168
+ tm.resolve_args(args)
169
+ end
170
+ end
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'rake/tasklib'
5
+
6
+
7
+ class TestTaskLib < Test::Unit::TestCase
8
+ def test_paste
9
+ tl = Rake::TaskLib.new
10
+ assert_equal :ab, tl.paste(:a, :b)
11
+ end
12
+ end
@@ -6,20 +6,10 @@ require 'rake'
6
6
  require 'test/filecreation'
7
7
  require 'test/capture_stdout'
8
8
 
9
-
10
- module Interning
11
- private
12
-
13
- def intern(name, *args)
14
- Rake.application.define_task(Rake::Task, name, *args)
15
- end
16
- end
17
-
18
9
  ######################################################################
19
10
  class TestTask < Test::Unit::TestCase
20
11
  include CaptureStdout
21
12
  include Rake
22
- include Interning
23
13
 
24
14
  def setup
25
15
  Task.clear
@@ -27,10 +17,9 @@ class TestTask < Test::Unit::TestCase
27
17
 
28
18
  def test_create
29
19
  arg = nil
30
- t = intern(:name).enhance { |task| arg = task; 1234 }
20
+ t = task(:name) { |task| arg = task; 1234 }
31
21
  assert_equal "name", t.name
32
22
  assert_equal [], t.prerequisites
33
- assert t.prerequisites.is_a?(FileList)
34
23
  assert t.needed?
35
24
  t.execute(0)
36
25
  assert_equal t, arg
@@ -39,26 +28,26 @@ class TestTask < Test::Unit::TestCase
39
28
  end
40
29
 
41
30
  def test_inspect
42
- t = intern(:foo).enhance([:bar, :baz])
31
+ t = task(:foo, :needs => [:bar, :baz])
43
32
  assert_equal "<Rake::Task foo => [bar, baz]>", t.inspect
44
33
  end
45
34
 
46
35
  def test_invoke
47
36
  runlist = []
48
- t1 = intern(:t1).enhance([:t2, :t3]) { |t| runlist << t.name; 3321 }
49
- t2 = intern(:t2).enhance { |t| runlist << t.name }
50
- t3 = intern(:t3).enhance { |t| runlist << t.name }
51
- assert_equal [:t2, :t3], t1.prerequisites
37
+ t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
38
+ t2 = task(:t2) { |t| runlist << t.name }
39
+ t3 = task(:t3) { |t| runlist << t.name }
40
+ assert_equal ["t2", "t3"], t1.prerequisites
52
41
  t1.invoke
53
42
  assert_equal ["t2", "t3", "t1"], runlist
54
43
  end
55
44
 
56
45
  def test_invoke_with_circular_dependencies
57
46
  runlist = []
58
- t1 = intern(:t1).enhance([:t2]) { |t| runlist << t.name; 3321 }
59
- t2 = intern(:t2).enhance([:t1]) { |t| runlist << t.name }
60
- assert_equal [:t2], t1.prerequisites
61
- assert_equal [:t1], t2.prerequisites
47
+ t1 = task(:t1 => [:t2]) { |t| runlist << t.name; 3321 }
48
+ t2 = task(:t2 => [:t1]) { |t| runlist << t.name }
49
+ assert_equal ["t2"], t1.prerequisites
50
+ assert_equal ["t1"], t2.prerequisites
62
51
  ex = assert_raise RuntimeError do
63
52
  t1.invoke
64
53
  end
@@ -69,7 +58,7 @@ class TestTask < Test::Unit::TestCase
69
58
  def test_dry_run_prevents_actions
70
59
  Rake.application.options.dryrun = true
71
60
  runlist = []
72
- t1 = intern(:t1).enhance { |t| runlist << t.name; 3321 }
61
+ t1 = task(:t1) { |t| runlist << t.name; 3321 }
73
62
  out = capture_stdout { t1.invoke }
74
63
  assert_match(/execute .*t1/i, out)
75
64
  assert_match(/dry run/i, out)
@@ -81,7 +70,7 @@ class TestTask < Test::Unit::TestCase
81
70
 
82
71
  def test_tasks_can_be_traced
83
72
  Rake.application.options.trace = true
84
- t1 = intern(:t1) { |t| runlist << t.name; 3321 }
73
+ t1 = task(:t1)
85
74
  out = capture_stdout {
86
75
  t1.invoke
87
76
  }
@@ -93,13 +82,42 @@ class TestTask < Test::Unit::TestCase
93
82
 
94
83
  def test_no_double_invoke
95
84
  runlist = []
96
- t1 = intern(:t1).enhance([:t2, :t3]) { |t| runlist << t.name; 3321 }
97
- t2 = intern(:t2).enhance([:t3]) { |t| runlist << t.name }
98
- t3 = intern(:t3).enhance { |t| runlist << t.name }
85
+ t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
86
+ t2 = task(:t2 => [:t3]) { |t| runlist << t.name }
87
+ t3 = task(:t3) { |t| runlist << t.name }
99
88
  t1.invoke
100
89
  assert_equal ["t3", "t2", "t1"], runlist
101
90
  end
102
91
 
92
+ def test_can_double_invoke_with_reenable
93
+ runlist = []
94
+ t1 = task(:t1) { |t| runlist << t.name }
95
+ t1.invoke
96
+ t1.reenable
97
+ t1.invoke
98
+ assert_equal ["t1", "t1"], runlist
99
+ end
100
+
101
+ def test_clear
102
+ t = task("t" => "a") { }
103
+ t.clear
104
+ assert t.prerequisites.empty?, "prerequisites should be empty"
105
+ assert t.actions.empty?, "actions should be empty"
106
+ end
107
+
108
+ def test_clear_prerequisites
109
+ t = task("t" => ["a", "b"])
110
+ assert_equal ['a', 'b'], t.prerequisites
111
+ t.clear_prerequisites
112
+ assert_equal [], t.prerequisites
113
+ end
114
+
115
+ def test_clear_actions
116
+ t = task("t") { }
117
+ t.clear_actions
118
+ assert t.actions.empty?, "actions should be empty"
119
+ end
120
+
103
121
  def test_find
104
122
  task :tfind
105
123
  assert_equal "tfind", Task[:tfind].name
@@ -155,9 +173,9 @@ class TestTask < Test::Unit::TestCase
155
173
  end
156
174
 
157
175
  def test_investigation_output
158
- t1 = intern(:t1).enhance([:t2, :t3]) { |t| runlist << t.name; 3321 }
159
- intern(:t2)
160
- intern(:t3)
176
+ t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
177
+ task(:t2)
178
+ task(:t3)
161
179
  out = t1.investigation
162
180
  assert_match(/class:\s*Rake::Task/, out)
163
181
  assert_match(/needed:\s*true/, out)
@@ -173,7 +191,7 @@ class TestTask < Test::Unit::TestCase
173
191
  name -- Name of task to execute.
174
192
  rev -- Software revision to use.
175
193
  }
176
- t = intern(:t, :name, :rev)
194
+ t = task(:t, :name, :rev)
177
195
  assert_equal "[name,rev]", t.arg_description
178
196
  assert_equal "This is a comment.", t.comment
179
197
  assert_match(/^\s*name -- Name/, t.full_comment)
@@ -183,14 +201,14 @@ class TestTask < Test::Unit::TestCase
183
201
 
184
202
  def test_multiple_comments
185
203
  desc "line one"
186
- t = intern(:t)
204
+ t = task(:t)
187
205
  desc "line two"
188
- intern(:t)
206
+ task(:t)
189
207
  assert_equal "line one / line two", t.comment
190
208
  end
191
209
 
192
210
  def test_settable_comments
193
- t = intern(:t)
211
+ t = task(:t)
194
212
  t.comment = "HI"
195
213
  assert_equal "HI", t.comment
196
214
  end
@@ -200,7 +218,6 @@ end
200
218
  class TestTaskWithArguments < Test::Unit::TestCase
201
219
  include CaptureStdout
202
220
  include Rake
203
- include Interning
204
221
 
205
222
  def setup
206
223
  Task.clear
@@ -244,9 +261,7 @@ class TestTaskWithArguments < Test::Unit::TestCase
244
261
  end
245
262
 
246
263
  def test_arg_list_is_empty_if_no_args_given
247
- t = intern(:t).enhance do |tt, args|
248
- assert_equal({}, args.to_hash)
249
- end
264
+ t = task(:t) { |tt, args| assert_equal({}, args.to_hash) }
250
265
  t.invoke(1, 2, 3)
251
266
  end
252
267
 
@@ -265,7 +280,7 @@ class TestTaskWithArguments < Test::Unit::TestCase
265
280
 
266
281
  def test_actions_of_various_arity_are_ok_with_args
267
282
  notes = []
268
- t = intern(:t, :x).enhance do
283
+ t = task(:t, :x) do
269
284
  notes << :a
270
285
  end
271
286
  t.enhance do | |
@@ -285,16 +300,16 @@ class TestTaskWithArguments < Test::Unit::TestCase
285
300
  end
286
301
 
287
302
  def test_arguments_are_passed_to_block
288
- t = intern(:t, :a, :b).enhance { |tt, args|
303
+ t = task(:t, :a, :b) { |tt, args|
289
304
  assert_equal( { :a => 1, :b => 2 }, args.to_hash )
290
305
  }
291
306
  t.invoke(1, 2)
292
307
  end
293
308
 
294
309
  def test_extra_parameters_are_ignored
295
- t = intern(:t, :a).enhance { |tt, args|
310
+ t = task(:t, :a) { |tt, args|
296
311
  assert_equal 1, args.a
297
- assert_nil args[2]
312
+ assert_nil args.b
298
313
  }
299
314
  t.invoke(1, 2)
300
315
  end
@@ -315,13 +330,13 @@ class TestTaskWithArguments < Test::Unit::TestCase
315
330
  end
316
331
 
317
332
  def test_block_with_no_parameters_is_ok
318
- t = intern(:t).enhance { }
333
+ t = task(:t) { }
319
334
  t.invoke(1, 2)
320
335
  end
321
336
 
322
337
  def test_name_with_args
323
338
  desc "T"
324
- t = intern(:tt, :a, :b)
339
+ t = task(:tt, :a, :b)
325
340
  assert_equal "tt", t.name
326
341
  assert_equal "T", t.comment
327
342
  assert_equal "[a,b]", t.arg_description
@@ -331,26 +346,26 @@ class TestTaskWithArguments < Test::Unit::TestCase
331
346
 
332
347
  def test_named_args_are_passed_to_prereqs
333
348
  value = nil
334
- pre = intern(:pre, :rev).enhance { |t, args| value = args.rev }
335
- t = intern(:t, :name, :rev).enhance([:pre])
349
+ pre = task(:pre, :rev) { |t, args| value = args.rev }
350
+ t = task(:t, :name, :rev, :needs => [:pre])
336
351
  t.invoke("bill", "1.2")
337
352
  assert_equal "1.2", value
338
353
  end
339
354
 
340
355
  def test_args_not_passed_if_no_prereq_names
341
- pre = intern(:pre).enhance { |t, args|
356
+ pre = task(:pre) { |t, args|
342
357
  assert_equal({}, args.to_hash)
343
358
  assert_equal "bill", args.name
344
359
  }
345
- t = intern(:t, :name, :rev).enhance([:pre])
360
+ t = task(:t, :name, :rev, :needs => [:pre])
346
361
  t.invoke("bill", "1.2")
347
362
  end
348
363
 
349
364
  def test_args_not_passed_if_no_arg_names
350
- pre = intern(:pre, :rev).enhance { |t, args|
351
- assert_equal({ :rev => nil }, args.to_hash)
365
+ pre = task(:pre, :rev) { |t, args|
366
+ assert_equal({}, args.to_hash)
352
367
  }
353
- t = intern(:t).enhance([:pre])
368
+ t = task(:t, :needs => [:pre])
354
369
  t.invoke("bill", "1.2")
355
370
  end
356
371
  end