rake 0.7.3 → 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 (66) hide show
  1. data/CHANGES +126 -1
  2. data/README +86 -132
  3. data/Rakefile +111 -64
  4. data/TODO +1 -0
  5. data/bin/rake +24 -0
  6. data/doc/command_line_usage.rdoc +102 -0
  7. data/doc/rakefile.rdoc +126 -3
  8. data/doc/release_notes/rake-0.7.3.rdoc +0 -0
  9. data/doc/release_notes/rake-0.8.0.rdoc +114 -0
  10. data/doc/release_notes/rake-0.8.2.rdoc +165 -0
  11. data/doc/release_notes/rake-0.8.3.rdoc +112 -0
  12. data/doc/release_notes/rake-0.8.4.rdoc +147 -0
  13. data/doc/release_notes/rake-0.8.5.rdoc +53 -0
  14. data/doc/release_notes/rake-0.8.6.rdoc +55 -0
  15. data/doc/release_notes/rake-0.8.7.rdoc +55 -0
  16. data/lib/rake/alt_system.rb +108 -0
  17. data/lib/rake/contrib/ftptools.rb +24 -10
  18. data/lib/rake/contrib/publisher.rb +1 -1
  19. data/lib/rake/contrib/sys.rb +5 -2
  20. data/lib/rake/gempackagetask.rb +2 -6
  21. data/lib/rake/loaders/makefile.rb +17 -15
  22. data/lib/rake/rdoctask.rb +83 -21
  23. data/lib/rake/ruby182_test_unit_fix.rb +0 -0
  24. data/lib/rake/tasklib.rb +8 -3
  25. data/lib/rake/testtask.rb +1 -1
  26. data/lib/rake/win32.rb +55 -0
  27. data/lib/rake.rb +861 -386
  28. data/test/check_expansion.rb +5 -0
  29. data/test/check_no_expansion.rb +5 -0
  30. data/test/data/file_creation_task/Rakefile +4 -1
  31. data/test/data/multidesc/Rakefile +3 -0
  32. data/test/data/sample.mf +6 -1
  33. data/test/data/statusreturn/Rakefile +8 -0
  34. data/test/filecreation.rb +0 -2
  35. data/test/functional.rb +3 -1
  36. data/test/in_environment.rb +30 -0
  37. data/test/rake_test_setup.rb +24 -0
  38. data/test/session_functional.rb +145 -24
  39. data/test/shellcommand.rb +0 -0
  40. data/test/test_application.rb +345 -95
  41. data/test/test_definitions.rb +4 -1
  42. data/test/test_earlytime.rb +2 -2
  43. data/test/test_extension.rb +63 -0
  44. data/test/test_file_task.rb +20 -16
  45. data/test/test_filelist.rb +59 -10
  46. data/test/test_fileutils.rb +59 -38
  47. data/test/test_ftp.rb +5 -1
  48. data/test/test_invocation_chain.rb +81 -0
  49. data/test/test_makefile_loader.rb +5 -2
  50. data/test/test_namespace.rb +37 -14
  51. data/test/test_package_task.rb +3 -15
  52. data/test/test_pathmap.rb +24 -2
  53. data/test/test_pseudo_status.rb +26 -0
  54. data/test/test_rake.rb +9 -2
  55. data/test/test_rdoc_task.rb +88 -0
  56. data/test/test_require.rb +3 -1
  57. data/test/test_rules.rb +56 -12
  58. data/test/test_task_arguments.rb +89 -0
  59. data/test/test_task_manager.rb +27 -2
  60. data/test/test_tasklib.rb +12 -0
  61. data/test/test_tasks.rb +248 -20
  62. data/test/test_test_task.rb +3 -2
  63. data/test/test_top_level_functions.rb +10 -3
  64. data/test/test_win32.rb +72 -0
  65. metadata +105 -69
  66. /data/test/contrib/{testsys.rb → test_sys.rb} +0 -0
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'rake'
5
+ require 'stringio'
6
+
7
+ ######################################################################
8
+ class TestExtension < Test::Unit::TestCase
9
+
10
+ module Redirect
11
+ def error_redirect
12
+ old_err = $stderr
13
+ result = StringIO.new
14
+ $stderr = result
15
+ yield
16
+ result
17
+ ensure
18
+ $stderr = old_err
19
+ end
20
+ end
21
+
22
+ class Sample
23
+ extend Redirect
24
+
25
+ def duplicate_method
26
+ :original
27
+ end
28
+
29
+ OK_ERRS = error_redirect do
30
+ rake_extension("a") do
31
+ def ok_method
32
+ end
33
+ end
34
+ end
35
+
36
+
37
+ DUP_ERRS = error_redirect do
38
+ rake_extension("duplicate_method") do
39
+ def duplicate_method
40
+ :override
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ def test_methods_actually_exist
47
+ sample = Sample.new
48
+ sample.ok_method
49
+ sample.duplicate_method
50
+ end
51
+
52
+ def test_no_warning_when_defining_ok_method
53
+ assert_equal "", Sample::OK_ERRS.string
54
+ end
55
+
56
+ def test_extension_complains_when_a_method_that_is_present
57
+ assert_match(/warning:/i, Sample::DUP_ERRS.string)
58
+ assert_match(/already exists/i, Sample::DUP_ERRS.string)
59
+ assert_match(/duplicate_method/i, Sample::DUP_ERRS.string)
60
+ assert_equal :original, Sample.new.duplicate_method
61
+ end
62
+
63
+ end
@@ -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 TestFileTask < Test::Unit::TestCase
10
11
  include Rake
