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
@@ -4,10 +4,12 @@ require 'test/unit'
4
4
  require 'rake'
5
5
 
6
6
  require 'test/capture_stdout'
7
+ require 'test/rake_test_setup'
7
8
 
8
9
  class TestFileList < Test::Unit::TestCase
9
10
  FileList = Rake::FileList
10
11
  include CaptureStdout
12
+ include TestMethods
11
13
 
12
14
  def setup
13
15
  create_test_data
@@ -204,12 +206,20 @@ class TestFileList < Test::Unit::TestCase
204
206
 
205
207
  def test_to_s_pending
206
208
  fl = FileList['testdata/abc.*']
207
- assert_equal %{testdata/abc.c testdata/abc.h testdata/abc.x}, fl.to_s
209
+ result = fl.to_s
210
+ assert_match(%r{testdata/abc\.c}, result)
211
+ assert_match(%r{testdata/abc\.h}, result)
212
+ assert_match(%r{testdata/abc\.x}, result)
213
+ assert_match(%r{(testdata/abc\..\b ?){2}}, result)
208
214
  end
209
215
 
210
216
  def test_inspect_pending
211
217
  fl = FileList['testdata/abc.*']
212
- assert_equal %{["testdata/abc.c", "testdata/abc.h", "testdata/abc.x"]}, fl.inspect
218
+ result = fl.inspect
219
+ assert_match(%r{"testdata/abc\.c"}, result)
220
+ assert_match(%r{"testdata/abc\.h"}, result)
221
+ assert_match(%r{"testdata/abc\.x"}, result)
222
+ assert_match(%r|^\[("testdata/abc\..", ){2}"testdata/abc\.."\]$|, result)
213
223
  end
214
224
 
215
225
  def test_sub
@@ -275,9 +285,7 @@ class TestFileList < Test::Unit::TestCase
275
285
  assert_equal "one.two.net", "one.two.c".ext(".net")
276
286
  assert_equal "one/two.net", "one/two.c".ext(".net")
277
287
  assert_equal "one.x/two.net", "one.x/two.c".ext(".net")
278
- assert_equal "one.x\\two.net", "one.x\\two.c".ext(".net")
279
288
  assert_equal "one.x/two.net", "one.x/two".ext(".net")
280
- assert_equal "one.x\\two.net", "one.x\\two".ext(".net")
281
289
  assert_equal ".onerc.net", ".onerc.dot".ext("net")
282
290
  assert_equal ".onerc.net", ".onerc".ext("net")
283
291
  assert_equal ".a/.onerc.net", ".a/.onerc".ext("net")
@@ -287,6 +295,11 @@ class TestFileList < Test::Unit::TestCase
287
295
  assert_equal ".one", ".one".ext
288
296
  assert_equal ".", ".".ext("c")
289
297
  assert_equal "..", "..".ext("c")
298
+ # These only need to work in windows
299
+ if Rake::Win32.windows?
300
+ assert_equal "one.x\\two.net", "one.x\\two.c".ext(".net")
301
+ assert_equal "one.x\\two.net", "one.x\\two".ext(".net")
302
+ end
290
303
  end
291
304
 
292
305
  def test_filelist_ext
@@ -403,12 +416,40 @@ class TestFileList < Test::Unit::TestCase
403
416
  ['a', FileList['testdata/*.c']].flatten.sort
404
417
  end
405
418
 
406
- def test_clone
419
+ def test_clone_and_dup
407
420
  a = FileList['a', 'b', 'c']
408
- b = a.clone
421
+ c = a.clone
422
+ d = a.dup
409
423
  a << 'd'
410
424
  assert_equal ['a', 'b', 'c', 'd'], a
