summaryrefslogtreecommitdiffstats
path: root/src/graph_test.cc
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit+github@google.com>2022-02-21 18:32:35 (GMT)
committerDavid 'Digit' Turner <digit+github@google.com>2022-03-21 13:44:26 (GMT)
commit988c847ee728de5520d07051843c02a17dd44777 (patch)
tree2576c688b1db657ebaa21a92a02bada0dca81e6f /src/graph_test.cc
parent1463b1fc3135358ebb19d29448e99ef62e5f1ee6 (diff)
downloadNinja-988c847ee728de5520d07051843c02a17dd44777.zip
Ninja-988c847ee728de5520d07051843c02a17dd44777.tar.gz
Ninja-988c847ee728de5520d07051843c02a17dd44777.tar.bz2
Make the output of `ninja -t inputs` deterministic
This sorts the output of `ninja -t inputs` to make it deterministic and remove duplicates, and adds a regression test in output_test.py + Ensure all inputs are listed, not only explicit ones. + Document the `inputs` tool in doc/manual.asciidoc.
Diffstat (limited to 'src/graph_test.cc')
-rw-r--r--src/graph_test.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/graph_test.cc b/src/graph_test.cc
index 5314bc5..9dba8af 100644
--- a/src/graph_test.cc
+++ b/src/graph_test.cc
@@ -215,6 +215,39 @@ TEST_F(GraphTest, RootNodes) {
}
}
+TEST_F(GraphTest, CollectInputs) {
+ ASSERT_NO_FATAL_FAILURE(AssertParse(
+ &state_,
+ "build out$ 1: cat in1 in2 in$ with$ space | implicit || order_only\n"));
+
+ std::vector<std::string> inputs;
+ Edge* edge = GetNode("out 1")->in_edge();
+
+ // Test without shell escaping.
+ inputs.clear();
+ edge->CollectInputs(false, &inputs);
+ EXPECT_EQ(5u, inputs.size());
+ EXPECT_EQ("in1", inputs[0]);
+ EXPECT_EQ("in2", inputs[1]);
+ EXPECT_EQ("in with space", inputs[2]);
+ EXPECT_EQ("implicit", inputs[3]);
+ EXPECT_EQ("order_only", inputs[4]);
+
+ // Test with shell escaping.
+ inputs.clear();
+ edge->CollectInputs(true, &inputs);
+ EXPECT_EQ(5u, inputs.size());
+ EXPECT_EQ("in1", inputs[0]);
+ EXPECT_EQ("in2", inputs[1]);
+#ifdef _WIN32
+ EXPECT_EQ("\"in with space\"", inputs[2]);
+#else
+ EXPECT_EQ("'in with space'", inputs[2]);
+#endif
+ EXPECT_EQ("implicit", inputs[3]);
+ EXPECT_EQ("order_only", inputs[4]);
+}
+
TEST_F(GraphTest, VarInOutPathEscaping) {
ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
"build a$ b: cat no'space with$ space$$ no\"space2\n"));