11
12
  include FileCreation
13
+ include TestMethods
12
14
 
13
15
  def setup
14
16
  Task.clear
@@ -118,22 +120,24 @@ class TestDirectoryTask < Test::Unit::TestCase
118
120
  assert ! File.exist?("testdata/a/b/c")
119
121
  end
120
122
 
121
- def test_directory_win32
122
- desc "WIN32 DESC"
123
- FileUtils.mkdir_p("testdata")
124
- Dir.chdir("testdata") do
125
- directory 'c:/testdata/a/b/c'
126
- assert_equal FileCreationTask, Task['c:/testdata'].class
127
- assert_equal FileCreationTask, Task['c:/testdata/a'].class
128
- assert_equal FileCreationTask, Task['c:/testdata/a/b/c'].class
129
- assert_nil Task['c:/testdata'].comment
130
- assert_equal "WIN32 DESC", Task['c:/testdata/a/b/c'].comment
131
- assert_nil Task['c:/testdata/a/b'].comment
132
- verbose(false) {
133
- Task['c:/testdata/a/b'].invoke
134
- }
135
- assert File.exist?('c:/testdata/a/b')
136
- assert ! File.exist?('c:/testdata/a/b/c')
123
+ if Rake::Win32.windows?
124
+ def test_directory_win32
125
+ desc "WIN32 DESC"
126
+ FileUtils.mkdir_p("testdata")
127
+ Dir.chdir("testdata") do
128
+ directory 'c:/testdata/a/b/c'
129
+ assert_equal FileCreationTask, Task['c:/testdata'].class
130
+ assert_equal FileCreationTask, Task['c:/testdata/a'].class
131
+ assert_equal FileCreationTask, Task['c:/testdata/a/b/c'].class
132
+ assert_nil Task['c:/testdata'].comment
133
+ assert_equal "WIN32 DESC", Task['c:/testdata/a/b/c'].comment
134
+ assert_nil Task['c:/testdata/a/b'].comment
135
+ verbose(false) {
136
+ Task['c:/testdata/a/b'].invoke
137
+ }
138
+ assert File.exist?('c:/testdata/a/b')
139
+ assert ! File.exist?('c:/testdata/a/b/c')
140
+ end
137
141
  end
138
142
  end
139
143
  end
@@ -2,21 +2,31 @@
2
2
 
3
3
  require 'test/unit'
4
4
  require 'rake'
5
+
5
6
  require 'test/capture_stdout'
7
+ require 'test/rake_test_setup'
6
8
 
7
9
  class TestFileList < Test::Unit::TestCase
8
10
  FileList = Rake::FileList
9
11
  include CaptureStdout
12
+ include TestMethods
10
13
 
11
14
  def setup
12
15
  create_test_data
13
16
  end
14
17
 
15
18
  def teardown
16
- FileList.select_default_ignore_patterns
19
+ # FileList.select_default_ignore_patterns
17
20
  FileUtils.rm_rf("testdata")
18
21
  end
19
22
 
