aboutsummaryrefslogtreecommitdiffstats
path: root/test/rake/test_rake_task.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-15 21:59:37 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-15 21:59:37 +0000
commit9c66bad9f3d522d50d4a45ef8a3a92abbf93229f (patch)
tree8fc1ae219e41bdd711442b1d35149da4f45dfa8a /test/rake/test_rake_task.rb
parentbfc95c6e1639edc909338ef4d20d990caf6f630e (diff)
downloadruby-9c66bad9f3d522d50d4a45ef8a3a92abbf93229f.tar.gz
* lib/rake*: Updated to rake 0.9.3
* test/rake*: ditto * bin/rake: ditto * NEWS: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rake/test_rake_task.rb')
-rw-r--r--test/rake/test_rake_task.rb51
1 files changed, 50 insertions, 1 deletions
diff --git a/test/rake/test_rake_task.rb b/test/rake/test_rake_task.rb
index a5bc693237..836e930ee4 100644
--- a/test/rake/test_rake_task.rb
+++ b/test/rake/test_rake_task.rb
@@ -104,10 +104,12 @@ class TestRakeTask < Rake::TestCase
end
def test_clear
+ desc "a task"
t = task("t" => "a") { }
t.clear
assert t.prerequisites.empty?, "prerequisites should be empty"
assert t.actions.empty?, "actions should be empty"
+ assert_nil t.comment, "comments should be empty"
end
def test_clear_prerequisites
@@ -123,6 +125,22 @@ class TestRakeTask < Rake::TestCase
assert t.actions.empty?, "actions should be empty"
end
+ def test_clear_comments
+ desc "the original foo"
+ task :foo => [:x] do
+ # Dummy action
+ end
+
+ task(:foo).clear_comments
+
+ desc "a slightly different foo"
+ task :foo
+
+ assert_equal "a slightly different foo", task(:foo).comment
+ assert_equal ["x"], task(:foo).prerequisites
+ assert_equal 1, task(:foo).actions.size
+ end
+
def test_find
task :tfind
assert_equal "tfind", Task[:tfind].name
@@ -223,6 +241,38 @@ class TestRakeTask < Rake::TestCase
assert_in_delta now + 10, a.timestamp, 0.1, 'computer too slow?'
end
+ def test_always_multitask
+ mx = Mutex.new
+ result = []
+
+ t_a = task(:a) do |t|
+ sleep 0.02
+ mx.synchronize{ result << t.name }
+ end
+
+ t_b = task(:b) do |t|
+ mx.synchronize{ result << t.name }
+ end
+
+ t_c = task(:c => [:a,:b]) do |t|
+ mx.synchronize{ result << t.name }
+ end
+
+ t_c.invoke
+
+ # task should always run in order
+ assert_equal ['a', 'b', 'c'], result
+
+ [t_a, t_b, t_c].each { |t| t.reenable }
+ result.clear
+
+ Rake.application.options.always_multitask = true
+ t_c.invoke
+
+ # with multitask, task 'b' should grab the mutex first
+ assert_equal ['b', 'a', 'c'], result
+ end
+
def test_investigation_output
t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
task(:t2)
@@ -264,4 +314,3 @@ class TestRakeTask < Rake::TestCase
assert_equal "HI", t.comment
end
end
-