rake 0.8.0 → 0.8.7

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 (62) hide show
  1. data/CHANGES +113 -2
  2. data/README +86 -132
  3. data/Rakefile +41 -13
  4. data/bin/rake +0 -0
  5. data/doc/command_line_usage.rdoc +102 -0
  6. data/doc/rakefile.rdoc +126 -3
  7. data/doc/release_notes/rake-0.7.3.rdoc +0 -0
  8. data/doc/release_notes/rake-0.8.0.rdoc +114 -0
  9. data/doc/release_notes/rake-0.8.2.rdoc +165 -0
  10. data/doc/release_notes/rake-0.8.3.rdoc +112 -0
  11. data/doc/release_notes/rake-0.8.4.rdoc +147 -0
  12. data/doc/release_notes/rake-0.8.5.rdoc +53 -0
  13. data/doc/release_notes/rake-0.8.6.rdoc +55 -0
  14. data/doc/release_notes/rake-0.8.7.rdoc +55 -0
  15. data/lib/rake/alt_system.rb +108 -0
  16. data/lib/rake/contrib/ftptools.rb +24 -10
  17. data/lib/rake/contrib/publisher.rb +1 -1
  18. data/lib/rake/contrib/sys.rb +5 -2
  19. data/lib/rake/gempackagetask.rb +0 -6
  20. data/lib/rake/loaders/makefile.rb +17 -15
  21. data/lib/rake/rdoctask.rb +83 -21
  22. data/lib/rake/ruby182_test_unit_fix.rb +0 -0
  23. data/lib/rake/tasklib.rb +8 -3
  24. data/lib/rake/testtask.rb +1 -1
  25. data/lib/rake/win32.rb +55 -0
  26. data/lib/rake.rb +490 -225
  27. data/test/check_expansion.rb +5 -0
  28. data/test/check_no_expansion.rb +5 -0
  29. data/test/data/file_creation_task/Rakefile +4 -1
  30. data/test/data/sample.mf +6 -1
  31. data/test/filecreation.rb +0 -2
  32. data/test/functional.rb +1 -1
  33. data/test/in_environment.rb +30 -0
  34. data/test/rake_test_setup.rb +21 -2
  35. data/test/session_functional.rb +109 -33
  36. data/test/shellcommand.rb +0 -0
  37. data/test/test_application.rb +269 -96
  38. data/test/test_definitions.rb +4 -1
  39. data/test/test_earlytime.rb +2 -2
  40. data/test/test_file_task.rb +20 -16
  41. data/test/test_filelist.rb +48 -7
  42. data/test/test_fileutils.rb +59 -38
  43. data/test/test_ftp.rb +5 -1
  44. data/test/test_invocation_chain.rb +8 -2
  45. data/test/test_makefile_loader.rb +5 -2
  46. data/test/test_namespace.rb +30 -11
  47. data/test/test_package_task.rb +3 -1
  48. data/test/test_pathmap.rb +3 -2
  49. data/test/test_pseudo_status.rb +26 -0
  50. data/test/test_rake.rb +9 -2
  51. data/test/test_rdoc_task.rb +88 -0
  52. data/test/test_require.rb +3 -1
  53. data/test/test_rules.rb +25 -7
  54. data/test/test_task_arguments.rb +14 -1
  55. data/test/test_task_manager.rb +27 -2
  56. data/test/test_tasklib.rb +12 -0
  57. data/test/test_tasks.rb +72 -54
  58. data/test/test_test_task.rb +2 -0
  59. data/test/test_top_level_functions.rb +4 -2
  60. data/test/test_win32.rb +72 -0
  61. metadata +99 -75
  62. /data/test/contrib/{testsys.rb → test_sys.rb} +0 -0
data/test/test_rules.rb CHANGED
@@ -4,11 +4,13 @@ require 'test/unit'
4
4
  require 'fileutils'
5
5
  require 'rake'
6
6
  require 'test/filecreation'
7
+ require 'test/rake_test_setup'
7
8
 
8
9
  ######################################################################
9
10
  class TestRules < Test::Unit::TestCase
10
11
  include Rake
11
12
  include FileCreation
13
+ include TestMethods
12
14
 
13
15
  SRCFILE = "testdata/abc.c"
14
16
  SRCFILE2 = "testdata/xyz.c"
@@ -23,7 +25,7 @@ class TestRules < Test::Unit::TestCase
23
25
  end
