summaryrefslogtreecommitdiffstats
path: root/src/graph_test.cc
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-09-13 22:33:40 (GMT)
committerEvan Martin <martine@danga.com>2012-09-13 22:33:40 (GMT)
commit7096bf1507f98be981aa14ffd9ed5a4a8b1c1494 (patch)
tree10f75334ddb1dc86c2cc85db0cab93ca672d39de /src/graph_test.cc
parent50af448b293b411bde5232931525574aba3bb451 (diff)
parent06fa62352d1e9868409b299ffc8abc8f4cd9a39d (diff)
downloadNinja-7096bf1507f98be981aa14ffd9ed5a4a8b1c1494.zip
Ninja-7096bf1507f98be981aa14ffd9ed5a4a8b1c1494.tar.gz
Ninja-7096bf1507f98be981aa14ffd9ed5a4a8b1c1494.tar.bz2
version 1.0.0v1.0.0
Diffstat (limited to 'src/graph_test.cc')
-rw-r--r--src/graph_test.cc57
1 files changed, 52 insertions, 5 deletions
diff --git a/src/graph_test.cc b/src/graph_test.cc
index 07a1936..5b25c2f 100644
--- a/src/graph_test.cc
+++ b/src/graph_test.cc
@@ -17,7 +17,10 @@
#include "test.h"
struct GraphTest : public StateTestWithBuiltinRules {
+ GraphTest() : scan_(&state_, NULL, &fs_) {}
+
VirtualFileSystem fs_;
+ DependencyScan scan_;
};
TEST_F(GraphTest, MissingImplicit) {
@@ -28,7 +31,7 @@ TEST_F(GraphTest, MissingImplicit) {
Edge* edge = GetNode("out")->in_edge();
string err;
- EXPECT_TRUE(edge->RecomputeDirty(&state_, &fs_, &err));
+ EXPECT_TRUE(scan_.RecomputeDirty(edge, &err));
ASSERT_EQ("", err);
// A missing implicit dep *should* make the output dirty.
@@ -46,7 +49,7 @@ TEST_F(GraphTest, ModifiedImplicit) {
Edge* edge = GetNode("out")->in_edge();
string err;
- EXPECT_TRUE(edge->RecomputeDirty(&state_, &fs_, &err));
+ EXPECT_TRUE(scan_.RecomputeDirty(edge, &err));
ASSERT_EQ("", err);
// A modified implicit dep should make the output dirty.
@@ -66,7 +69,7 @@ TEST_F(GraphTest, FunkyMakefilePath) {
Edge* edge = GetNode("out.o")->in_edge();
string err;
- EXPECT_TRUE(edge->RecomputeDirty(&state_, &fs_, &err));
+ EXPECT_TRUE(scan_.RecomputeDirty(edge, &err));
ASSERT_EQ("", err);
// implicit.h has changed, though our depfile refers to it with a
@@ -89,7 +92,7 @@ TEST_F(GraphTest, ExplicitImplicit) {
Edge* edge = GetNode("out.o")->in_edge();
string err;
- EXPECT_TRUE(edge->RecomputeDirty(&state_, &fs_, &err));
+ EXPECT_TRUE(scan_.RecomputeDirty(edge, &err));
ASSERT_EQ("", err);
// We have both an implicit and an explicit dep on implicit.h.
@@ -110,7 +113,7 @@ TEST_F(GraphTest, PathWithCurrentDirectory) {
Edge* edge = GetNode("out.o")->in_edge();
string err;
- EXPECT_TRUE(edge->RecomputeDirty(&state_, &fs_, &err));
+ EXPECT_TRUE(scan_.RecomputeDirty(edge, &err));
ASSERT_EQ("", err);
EXPECT_FALSE(GetNode("out.o")->dirty());
@@ -140,3 +143,47 @@ TEST_F(GraphTest, VarInOutQuoteSpaces) {
EXPECT_EQ("cat nospace \"with space\" nospace2 > \"a b\"",
edge->EvaluateCommand());
}
+
+// Regression test for https://github.com/martine/ninja/issues/380
+TEST_F(GraphTest, DepfileWithCanonicalizablePath) {
+ ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
+"rule catdep\n"
+" depfile = $out.d\n"
+" command = cat $in > $out\n"
+"build ./out.o: catdep ./foo.cc\n"));
+ fs_.Create("foo.cc", 1, "");
+ fs_.Create("out.o.d", 1, "out.o: bar/../foo.cc\n");
+ fs_.Create("out.o", 1, "");
+
+ Edge* edge = GetNode("out.o")->in_edge();
+ string err;
+ EXPECT_TRUE(scan_.RecomputeDirty(edge, &err));
+ ASSERT_EQ("", err);
+
+ EXPECT_FALSE(GetNode("out.o")->dirty());
+}
+
+// Regression test for https://github.com/martine/ninja/issues/404
+TEST_F(GraphTest, DepfileRemoved) {
+ ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
+"rule catdep\n"
+" depfile = $out.d\n"
+" command = cat $in > $out\n"
+"build ./out.o: catdep ./foo.cc\n"));
+ fs_.Create("foo.h", 1, "");
+ fs_.Create("foo.cc", 1, "");
+ fs_.Create("out.o.d", 2, "out.o: foo.h\n");
+ fs_.Create("out.o", 2, "");
+
+ Edge* edge = GetNode("out.o")->in_edge();
+ string err;
+ EXPECT_TRUE(scan_.RecomputeDirty(edge, &err));
+ ASSERT_EQ("", err);
+ EXPECT_FALSE(GetNode("out.o")->dirty());
+
+ state_.Reset();
+ fs_.RemoveFile("out.o.d");
+ EXPECT_TRUE(scan_.RecomputeDirty(edge, &err));
+ ASSERT_EQ("", err);
+ EXPECT_TRUE(GetNode("out.o")->dirty());
+}