test/test_rake_task.rb in rake-10.0.3 vs test/test_rake_task.rb in rake-10.0.4
- old
+ new
@@ -30,20 +30,19 @@
assert_equal 1, t.locations.size
assert_match(/#{Regexp.quote(__FILE__)}/, t.locations.first)
end
def test_inspect
-# t = task(:foo, :needs => [:bar, :baz])
t = task(:foo => [:bar, :baz])
assert_equal "<Rake::Task foo => [bar, baz]>", t.inspect
end
def test_invoke
runlist = []
t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
- t2 = task(:t2) { |t| runlist << t.name }
- t3 = task(:t3) { |t| runlist << t.name }
+ task(:t2) { |t| runlist << t.name }
+ task(:t3) { |t| runlist << t.name }
assert_equal ["t2", "t3"], t1.prerequisites
t1.invoke
assert_equal ["t2", "t3", "t1"], runlist
end
@@ -86,12 +85,12 @@
end
def test_no_double_invoke
runlist = []
t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
- t2 = task(:t2 => [:t3]) { |t| runlist << t.name }
- t3 = task(:t3) { |t| runlist << t.name }
+ task(:t2 => [:t3]) { |t| runlist << t.name }
+ task(:t3) { |t| runlist << t.name }
t1.invoke
assert_equal ["t3", "t2", "t1"], runlist
end
def test_can_double_invoke_with_reenable
@@ -202,11 +201,11 @@
assert_equal [b, c], a.prerequisite_tasks
end
def test_prerequiste_tasks_fails_if_prerequisites_are_undefined
a = task :a => ["b", "c"]
- b = task :b
+ task :b
assert_raises(RuntimeError) do
a.prerequisite_tasks
end
end
@@ -219,13 +218,38 @@
c = task :c
assert_equal [b, c], a.prerequisite_tasks
end
- def test_timestamp_returns_now_if_all_prereqs_have_no_times
+ def test_all_prerequisite_tasks_includes_all_prerequisites
+ a = task :a => "b"
+ b = task :b => ["c", "d"]
+ c = task :c => "e"
+ d = task :d
+ e = task :e
+
+ assert_equal [b, c, d, e], a.all_prerequisite_tasks.sort_by { |t| t.name }
+ end
+
+ def test_all_prerequisite_tasks_does_not_include_duplicates
a = task :a => ["b", "c"]
- b = task :b
+ b = task :b => "c"
c = task :c
+
+ assert_equal [b, c], a.all_prerequisite_tasks.sort_by { |t| t.name }
+ end
+
+ def test_all_prerequisite_tasks_includes_self_on_cyclic_dependencies
+ a = task :a => "b"
+ b = task :b => "a"
+
+ assert_equal [a, b], a.all_prerequisite_tasks.sort_by { |t| t.name }
+ end
+
+ def test_timestamp_returns_now_if_all_prereqs_have_no_times
+ a = task :a => ["b", "c"]
+ task :b
+ task :c
assert_in_delta Time.now, a.timestamp, 0.1, 'computer too slow?'
end
def test_timestamp_returns_latest_prereq_timestamp