24
26
 
25
27
  def teardown
26
- FileList['testdata/*'].each do |f| rm_r(f, :verbose=>false) end
28
+ FileList['testdata/*'].uniq.each do |f| rm_r(f, :verbose=>false) end
27
29
  end
28
30
 
29
31
  def test_multiple_rules1
@@ -190,8 +192,8 @@ class TestRules < Test::Unit::TestCase
190
192
  rule '.o' => ['.c'] do |t|
191
193
  @runs << t.name
192
194
  end
193
- assert_raises(RuntimeError) { Task['testdata/x.obj'].invoke }
194
- assert_raises(RuntimeError) { Task['testdata/x.xyo'].invoke }
195
+ assert_exception(RuntimeError) { Task['testdata/x.obj'].invoke }
196
+ assert_exception(RuntimeError) { Task['testdata/x.xyo'].invoke }
195
197
  end
196
198
 
197
199
  def test_rule_rebuilds_obj_when_source_is_newer
@@ -222,6 +224,22 @@ class TestRules < Test::Unit::TestCase
222
224
  assert_equal [], @runs
223
225
  end
224
226
 
227
+ def test_rule_with_two_sources_builds_both_sources
228
+ task 'x.aa'
229
+ task 'x.bb'
230
+ rule '.a' => '.aa' do
231
+ @runs << "A"
232
+ end
233
+ rule '.b' => '.bb' do
234
+ @runs << "B"
235
+ end
236
+ rule ".c" => ['.a', '.b'] do
237
+ @runs << "C"
238
+ end
239
+ Task["x.c"].invoke
240
+ assert_equal ["A", "B", "C"], @runs.sort
241
+ end
242
+
225
243
  def test_second_rule_runs_when_first_rule_doesnt
226
244
  create_timed_files(OBJFILE, SRCFILE)
227
245
  delete_file(SRCFILE2)
@@ -261,7 +279,7 @@ class TestRules < Test::Unit::TestCase
261
279
 
262
280
  def test_rule_with_proc_dependent_will_trigger
263
281
  ran = false
264
- File.makedirs("testdata/src/jw")
282
+ mkdir_p("testdata/src/jw")
265
283
  create_file("testdata/src/jw/X.java")
