drake 0.8.3.1.0.14 → 0.8.4.1.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/CHANGES +27 -0
  2. data/CHANGES.drake +4 -0
  3. data/README +98 -198
  4. data/Rakefile +2 -4
  5. data/Rakefile.drake +0 -4
  6. data/doc/command_line_usage.rdoc +102 -0
  7. data/doc/rakefile.rdoc +4 -4
  8. data/doc/release_notes/rake-0.8.4.rdoc +147 -0
  9. data/lib/rake.rb +94 -60
  10. data/lib/rake/alt_system.rb +108 -0
  11. data/lib/rake/contrib/publisher.rb +1 -1
  12. data/lib/rake/contrib/sys.rb +1 -1
  13. data/lib/rake/gempackagetask.rb +0 -6
  14. data/lib/rake/loaders/makefile.rb +8 -1
  15. data/lib/rake/packagetask.rb +0 -1
  16. data/lib/rake/rdoctask.rb +79 -17
  17. data/lib/rake/testtask.rb +1 -1
  18. data/lib/rake/win32.rb +11 -10
  19. data/test/Rakefile.seq +1 -1
  20. data/test/Rakefile.simple +14 -25
  21. data/test/check_no_expansion.rb +5 -0
  22. data/test/data/sample.mf +2 -0
  23. data/test/rake_test_setup.rb +14 -0
  24. data/test/session_functional.rb +2 -0
  25. data/test/test_application.rb +25 -44
  26. data/test/test_definitions.rb +4 -1
  27. data/test/test_file_task.rb +20 -16
  28. data/test/test_filelist.rb +8 -3
  29. data/test/test_fileutils.rb +45 -44
  30. data/test/test_invocation_chain.rb +8 -2
  31. data/test/test_makefile_loader.rb +2 -1
  32. data/test/test_namespace.rb +30 -11
  33. data/test/test_package_task.rb +3 -1
  34. data/test/test_parallel.rb +4 -15
  35. data/test/test_pathmap.rb +3 -2
  36. data/test/test_pseudo_status.rb +26 -0
  37. data/test/test_rdoc_task.rb +88 -0
  38. data/test/test_require.rb +3 -1
  39. data/test/test_rules.rb +7 -5
  40. data/test/test_task_manager.rb +4 -1
  41. data/test/test_tasks.rb +7 -4
  42. data/test/test_test_task.rb +2 -0
  43. data/test/test_top_level_functions.rb +4 -2
  44. data/test/test_win32.rb +29 -14
  45. metadata +12 -4
@@ -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)
@@ -20,6 +20,7 @@ class TestMakefileLoader < Test::Unit::TestCase
20
20
  assert_equal %w(d1 d2).sort, Task['d'].prerequisites.sort
21
21
  assert_equal %w(e1 f1).sort, Task['e'].prerequisites.sort
22
22
  assert_equal %w(e1 f1).sort, Task['f'].prerequisites.sort
23
- assert_equal 6, Task.tasks.size
23
+ assert_equal ["g1", "g 2", "g 3", "g4"].sort, Task['g 0'].prerequisites.sort
24
+ assert_equal 7, Task.tasks.size
24
25
  end
25
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
@@ -2,28 +2,17 @@
2
2
  require 'rbconfig'
3
3
  require 'test/unit'
4
4
 
5
- ENV["PATH"] =
6
- File.expand_path(File.dirname(__FILE__) + "/../bin") +
7
- ":" +
8
- ENV["PATH"]
9
-
10
5
  if Rake.application.num_threads > 1
11
6
  class TestSimpleParallel < Test::Unit::TestCase
12
7
  def test_1
13
8
  here = File.dirname(__FILE__)
14
-
15
- rake =
16
- if Config::CONFIG["arch"] =~ %r!java!i
17
- "jrake"
18
- else
19
- "rake"
20
- end
21
-
9
+ rake = File.expand_path("#{here}/../bin/rake")
10
+
22
11
  ENV["RUBYLIB"] = lambda {
23
12
  lib = File.expand_path("#{here}/../lib")
24
13
  current = ENV["RUBYLIB"]
25
14
  if current
26
- "#{current}:#{lib}"
15
+ "#{lib}:#{current}"
27
16
  else
28
17
  lib
29
18
  end
@@ -36,7 +25,7 @@ if Rake.application.num_threads > 1
36
25
  ].each { |file|
37
26
  (1..5).each { |n|
38
27
  args = [rake, "--threads", n.to_s, "-f", file]
39
- puts("-"*40)
28
+ puts("\n" + "-"*40)
40
29
  puts(args.join(" "))
41
30
  assert(system(*args))
42
31
  }
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
@@ -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
  }
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
@@ -191,8 +193,8 @@ class TestRules < Test::Unit::TestCase
191
193
  rule '.o' => ['.c'] do |t|