23
+ def test_delgating_methods_do_not_include_to_a_or_to_ary
24
+ assert ! FileList::DELEGATING_METHODS.include?("to_a"), "should not include to_a"
25
+ assert ! FileList::DELEGATING_METHODS.include?(:to_a), "should not include to_a"
26
+ assert ! FileList::DELEGATING_METHODS.include?("to_ary"), "should not include to_ary"
27
+ assert ! FileList::DELEGATING_METHODS.include?(:to_ary), "should not include to_ary"
28
+ end
29
+
20
30
  def test_create
21
31
  fl = FileList.new
22
32
  assert_equal 0, fl.size
@@ -196,12 +206,20 @@ class TestFileList < Test::Unit::TestCase
196
206
 
197
207
  def test_to_s_pending
198
208
  fl = FileList['testdata/abc.*']
199
- assert_equal %{testdata/abc.c testdata/abc.h testdata/abc.x}.sort, fl.to_s.sort
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)
200
214
  end
201
215
 
202
216
  def test_inspect_pending
203
217
  fl = FileList['testdata/abc.*']
204
- 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)
205
223
  end
206
224
 
207
225
  def test_sub
@@ -267,9 +285,7 @@ class TestFileList < Test::Unit::TestCase
267
285
  assert_equal "one.two.net", "one.two.c".ext(".net")
268
286
  assert_equal "one/two.net", "one/two.c".ext(".net")
269
287
  assert_equal "one.x/two.net", "one.x/two.c".ext(".net")
270
- assert_equal "one.x\\two.net", "one.x\\two.c".ext(".net")
271
288
  assert_equal "one.x/two.net", "one.x/two".ext(".net")
272
- assert_equal "one.x\\two.net", "one.x\\two".ext(".net")
273
289
  assert_equal ".onerc.net", ".onerc.dot".ext("net")
274
290
  assert_equal ".onerc.net", ".onerc".ext("net")
275
291
  assert_equal ".a/.onerc.net", ".a/.onerc".ext("net")
@@ -279,6 +295,11 @@ class TestFileList < Test::Unit::TestCase
279
295
  assert_equal ".one", ".one".ext
280
296
  assert_equal ".", ".".ext("c")
281
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
282
303
  end
283
304
 
284
305
  def test_filelist_ext
@@ -395,12 +416,40 @@ class TestFileList < Test::Unit::TestCase
395
416
  ['a', FileList['testdata/*.c']].flatten.sort
396
417
  end
397
418
 
398
- def test_clone
419
+ def test_clone_and_dup
399
420
  a = FileList['a', 'b', 'c']
400
- b = a.clone
421
+ c = a.clone
422
+ d = a.dup
401
423
  a << 'd'
402
424
  assert_equal ['a', 'b', 'c', 'd'], a
403
- 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
404
453
  end
405
454
 
406
455
  def test_array_comparisons
@@ -467,7 +516,7 @@ class TestFileList < Test::Unit::TestCase
467
516
  assert_equal FileList, b[0].class
468
517
  assert_equal FileList, b[1].class
469
518
 
470
- b = a.zip(['x', 'y'])
519
+ b = a.zip(['x', 'y']).to_a
471
520
  assert_equal [['a', 'x'], ['b', 'y']], b
472
521
  assert_equal Array, b.class
473
522
  assert_equal Array, b[0].class
@@ -543,7 +592,7 @@ class TestFileList < Test::Unit::TestCase
543
592
  def test_file_utils_can_use_filelists
544
593
  cfiles = FileList['testdata/*.c']
545
594
 
546
- cp cfiles, @cdir
595
+ cp cfiles, @cdir, :verbose => false
547
596
 
548
597
  assert File.exist?(File.join(@cdir, 'abc.c'))
549
598
  assert File.exist?(File.join(@cdir, 'xyz.c'))