411
- assert_equal ['a', 'b', 'c'], b
425
+ assert_equal ['a', 'b', 'c'], c
426
+ assert_equal ['a', 'b', 'c'], d
427
+ end
428
+
429
+ def test_dup_and_clone_replicate_taint
430
+ a = FileList['a', 'b', 'c']
431
+ a.taint
432
+ c = a.clone
433
+ d = a.dup
434
+ assert c.tainted?, "Clone should be tainted"
435
+ assert d.tainted?, "Dup should be tainted"
436
+ end
437
+
438
+ def test_duped_items_will_thaw
439
+ a = FileList['a', 'b', 'c']
440
+ a.freeze
441
+ d = a.dup
442
+ d << 'more'
443
+ assert_equal ['a', 'b', 'c', 'more'], d
444
+ end
445
+
446
+ def test_cloned_items_stay_frozen
447
+ a = FileList['a', 'b', 'c']
448
+ a.freeze
449
+ c = a.clone
450
+ assert_exception(TypeError, RuntimeError) do
451
+ c << 'more'
452
+ end
412
453
  end
413
454
 
414
455
  def test_array_comparisons
@@ -5,9 +5,11 @@ require 'test/unit'
5
5
  require 'test/filecreation'
6
6
  require 'fileutils'
7
7
  require 'stringio'
8
+ require 'test/rake_test_setup'
8
9
 
9
10
  class TestFileUtils < Test::Unit::TestCase
10
11
  include FileCreation
12
+ include TestMethods
11
13
 
12
14
  def setup
13
15
  File.chmod(0750,"test/shellcommand.rb")
@@ -81,7 +83,7 @@ class TestFileUtils < Test::Unit::TestCase
81
83
  def test_safe_ln_fails_on_script_error
82
84
  FileUtils::LN_SUPPORTED[0] = true
83
85
  c = BadLink.new(ScriptError)
84
- assert_raise(ScriptError) do c.safe_ln "a", "b" end
86
+ assert_exception(ScriptError) do c.safe_ln "a", "b" end
85
87
  end
86
88
 
87
89
  def test_verbose
@@ -114,41 +116,58 @@ class TestFileUtils < Test::Unit::TestCase
114
116
 
115
117
  def test_fileutils_methods_dont_leak
116
118
  obj = Object.new
117
- assert_raise(NoMethodError) { obj.copy } # from FileUtils
118
- assert_raise(NoMethodError) { obj.ruby } # from RubyFileUtils
119
+ assert_exception(NoMethodError) { obj.copy } # from FileUtils
120
+ assert_exception(NoMethodError) { obj.ruby } # from RubyFileUtils
119
121
  end
120
122
 
121
123
  def test_sh
122
- verbose(false) { sh %{test/shellcommand.rb} }
124
+ verbose(false) { sh %{ruby test/shellcommand.rb} }
123
125
  assert true, "should not fail"
124
126
  end
125
127
 
126
- def test_sh_multiple_arguments
128
+ # If the :sh method is invoked directly from a test unit instance
129
+ # (under mini/test), the mini/test version of fail is invoked rather
130
+ # than the kernel version of fail. So we run :sh from within a
131
+ # non-test class to avoid the problem.
132
+ class Sh
133
+ include FileUtils
134
+ def run(*args)
135
+ sh(*args)
136
+ end
137
+ def self.run(*args)
138
+ new.run(*args)
139
+ end
140
+ end
141
+
142
+ def test_sh_with_a_single_string_argument
127
143
  ENV['RAKE_TEST_SH'] = 'someval'