266
284
  rule %r(classes/.*\.class) => [
267
285
  proc { |fn| fn.pathmap("%{classes,testdata/src}d/%n.java") }
@@ -278,7 +296,7 @@ class TestRules < Test::Unit::TestCase
278
296
 
279
297
  def test_proc_returning_lists_are_flattened_into_prereqs
280
298
  ran = false
281
- File.makedirs("testdata/flatten")
299
+ mkdir_p("testdata/flatten")
282
300
  create_file("testdata/flatten/a.txt")
283
301
  task 'testdata/flatten/b.data' do |t|
284
302
  ran = true
@@ -316,7 +334,7 @@ class TestRules < Test::Unit::TestCase
316
334
  rule ".#{letter}" => ".#{prev}" do |t| puts "#{t.name}" end
317
335
  prev = letter
318
336
  end
319
- ex = assert_raises(Rake::RuleRecursionOverflowError) {
337
+ ex = assert_exception(Rake::RuleRecursionOverflowError) {
320
338
  Task["testdata/a.z"].invoke
321
339
  }
322
340
  assert_match(/a\.z => testdata\/a.y/, ex.message)
@@ -324,7 +342,7 @@ class TestRules < Test::Unit::TestCase
324
342
 
325
343
  def test_rules_with_bad_dependents_will_fail
326
344
  rule "a" => [ 1 ] do |t| puts t.name end
327
- assert_raise(RuntimeError) do Task['a'].invoke end
345
+ assert_exception(RuntimeError) do Task['a'].invoke end
328
346
  end
329
347
 
330
348
  end
@@ -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
@@ -2,12 +2,15 @@
2
2
 
3
3
  require 'test/unit'
4
4
  require 'rake'
5
+ require 'test/rake_test_setup'
5
6
 
6
7
  class TaskManager
7
8
  include Rake::TaskManager
8
9
  end
9
10
 
10
11
  class TestTaskManager < Test::Unit::TestCase
12
+ include TestMethods
13
+
11
14
  def setup
12
15
  @tm = TaskManager.new
13
16
  end
@@ -53,7 +56,7 @@ class TestTaskManager < Test::Unit::TestCase
53
56
  assert_equal ["fn"], @tm.tasks.collect { |t| t.name }
54
57
  end
55
58
 
56
- def testS_namespace_yields_same_namespace_as_returned
59
+ def test_namespace_yields_same_namespace_as_returned
57
60
  yielded_namespace = nil
58
61
  returned_namespace = @tm.in_namespace("x") do |ns|
59
62
  yielded_namespace = ns
@@ -68,7 +71,7 @@ class TestTaskManager < Test::Unit::TestCase
68
71
  end
69
72
 
70
73
  def test_name_lookup_with_nonexistent_task
71
- assert_raise(RuntimeError) {
74
+ assert_exception(RuntimeError) {
72
75
  t = @tm["DOES NOT EXIST"]
73
76
  }
74
77
  end
@@ -146,3 +149,25 @@ class TestTaskManager < Test::Unit::TestCase
146
149
  end
147
150
 
148
151
  end
152
+
153
+ class TestTaskManagerArgumentResolution < Test::Unit::TestCase
154
+ def test_good_arg_patterns
155
+ assert_equal [:t, [], []], task(:t)
156
+ assert_equal [:t, [], [:x]], task(:t => :x)
157
+ assert_equal [:t, [], [:x, :y]], task(:t => [:x, :y])
158
+
159
+ assert_equal [:t, [:a, :b], []], task(:t, :a, :b)
160
+ assert_equal [:t, [], [:x]], task(:t, :needs => :x)
161
+ assert_equal [:t, [:a, :b], [:x]], task(:t, :a, :b, :needs => :x)
162
+ assert_equal [:t, [:a, :b], [:x, :y]], task(:t, :a, :b, :needs => [:x, :y])
163
+
164
+ assert_equal [:t, [:a, :b], []], task(:t, [:a, :b])
165
+ assert_equal [:t, [:a, :b], [:x]], task(:t, [:a, :b] => :x)
166
+ assert_equal [:t, [:a, :b], [:x, :y]], task(:t, [:a, :b] => [:x, :y])
167
+ end
168
+
169
+ def task(*args)
170
+ tm = TaskManager.new
171
+ tm.resolve_args(args)
172
+ end
173
+ 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
data/test/test_tasks.rb CHANGED
@@ -5,21 +5,13 @@ require 'fileutils'
5
5
  require 'rake'
6
6
  require 'test/filecreation'
7
7
  require 'test/capture_stdout'
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
8
+ require 'test/rake_test_setup'
17
9
 
18
10
  ######################################################################
19
11
  class TestTask < Test::Unit::TestCase
20
12
  include CaptureStdout
21
13
  include Rake
22
- include Interning
14
+ include TestMethods
23
15
 
24
16
  def setup
25
17
  Task.clear
@@ -27,10 +19,9 @@ class TestTask < Test::Unit::TestCase
27
19
 
28
20
  def test_create
29
21
  arg = nil
30
- t = intern(:name).enhance { |task| arg = task; 1234 }
22
+ t = task(:name) { |task| arg = task; 1234 }
31
23
  assert_equal "name", t.name
32
24
  assert_equal [], t.prerequisites
33
- assert t.prerequisites.is_a?(FileList)
34
25
  assert t.needed?
35
26
  t.execute(0)
36
27
  assert_equal t, arg
@@ -39,27 +30,27 @@ class TestTask < Test::Unit::TestCase
39
30
  end
40
31
 
41
32
  def test_inspect
42
- t = intern(:foo).enhance([:bar, :baz])
33
+ t = task(:foo, :needs => [:bar, :baz])
43
34
  assert_equal "<Rake::Task foo => [bar, baz]>", t.inspect
44
35
  end
45
36
 
46
37
  def test_invoke
47
38
  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
39
+ t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
40
+ t2 = task(:t2) { |t| runlist << t.name }
41
+ t3 = task(:t3) { |t| runlist << t.name }
42
+ assert_equal ["t2", "t3"], t1.prerequisites
52
43
  t1.invoke
53
44
  assert_equal ["t2", "t3", "t1"], runlist
54
45
  end
55
46
 
56
47
  def test_invoke_with_circular_dependencies
57
48
  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
62
- ex = assert_raise RuntimeError do
49
+ t1 = task(:t1 => [:t2]) { |t| runlist << t.name; 3321 }
50
+ t2 = task(:t2 => [:t1]) { |t| runlist << t.name }
51
+ assert_equal ["t2"], t1.prerequisites
52
+ assert_equal ["t1"], t2.prerequisites
53
+ ex = assert_exception RuntimeError do
63
54
  t1.invoke
64
55
  end
65
56
  assert_match(/circular dependency/i, ex.message)
@@ -69,7 +60,7 @@ class TestTask < Test::Unit::TestCase
69
60
  def test_dry_run_prevents_actions
70
61
  Rake.application.options.dryrun = true
71
62
  runlist = []
72
- t1 = intern(:t1).enhance { |t| runlist << t.name; 3321 }
63
+ t1 = task(:t1) { |t| runlist << t.name; 3321 }
73
64
  out = capture_stdout { t1.invoke }
74
65
  assert_match(/execute .*t1/i, out)
75
66
  assert_match(/dry run/i, out)
@@ -81,7 +72,7 @@ class TestTask < Test::Unit::TestCase
81
72
 
82
73
  def test_tasks_can_be_traced
83
74
  Rake.application.options.trace = true
84
- t1 = intern(:t1) { |t| runlist << t.name; 3321 }
75
+ t1 = task(:t1)
85
76
  out = capture_stdout {
86
77
  t1.invoke
87
78
  }
@@ -93,17 +84,46 @@ class TestTask < Test::Unit::TestCase
93
84
 
94
85
  def test_no_double_invoke
95
86
  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 }
87
+ t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
88
+ t2 = task(:t2 => [:t3]) { |t| runlist << t.name }
89
+ t3 = task(:t3) { |t| runlist << t.name }
99
90
  t1.invoke
100
91
  assert_equal ["t3", "t2", "t1"], runlist
101
92
  end
102
93
 
94
+ def test_can_double_invoke_with_reenable
95
+ runlist = []
96
+ t1 = task(:t1) { |t| runlist << t.name }
97
+ t1.invoke
98
+ t1.reenable
99
+ t1.invoke
100
+ assert_equal ["t1", "t1"], runlist
101
+ end
102
+
103
+ def test_clear
104
+ t = task("t" => "a") { }
105
+ t.clear
106
+ assert t.prerequisites.empty?, "prerequisites should be empty"
107
+ assert t.actions.empty?, "actions should be empty"
108
+ end
109
+
110
+ def test_clear_prerequisites
111
+ t = task("t" => ["a", "b"])
112
+ assert_equal ['a', 'b'], t.prerequisites
113
+ t.clear_prerequisites
114
+ assert_equal [], t.prerequisites
115
+ end
116
+
117
+ def test_clear_actions
118
+ t = task("t") { }
119
+ t.clear_actions
120
+ assert t.actions.empty?, "actions should be empty"
121
+ end
122
+
103
123
  def test_find
104
124
  task :tfind
105
125
  assert_equal "tfind", Task[:tfind].name
106
- ex = assert_raises(RuntimeError) { Task[:leaves] }
126
+ ex = assert_exception(RuntimeError) { Task[:leaves] }
107
127
  assert_equal "Don't know how to build task 'leaves'", ex.message
108
128
  end
109
129
 
@@ -155,13 +175,13 @@ class TestTask < Test::Unit::TestCase
155
175
  end
156
176
 
157
177
  def test_investigation_output
158
- t1 = intern(:t1).enhance([:t2, :t3]) { |t| runlist << t.name; 3321 }
159
- intern(:t2)
160
- intern(:t3)
178
+ t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
179
+ task(:t2)
180
+ task(:t3)
161
181
  out = t1.investigation
162
182
  assert_match(/class:\s*Rake::Task/, out)
163
183
  assert_match(/needed:\s*true/, out)
164
- assert_match(/pre-requisites:\s*--t2/, out)
184
+ assert_match(/pre-requisites:\s*--t[23]/, out)
165
185
  end
166
186
 
167
187
 
@@ -173,7 +193,7 @@ class TestTask < Test::Unit::TestCase
173
193
  name -- Name of task to execute.
174
194
  rev -- Software revision to use.
175
195
  }
176
- t = intern(:t, :name, :rev)
196
+ t = task(:t, :name, :rev)
177
197
  assert_equal "[name,rev]", t.arg_description
178
198
  assert_equal "This is a comment.", t.comment
179
199
  assert_match(/^\s*name -- Name/, t.full_comment)
@@ -183,14 +203,14 @@ class TestTask < Test::Unit::TestCase
183
203
 
184
204
  def test_multiple_comments
185
205
  desc "line one"
186
- t = intern(:t)
206
+ t = task(:t)
187
207
  desc "line two"
188
- intern(:t)
208
+ task(:t)
189
209
  assert_equal "line one / line two", t.comment
190
210
  end
191
211
 
192
212
  def test_settable_comments
193
- t = intern(:t)
213
+ t = task(:t)
194
214
  t.comment = "HI"
195
215
  assert_equal "HI", t.comment
196
216
  end
@@ -200,7 +220,7 @@ end
200
220
  class TestTaskWithArguments < Test::Unit::TestCase
201
221
  include CaptureStdout
202
222
  include Rake
203
- include Interning
223
+ include TestMethods
204
224
 
205
225
  def setup
206
226
  Task.clear
@@ -238,15 +258,13 @@ class TestTaskWithArguments < Test::Unit::TestCase
238
258
  end
239
259
 
240
260
  def test_illegal_keys_in_task_name_hash
241
- assert_raise RuntimeError do
261
+ assert_exception RuntimeError do
242
262
  t = task(:t, :x, :y => 1, :needs => [:pre])
243
263
  end
244
264
  end
245
265
 
246
266
  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
267
+ t = task(:t) { |tt, args| assert_equal({}, args.to_hash) }
250
268
  t.invoke(1, 2, 3)
251
269
  end
252
270
 
@@ -265,7 +283,7 @@ class TestTaskWithArguments < Test::Unit::TestCase
265
283
 
266
284
  def test_actions_of_various_arity_are_ok_with_args
267
285
  notes = []
268
- t = intern(:t, :x).enhance do
286
+ t = task(:t, :x) do
269
287
  notes << :a
270
288
  end
271
289
  t.enhance do | |
@@ -285,16 +303,16 @@ class TestTaskWithArguments < Test::Unit::TestCase
285
303
  end
286
304
 
287
305
  def test_arguments_are_passed_to_block
288
- t = intern(:t, :a, :b).enhance { |tt, args|
306
+ t = task(:t, :a, :b) { |tt, args|
289
307
  assert_equal( { :a => 1, :b => 2 }, args.to_hash )
290
308
  }
291
309
  t.invoke(1, 2)
292
310
  end
293
311
 
294
312
  def test_extra_parameters_are_ignored
295
- t = intern(:t, :a).enhance { |tt, args|
313
+ t = task(:t, :a) { |tt, args|
296
314
  assert_equal 1, args.a
297
- assert_nil args[2]
315
+ assert_nil args.b
298
316
  }
299
317
  t.invoke(1, 2)
300
318
  end
@@ -315,13 +333,13 @@ class TestTaskWithArguments < Test::Unit::TestCase
315
333
  end
316
334
 
317
335
  def test_block_with_no_parameters_is_ok
318
- t = intern(:t).enhance { }
336
+ t = task(:t) { }
319
337
  t.invoke(1, 2)
320
338
  end
321
339
 
322
340
  def test_name_with_args
323
341
  desc "T"
324
- t = intern(:tt, :a, :b)
342
+ t = task(:tt, :a, :b)
325
343
  assert_equal "tt", t.name
326
344
  assert_equal "T", t.comment
327
345
  assert_equal "[a,b]", t.arg_description
@@ -331,26 +349,26 @@ class TestTaskWithArguments < Test::Unit::TestCase
331
349
 
332
350
  def test_named_args_are_passed_to_prereqs
333
351
  value = nil
334
- pre = intern(:pre, :rev).enhance { |t, args| value = args.rev }
335
- t = intern(:t, :name, :rev).enhance([:pre])
352
+ pre = task(:pre, :rev) { |t, args| value = args.rev }
353
+ t = task(:t, :name, :rev, :needs => [:pre])
336
354
  t.invoke("bill", "1.2")
337
355
  assert_equal "1.2", value
338
356
  end
339
357
 
340
358
  def test_args_not_passed_if_no_prereq_names
341
- pre = intern(:pre).enhance { |t, args|
359
+ pre = task(:pre) { |t, args|
342
360
  assert_equal({}, args.to_hash)
343
361
  assert_equal "bill", args.name
344
362
  }
345
- t = intern(:t, :name, :rev).enhance([:pre])
363
+ t = task(:t, :name, :rev, :needs => [:pre])
346
364
  t.invoke("bill", "1.2")
347
365
  end
348
366
 
349
367
  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)
368
+ pre = task(:pre, :rev) { |t, args|
369
+ assert_equal({}, args.to_hash)
352
370
  }
353
- t = intern(:t).enhance([:pre])
371
+ t = task(:t, :needs => [:pre])
354
372
  t.invoke("bill", "1.2")
355
373
  end
356
374
  end
@@ -5,6 +5,8 @@ require 'rake/testtask'
5
5
 
6
6
  class TestTestTask < Test::Unit::TestCase
7
7
  include Rake
8
+ include TestMethods
9
+
8
10
  def setup
9
11
  Task.clear
10
12
  ENV.delete('TEST')
@@ -7,12 +7,14 @@ rescue LoadError
7
7
  end
8
8
 
9
9
  require 'test/unit'
10
+ require 'flexmock/test_unit'
10
11
  require 'test/capture_stdout'
12
+ require 'test/rake_test_setup'
11
13
  require 'rake'
12
- require 'flexmock/test_unit'
13
14
 
14
15
  class TestTopLevelFunctions < Test::Unit::TestCase
15
16
  include CaptureStdout
17
+ include TestMethods
16
18
 
17
19
  def setup
18
20
  super
@@ -79,6 +81,6 @@ class TestTopLevelFunctions < Test::Unit::TestCase
79
81
  end
80
82
 
81
83
  def test_missing_other_constant
82
- assert_raise(NameError) do Object.const_missing(:Xyz) end
84
+ assert_exception(NameError) do Object.const_missing(:Xyz) end
83
85
  end
84
86
  end
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'test/rake_test_setup'
5
+ require 'test/in_environment'
6
+
7
+ require 'rake'
8
+
9
+ class TestWin32 < Test::Unit::TestCase
10
+ include InEnvironment
11
+ include TestMethods
12
+
13
+ Win32 = Rake::Win32
14
+
15
+ def test_win32_system_dir_uses_home_if_defined
16
+ in_environment('RAKE_SYSTEM' => nil, 'HOME' => 'C:\\HP') do
17
+ assert_equal "C:/HP/Rake", Win32.win32_system_dir
18
+ end
19
+ end
20
+
21
+ def test_win32_system_dir_uses_homedrive_homepath_when_no_home_defined
22
+ in_environment(
23
+ 'RAKE_SYSTEM' => nil,
24
+ 'HOME' => nil,
25
+ 'HOMEDRIVE' => "C:",
26
+ 'HOMEPATH' => "\\HP"
27
+ ) do
28
+ assert_equal "C:/HP/Rake", Win32.win32_system_dir
29
+ end
30
+ end
31
+
32
+ def test_win32_system_dir_uses_appdata_when_no_home_or_home_combo
33
+ in_environment(
34
+ 'RAKE_SYSTEM' => nil,
35
+ 'HOME' => nil,
36
+ 'HOMEDRIVE' => nil,
37
+ 'HOMEPATH' => nil,
38
+ 'APPDATA' => "C:\\Documents and Settings\\HP\\Application Data"
39
+ ) do
40
+ assert_equal "C:/Documents and Settings/HP/Application Data/Rake", Win32.win32_system_dir
41
+ end
42
+ end
43
+
44
+ def test_win32_system_dir_fallback_to_userprofile_otherwise
45
+ in_environment(
46
+ 'RAKE_SYSTEM' => nil,
47
+ 'HOME' => nil,
48
+ 'HOMEDRIVE' => nil,
49
+ 'HOMEPATH' => nil,
50
+ 'APPDATA' => nil,
51
+ 'USERPROFILE' => "C:\\Documents and Settings\\HP"
52
+ ) do
53
+ assert_equal "C:/Documents and Settings/HP/Rake", Win32.win32_system_dir
54
+ end
55
+ end
56
+
57
+ def test_win32_system_dir_nil_of_no_env_vars
58
+ in_environment(
59
+ 'RAKE_SYSTEM' => nil,
60
+ 'HOME' => nil,
61
+ 'HOMEDRIVE' => nil,
62
+ "HOMEPATH" => nil,
63
+ 'APPDATA' => nil,
64
+ "USERPROFILE" => nil
65
+ ) do
66
+ assert_exception(Rake::Win32::Win32HomeError) do
67
+ Win32.win32_system_dir
68
+ end
69
+ end
70
+ end
71
+
72
+ end