@@ -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
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'rake'
5
+ require 'test/rake_test_setup'
6
+
7
+ ######################################################################
8
+ class TestAnEmptyInvocationChain < Test::Unit::TestCase
9
+ include TestMethods
10
+
11
+ def setup
12
+ @empty = Rake::InvocationChain::EMPTY
13
+ end
14
+
15
+ def test_should_be_able_to_add_members
16
+ assert_nothing_raised do
17
+ @empty.append("A")
18
+ end
19
+ end
20
+
21
+ def test_to_s
22
+ assert_equal "TOP", @empty.to_s
23
+ end
24
+ end
25
+
26
+ ######################################################################
27
+ class TestAnInvocationChainWithOneMember < Test::Unit::TestCase
28
+ include TestMethods
29
+
30
+ def setup
31
+ @empty = Rake::InvocationChain::EMPTY
32
+ @first_member = "A"
33
+ @chain = @empty.append(@first_member)
34
+ end
35
+
36
+ def test_should_report_first_member_as_a_member
37
+ assert @chain.member?(@first_member)
38
+ end
39
+
40
+ def test_should_fail_when_adding_original_member
41
+ ex = assert_exception RuntimeError do
42
+ @chain.append(@first_member)
43
+ end
44
+ assert_match(/circular +dependency/i, ex.message)
45
+ assert_match(/A.*=>.*A/, ex.message)
46
+ end
47
+
48
+ def test_to_s
49
+ assert_equal "TOP => A", @chain.to_s
50
+ end
51
+
52
+ end
53
+
54
+ ######################################################################
55
+ class TestAnInvocationChainWithMultipleMember < Test::Unit::TestCase
56
+ include TestMethods
57
+
58
+ def setup
59
+ @first_member = "A"
60
+ @second_member = "B"
61
+ ch = Rake::InvocationChain::EMPTY.append(@first_member)
62
+ @chain = ch.append(@second_member)
63
+ end
64
+
65
+ def test_should_report_first_member_as_a_member
66
+ assert @chain.member?(@first_member)
67
+ end
68
+
69
+ def test_should_report_second_member_as_a_member
70
+ assert @chain.member?(@second_member)
71
+ end
72
+
73
+ def test_should_fail_when_adding_original_member
74
+ ex = assert_exception RuntimeError do
75
+ @chain.append(@first_member)
76
+ end
77
+ assert_match(/A.*=>.*B.*=>.*A/, ex.message)
78
+ end
79
+ end
80
+
81
+
@@ -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
@@ -1,32 +1,55 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'rubygems'
3
+ begin
4
+ require 'rubygems'
5
+ rescue LoadError
6
+ # got no gems
7
+ end
8
+
4
9
  require 'test/unit'
5
- require 'flexmock'
10
+ require 'flexmock/test_unit'
6
11
  require 'rake'
12
+ require 'test/rake_test_setup'
7
13
 
8
14
  class TestNameSpace < Test::Unit::TestCase
9
- include FlexMock::TestCase
15
+ include TestMethods
16
+
17
+ class TM
18
+ include Rake::TaskManager
19
+ end
10
20
 
11
21
  def test_namespace_creation
12
- mgr = flexmock("TaskManager")
22
+ mgr = TM.new
13
23
  ns = Rake::NameSpace.new(mgr, [])
14
24
  assert_not_nil ns
15
25
  end
16
26
 
17
27
  def test_namespace_lookup
18
- mgr = flexmock("TaskManager")
19
- mgr.should_receive(:lookup).with(:t, ["a"]).
20
- and_return(:dummy).once
21
- ns = Rake::NameSpace.new(mgr, ["a"])
22
- 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"]
23
35
  end
24
36
 
25
37
  def test_namespace_reports_tasks_it_owns
26
- mgr = flexmock("TaskManager")
27
- mgr.should_receive(:tasks).with().
28
- and_return([:x, :y, :z]).once
29
- ns = Rake::NameSpace.new(mgr, ["a"])
30
- 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}
31
54
  end
32
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
@@ -85,20 +87,6 @@ else
85
87
  assert_equal "pkgr-1.2.3.gem", pkg.gem_file
86
88
  end
87
89
 
88
- def test_gem_package_with_specific_platform
89
- gem = Gem::Specification.new do |g|
90
- g.name = "pkgr"
91
- g.version = "1.2.3"
92
- g.files = FileList["x"].resolve
93
- g.platform = Gem::Platform::WIN32
94
- end
95
- pkg = Rake::GemPackageTask.new(gem) do |p|
96
- p.package_files << "y"
97
- end
98
- assert_equal ["x", "y"], pkg.package_files
99
- assert_equal "pkgr-1.2.3-mswin32.gem", pkg.gem_file
100
- end
101
-
102
90
  def test_gem_package_with_current_platform
103
91
  gem = Gem::Specification.new do |g|
104
92
  g.name = "pkgr"