128
- # This one gets expanded by the shell
129
- verbose(false) { sh %{test $RAKE_TEST_SH = someval} }
130
- assert true, "should not fail"
131
- assert_raises(RuntimeError) {
132
- # This one does not get expanded
133
- verbose(false) { sh 'test','$RAKE_TEST_SH', '=', 'someval' }
144
+ verbose(false) {
145
+ sh %{ruby test/check_expansion.rb #{env_var} someval}
146
+ }
147
+ end
148
+
149
+ def test_sh_with_multiple_arguments
150
+ ENV['RAKE_TEST_SH'] = 'someval'
151
+ verbose(false) {
152
+ Sh.run 'ruby', 'test/check_no_expansion.rb', env_var, 'someval'
134
153
  }
135
154
  end
136
155
 
137
156
  def test_sh_failure
138
- assert_raises(RuntimeError) {
139
- verbose(false) { sh %{test/shellcommand.rb 1} }
157
+ assert_exception(RuntimeError) {
158
+ verbose(false) { Sh.run %{ruby test/shellcommand.rb 1} }
140
159
  }
141
160
  end
142
161
 
143
162
  def test_sh_special_handling
144
163
  count = 0
145
164
  verbose(false) {
146
- sh(%{test/shellcommand.rb}) do |ok, res|
165
+ sh(%{ruby test/shellcommand.rb}) do |ok, res|
147
166
  assert(ok)
148
167
  assert_equal 0, res.exitstatus
149
168
  count += 1
150
169
  end
151
- sh(%{test/shellcommand.rb 1}) do |ok, res|
170
+ sh(%{ruby test/shellcommand.rb 1}) do |ok, res|
152
171
  assert(!ok)
153
172
  assert_equal 1, res.exitstatus
154
173
  count += 1
@@ -163,7 +182,7 @@ class TestFileUtils < Test::Unit::TestCase
163
182
  end
164
183
 
165
184
  def test_sh_bad_option
166
- ex = assert_raise(ArgumentError) {
185
+ ex = assert_exception(ArgumentError) {
167
186
  verbose(false) { sh %{test/shellcommand.rb}, :bad_option=>true }
168
187
  }
169
188
  assert_match(/bad_option/, ex.message)
@@ -178,34 +197,27 @@ class TestFileUtils < Test::Unit::TestCase
178
197
  assert_match(/^test\/shellcommand\.rb$/, out)
179
198
  end
180
199
 
181
- def test_sh_default_verbosity_is_false
200
+ def test_sh_no_verbose
182
201
  out = redirect_stderr {
183
- sh %{test/shellcommand.rb}, :noop=>true
202
+ verbose(false) {
203
+ sh %{test/shellcommand.rb}, :noop=>true
204
+ }
184
205
  }
185
206
  assert_equal '', out
186
207
  end
187
208
 
188
- def test_ruby
189
- verbose(false) do
190
- ENV['RAKE_TEST_RUBY'] = "123"
191
- block_run = false
192
- # This one gets expanded by the shell
193
- ruby %{-e "exit $RAKE_TEST_RUBY"} do |ok, status|
194
- assert(!ok)
195
- assert_equal 123, status.exitstatus
196
- block_run = true
197
- end
198
- assert block_run, "The block must be run"
209
+ def test_ruby_with_a_single_string_argument
210
+ ENV['RAKE_TEST_SH'] = 'someval'
211
+ verbose(false) {
212
+ ruby %{test/check_expansion.rb #{env_var} someval}
213
+ }
214
+ end
199
215
 
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
206
- end
207
- assert block_run, "The block must be run"
208
- end
216
+ def test_ruby_with_multiple_arguments
217
+ ENV['RAKE_TEST_SH'] = 'someval'
218
+ verbose(false) {
219
+ ruby 'test/check_no_expansion.rb', env_var, 'someval'
220
+ }
209
221
  end
210
222
 
211
223
  def test_split_all
@@ -227,4 +239,13 @@ class TestFileUtils < Test::Unit::TestCase
227
239
  ensure
228
240
  $stderr = old_err
229
241
  end
242
+
243
+ def windows?
244
+ ! File::ALT_SEPARATOR.nil?
245
+ end
246
+
247
+ def env_var
248
+ windows? ? '%RAKE_TEST_SH%' : '$RAKE_TEST_SH'
249
+ end
250
+
230
251
  end
data/test/test_ftp.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'date'
4
+ require 'time'
4
5
  require 'test/unit'
5
6
  require 'rake/contrib/ftptools'
6
7
 
@@ -8,13 +9,16 @@ class FakeDate
8
9
  def self.today
9
10
  Date.new(2003,10,3)
10
11
  end
12
+ def self.now
13
+ Time.local(2003,10,3,12,00,00)
14
+ end
11
15
  end
12
16
 
13
17
 
14
18
  class TestFtpFile < Test::Unit::TestCase
15
19
 
16
20
  def setup
17
- Rake::FtpFile.class_eval { @date_class = FakeDate }
21
+ Rake::FtpFile.class_eval { @date_class = FakeDate; @time_class = FakeDate }
18
22
  end
19
23
 
20
24
  def test_general
@@ -2,9 +2,11 @@
2
2
 
3
3
  require 'test/unit'
4
4
  require 'rake'
5
+ require 'test/rake_test_setup'
5
6
 
6
7
  ######################################################################
7
8
  class TestAnEmptyInvocationChain < Test::Unit::TestCase
9
+ include TestMethods
8
10
 
9
11
  def setup
10
12
  @empty = Rake::InvocationChain::EMPTY
@@ -23,6 +25,8 @@ end
23
25
 
24
26
  ######################################################################
25
27
  class TestAnInvocationChainWithOneMember < Test::Unit::TestCase
28
+ include TestMethods
29
+
26
30
  def setup
27
31
  @empty = Rake::InvocationChain::EMPTY
28
32
  @first_member = "A"
@@ -34,7 +38,7 @@ class TestAnInvocationChainWithOneMember < Test::Unit::TestCase
34
38
  end
35
39
 
36
40
  def test_should_fail_when_adding_original_member
37
- ex = assert_raise RuntimeError do
41
+ ex = assert_exception RuntimeError do
38
42
  @chain.append(@first_member)
39
43
  end
40
44
  assert_match(/circular +dependency/i, ex.message)
@@ -49,6 +53,8 @@ end
49
53
 
50
54
  ######################################################################
51
55
  class TestAnInvocationChainWithMultipleMember < Test::Unit::TestCase
56
+ include TestMethods
57
+
52
58
  def setup
53
59
  @first_member = "A"
54
60
  @second_member = "B"
@@ -65,7 +71,7 @@ class TestAnInvocationChainWithMultipleMember < Test::Unit::TestCase
65
71
  end
66
72
 
67
73
  def test_should_fail_when_adding_original_member
68
- ex = assert_raise RuntimeError do
74
+ ex = assert_exception RuntimeError do
69
75
  @chain.append(@first_member)
70
76
  end
71
77
  assert_match(/A.*=>.*B.*=>.*A/, ex.message)
@@ -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,9 @@ 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 ["g1", "g 2", "g 3", "g4"].sort, Task['g 0'].prerequisites.sort
24
+ assert_equal 7, Task.tasks.size
22
25
  end
23
26
  end
@@ -9,28 +9,47 @@ end
9
9
  require 'test/unit'
10
10
  require 'flexmock/test_unit'
11
11
  require 'rake'
12
+ require 'test/rake_test_setup'
12
13
 
13
14
  class TestNameSpace < Test::Unit::TestCase
15
+ include TestMethods
16
+
17
+ class TM
18
+ include Rake::TaskManager
19
+ end
14
20
 
15
21
  def test_namespace_creation
16
- mgr = flexmock("TaskManager")
22
+ mgr = TM.new
17
23
  ns = Rake::NameSpace.new(mgr, [])
18
24
  assert_not_nil ns
19
25
  end
20
26
 
21
27
  def test_namespace_lookup
22
- mgr = flexmock("TaskManager")
23
- mgr.should_receive(:lookup).with(:t, ["a"]).
24
- and_return(:dummy).once
25
- ns = Rake::NameSpace.new(mgr, ["a"])
26
- assert_equal :dummy, ns[:t]
28
+ mgr = TM.new
29
+ ns = mgr.in_namespace("n") do
30
+ mgr.define_task(Rake::Task, "t")
31
+ end
32
+
33
+ assert_not_nil ns["t"]
34
+ assert_equal mgr["n:t"], ns["t"]
27
35
  end
28
36
 
29
37
  def test_namespace_reports_tasks_it_owns
30
- mgr = flexmock("TaskManager")
31
- mgr.should_receive(:tasks).with().
32
- and_return([:x, :y, :z]).once
33
- ns = Rake::NameSpace.new(mgr, ["a"])
34
- assert_equal [:x, :y, :z], ns.tasks
38
+ mgr = TM.new
39
+ nns = nil
40
+ ns = mgr.in_namespace("n") do
41
+ mgr.define_task(Rake::Task, :x)
42
+ mgr.define_task(Rake::Task, :y)
43
+ nns = mgr.in_namespace("nn") do
44
+ mgr.define_task(Rake::Task, :z)
45
+ end
46
+ end
47
+ mgr.in_namespace("m") do
48
+ mgr.define_task(Rake::Task, :x)
49
+ end
50
+
51
+ assert_equal ["n:nn:z", "n:x", "n:y"],
52
+ ns.tasks.map { |tsk| tsk.name }
53
+ assert_equal ["n:nn:z"], nns.tasks.map {|t| t.name}
35
54
  end
36
55
  end
@@ -2,9 +2,11 @@
2
2
 
3
3
  require 'test/unit'
4
4
  require 'rake/packagetask'
5
+ require 'test/rake_test_setup'
5
6
 
6
7
  class TestPackageTask < Test::Unit::TestCase
7
8
  include Rake
9
+ include TestMethods
8
10
 
9
11
  def test_create
10
12
  pkg = Rake::PackageTask.new("pkgr", "1.2.3") { |p|
@@ -40,7 +42,7 @@ class TestPackageTask < Test::Unit::TestCase
40
42
  end
41
43
 
42
44
  def test_missing_version
43
- assert_raises(RuntimeError) {
45
+ assert_exception(RuntimeError) {
44
46
  pkg = Rake::PackageTask.new("pkgr") { |p| }
45
47
  }
46
48
  end
data/test/test_pathmap.rb CHANGED
@@ -5,6 +5,7 @@ require 'rake'
5
5
 
6
6
  # ====================================================================
7
7
  class TestPathMap < Test::Unit::TestCase
8
+ include TestMethods
8
9
 
9
10
  def test_returns_self_with_no_args
10
11
  assert_equal "abc.rb", "abc.rb".pathmap
@@ -86,7 +87,7 @@ class TestPathMap < Test::Unit::TestCase
86
87
  end
87
88
 
88
89
  def test_undefined_percent_causes_error
89
- ex = assert_raise(ArgumentError) {
90
+ ex = assert_exception(ArgumentError) {
90
91
  "dir/abc.rb".pathmap("%z")
91
92
  }
92
93
  end
@@ -130,7 +131,7 @@ class TestPathMap < Test::Unit::TestCase
130
131
  end
131
132
 
132
133
  def test_pattern_with_invalid_operator
133
- ex = assert_raise(ArgumentError) do
134
+ ex = assert_exception(ArgumentError) do
134
135
  "abc.xyz".pathmap("%{src,bin}z")
135
136
  end
136
137
  assert_match(/unknown.*pathmap.*spec.*z/i, ex.message)
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'rake'
5
+
6
+ require 'test/capture_stdout'
7
+ require 'test/rake_test_setup'
8
+
9
+ class PseudoStatusTest < Test::Unit::TestCase
10
+ def test_with_zero_exit_status
11
+ s = Rake::PseudoStatus.new
12
+ assert_equal 0, s.exitstatus
13
+ assert_equal 0, s.to_i
14
+ assert_equal 0, s >> 8
15
+ assert ! s.stopped?
16
+ assert s.exited?
17
+ end
18
+ def test_with_99_exit_status
19
+ s = Rake::PseudoStatus.new(99)
20
+ assert_equal 99, s.exitstatus
21
+ assert_equal 25344, s.to_i
22
+ assert_equal 99, s >> 8
23
+ assert ! s.stopped?
24
+ assert s.exited?
25
+ end
26
+ end
data/test/test_rake.rb CHANGED
@@ -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)
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'rake/rdoctask'
5
+ require 'test/rake_test_setup'
6
+
7
+ class TestRDocTask < Test::Unit::TestCase
8
+ include Rake
9
+ include TestMethods
10
+
11
+ def setup
12
+ Task.clear
13
+ end
14
+
15
+ def test_tasks_creation
16
+ Rake::RDocTask.new
17
+ assert Task[:rdoc]
18
+ assert Task[:clobber_rdoc]
19
+ assert Task[:rerdoc]
20
+ end
21
+
22
+ def test_tasks_creation_with_custom_name_symbol
23
+ rd = Rake::RDocTask.new(:rdoc_dev)
24
+ assert Task[:rdoc_dev]
25
+ assert Task[:clobber_rdoc_dev]
26
+ assert Task[:rerdoc_dev]
27
+ assert_equal :rdoc_dev, rd.name
28
+ end
29
+
30
+ def test_tasks_creation_with_custom_name_string
31
+ rd = Rake::RDocTask.new("rdoc_dev")
32
+ assert Task[:rdoc_dev]
33
+ assert Task[:clobber_rdoc_dev]
34
+ assert Task[:rerdoc_dev]
35
+ assert_equal "rdoc_dev", rd.name
36
+ end
37
+
38
+ def test_tasks_creation_with_custom_name_hash
39
+ options = { :rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force" }
40
+ rd = Rake::RDocTask.new(options)
41
+ assert Task[:"rdoc"]
42
+ assert Task[:"rdoc:clean"]
43
+ assert Task[:"rdoc:force"]
44
+ assert_raises(RuntimeError) { Task[:clobber_rdoc] }
45
+ assert_equal options, rd.name
46
+ end
47
+
48
+ def test_tasks_creation_with_custom_name_hash_will_use_default_if_an_option_isnt_given
49
+ rd = Rake::RDocTask.new(:clobber_rdoc => "rdoc:clean")
50
+ assert Task[:rdoc]
51
+ assert Task[:"rdoc:clean"]
52
+ assert Task[:rerdoc]
53
+ end
54
+
55
+ def test_tasks_creation_with_custom_name_hash_raises_exception_if_invalid_option_given
56
+ assert_raises(ArgumentError) do
57
+ Rake::RDocTask.new(:foo => "bar")
58
+ end
59
+
60
+ begin
61
+ Rake::RDocTask.new(:foo => "bar")
62
+ rescue ArgumentError => e
63
+ assert_match(/foo/, e.message)
64
+ end
65
+ end
66
+
67
+ def test_inline_source_is_enabled_by_default
68
+ rd = Rake::RDocTask.new
69
+ assert rd.option_list.include?('--inline-source')
70
+ end
71
+
72
+ def test_inline_source_option_is_only_appended_if_option_not_already_given
73
+ rd = Rake::RDocTask.new
74
+ rd.options << '--inline-source'
75
+ assert_equal 1, rd.option_list.grep('--inline-source').size
76
+
77
+ rd = Rake::RDocTask.new
78
+ rd.options << '-S'
79
+ assert_equal 1, rd.option_list.grep('-S').size
80
+ assert_equal 0, rd.option_list.grep('--inline-source').size
81
+ end
82
+
83
+ def test_inline_source_option_can_be_disabled
84
+ rd = Rake::RDocTask.new
85
+ rd.inline_source = false
86
+ assert !rd.option_list.include?('--inline-source')
87
+ end
88
+ end
data/test/test_require.rb CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  require 'test/unit'
4
4
  require 'rake'
5
+ require 'test/rake_test_setup'
5
6
 
6
7
  # ====================================================================
7
8
  class TestRequire < Test::Unit::TestCase
9
+ include TestMethods
8
10
 
9
11
  def test_can_load_rake_library
10
12
  app = Rake::Application.new
@@ -22,7 +24,7 @@ class TestRequire < Test::Unit::TestCase
22
24
 
23
25
  def test_throws_error_if_library_not_found
24
26
  app = Rake::Application.new
25
- ex = assert_raise(LoadError) {
27
+ ex = assert_exception(LoadError) {
26
28
  assert app.instance_eval {
27
29
  rake_require("testx", ['test/data/rakelib'], [])
28
30
  }