test/project1/test_project.rb in rant-0.3.0 vs test/project1/test_project.rb in rant-0.3.2

- old
+ new

@@ -1,8 +1,8 @@ require 'test/unit' -require 'rant' +require 'rant/rantlib' require 'tutil' # Ensure we run in testproject directory. $testProject1Dir = File.expand_path(File.dirname(__FILE__)) @@ -35,28 +35,28 @@ capture_std do assert_equal(Rant.run("create_target"), 0) end assert(File.exist?("target")) Rant.reset - sleep 2 + timeout capture_std do assert_equal(Rant.run("create_dep"), 0) end assert(File.exist?("dep")) - assert(sys.uptodate?("dep", "target"), + assert(Rant::Sys.uptodate?("dep", "target"), "`create_target' was run before `create_dep'") - sleep 2 + timeout capture_std do assert_equal(Rant.run("target"), 0) end assert(File.exist?("target")) assert(File.exist?("dep")) - assert(sys.uptodate?("target", "dep"), + assert(Rant::Sys.uptodate?("target", "dep"), "`target' should be newer than `dep'") t1 = File.mtime "target" Rant.reset - sleep 2 + timeout capture_std do assert_equal(Rant.run("target"), 0) end assert_equal(t1, File.mtime("target"), "`target' was already up to date") @@ -121,10 +121,35 @@ assert_equal(Rant.run("dir/sub2"), 0) end assert(test(?f, "dir/sub2/postprocess"), "dir/sub2/postprocess should have been created by block supplied to directory task") end + def test_directory_pre_postprocess + capture_std do + assert_equal(0, Rant.run("dir/sub3")) + end + assert(test(?d, "dir/sub3")) + assert(test(?e, "dep1"), "dep1 is a prerequisite") + assert(test(?e, "dir/sub3/postprocess")) + old_mtime = File.mtime "dir/sub3" + assert_equal(old_mtime, File.mtime("dep1")) + timeout + capture_std do + assert_equal(0, Rant.run("dir/sub3")) + end + assert_equal(old_mtime, File.mtime("dir/sub3"), + "no prerequisite requires update") + assert_equal(old_mtime, File.mtime("dir/sub3/postprocess")) + capture_std do + assert_equal(0, Rant.run(%w(-a dep1))) + assert(File.mtime("dep1") > old_mtime) + timeout + assert_equal(0, Rant.run("dir/sub3")) + assert(File.mtime("dir/sub3") > old_mtime) + assert(File.mtime("dir/sub3/postprocess") > old_mtime) + end + end def test_order capture_std do assert_equal(Rant.run("order"), 0) end assert(File.exist?("order1")) @@ -156,11 +181,11 @@ assert_equal(Rant.run("inc"), 0) end assert(test(?f, "inc")) assert(test(?f, "incdep")) old_mtime = test(?M, "incdep") - sleep 2 + timeout capture_std do assert_equal(Rant.run(%w(--force-run incdep)), 0, "--force-run should unconditionally run `incdep'") end assert(old_mtime < test(?M, "incdep"), @@ -183,10 +208,10 @@ assert_equal(Rant.run("task_one"), 0) end assert(test(?e, "one_target"), "one_target should get `touched' by task_one") old_mtime = test(?M, "one_target") - sleep 2 + timeout capture_std do assert_equal(Rant.run("task_one"), 0) end assert_equal(test(?M, "one_target"), old_mtime) end