192
194
  @runs << t.name
193
195
  end
194
- assert_raises(RuntimeError) { Task['testdata/x.obj'].invoke }
195
- assert_raises(RuntimeError) { Task['testdata/x.xyo'].invoke }
196
+ assert_exception(RuntimeError) { Task['testdata/x.obj'].invoke }
197
+ assert_exception(RuntimeError) { Task['testdata/x.xyo'].invoke }
196
198
  end
197
199
 
198
200
  def test_rule_rebuilds_obj_when_source_is_newer
@@ -333,7 +335,7 @@ class TestRules < Test::Unit::TestCase
333
335
  rule ".#{letter}" => ".#{prev}" do |t| puts "#{t.name}" end
334
336
  prev = letter
335
337
  end
336
- ex = assert_raises(Rake::RuleRecursionOverflowError) {
338
+ ex = assert_exception(Rake::RuleRecursionOverflowError) {
337
339
  Task["testdata/a.z"].invoke
338
340
  }
339
341
  assert_match(/a\.z => testdata\/a.y/, ex.message)
@@ -341,7 +343,7 @@ class TestRules < Test::Unit::TestCase
341
343
 
342
344
  def test_rules_with_bad_dependents_will_fail
343
345
  rule "a" => [ 1 ] do |t| puts t.name end
344
- assert_raise(RuntimeError) do Task['a'].invoke end
346
+ assert_exception(RuntimeError) do Task['a'].invoke end
345
347
  end
346
348
 
347
349
  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
  @tm.num_threads = Rake.application.num_threads
@@ -69,7 +72,7 @@ class TestTaskManager < Test::Unit::TestCase
69
72
  end
70
73
 
71
74
  def test_name_lookup_with_nonexistent_task
72
- assert_raise(RuntimeError) {
75
+ assert_exception(RuntimeError) {
73
76
  t = @tm["DOES NOT EXIST"]
74
77
  }
75
78
  end
data/test/test_tasks.rb CHANGED
@@ -5,11 +5,13 @@ require 'fileutils'
5
5
  require 'rake'
6
6
  require 'test/filecreation'
7
7
  require 'test/capture_stdout'
8
+ require 'test/rake_test_setup'
8
9
 
9
10
  ######################################################################
10
11
  class TestTask < Test::Unit::TestCase
11
12
  include CaptureStdout
12
13
  include Rake
14
+ include TestMethods
13
15
 
14
16
  def setup
15
17
  Task.clear
@@ -48,7 +50,7 @@ class TestTask < Test::Unit::TestCase
48
50
  t2 = task(:t2 => [:t1]) { |t| runlist << t.name }
49
51
  assert_equal ["t2"], t1.prerequisites
50
52
  assert_equal ["t1"], t2.prerequisites
51
- ex = assert_raise RuntimeError do
53
+ ex = assert_exception RuntimeError do
52
54
  t1.invoke
53
55
  end
54
56
  assert_match(/circular dependency/i, ex.message)
@@ -123,7 +125,7 @@ class TestTask < Test::Unit::TestCase
123
125
  def test_find
124
126
  task :tfind
125
127
  assert_equal "tfind", Task[:tfind].name
126
- ex = assert_raises(RuntimeError) { Task[:leaves] }
128
+ ex = assert_exception(RuntimeError) { Task[:leaves] }
127
129
  assert_equal "Don't know how to build task 'leaves'", ex.message
128
130
  end
129
131
 
@@ -181,7 +183,7 @@ class TestTask < Test::Unit::TestCase
181
183
  out = t1.investigation
182
184
  assert_match(/class:\s*Rake::Task/, out)
183
185
  assert_match(/needed:\s*true/, out)
184
- assert_match(/pre-requisites:\s*--t2/, out)
186
+ assert_match(/pre-requisites:\s*--t[23]/, out)
185
187
  end
186
188
 
187
189
 
@@ -220,6 +222,7 @@ end
220
222
  class TestTaskWithArguments < Test::Unit::TestCase
221
223
  include CaptureStdout
222
224
  include Rake
225
+ include TestMethods
223
226
 
224
227
  def setup
225
228
  Task.clear
@@ -257,7 +260,7 @@ class TestTaskWithArguments < Test::Unit::TestCase
257
260
  end
258
261
 
259
262
  def test_illegal_keys_in_task_name_hash
260
- assert_raise RuntimeError do
263
+ assert_exception RuntimeError do
261
264
  t = task(:t, :x, :y => 1, :needs => [:pre])
262
265
  end
263
266
  end