summaryrefslogtreecommitdiffstats
path: root/src/manifest_parser_test.cc
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2015-03-19 23:42:06 (GMT)
committerNico Weber <nicolasweber@gmx.de>2015-03-19 23:42:06 (GMT)
commitf5c5789aad8001e15a7e4f1ee0dee0c2b688e993 (patch)
tree9e26b5bbf6486a710eba81c0d0214b2fb3f3e348 /src/manifest_parser_test.cc
parent20a840539ce87a343b414f52a3330706a731b044 (diff)
downloadNinja-f5c5789aad8001e15a7e4f1ee0dee0c2b688e993.zip
Ninja-f5c5789aad8001e15a7e4f1ee0dee0c2b688e993.tar.gz
Ninja-f5c5789aad8001e15a7e4f1ee0dee0c2b688e993.tar.bz2
Another crash fix for duplicate edges. Fixes #939.
Patch #933 fixed a crash with duplicate edges by not adding edges to the graph if all the edge's outputs are already built by other edges. However, it added the edge to the out_edges of the edge's input nodes before deleting it, letting inputs refer to dead edges. To fix, move the check for deleting an edge above the code that adds inputs. Expand VerifyGraph() to check that nodes don't refer to edges that aren't present in the state.
Diffstat (limited to 'src/manifest_parser_test.cc')
-rw-r--r--src/manifest_parser_test.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/manifest_parser_test.cc b/src/manifest_parser_test.cc
index 7e38fc6..7e72b34 100644
--- a/src/manifest_parser_test.cc
+++ b/src/manifest_parser_test.cc
@@ -353,6 +353,17 @@ TEST_F(ParserTest, DuplicateEdgeWithMultipleOutputs) {
// That's all the checking that this test needs.
}
+TEST_F(ParserTest, NoDeadPointerFromDuplicateEdge) {
+ ASSERT_NO_FATAL_FAILURE(AssertParse(
+"rule cat\n"
+" command = cat $in > $out\n"
+"build out: cat in\n"
+"build out: cat in\n"
+));
+ // AssertParse() checks that the generated build graph is self-consistent.
+ // That's all the checking that this test needs.
+}
+
TEST_F(ParserTest, ReservedWords) {
ASSERT_NO_FATAL_FAILURE(AssertParse(
"rule build\n"