summaryrefslogtreecommitdiffstats
path: root/src/graph_test.cc
diff options
context:
space:
mode:
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());
+}