From a36038f990db1b347ecb4cc3bfb984fc3045d04f Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 27 Oct 2013 12:38:34 -0700 Subject: Add a test that shows that there is a single global namespace for rules. --- src/manifest_parser_test.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/manifest_parser_test.cc b/src/manifest_parser_test.cc index 5ed1584..0b4c042 100644 --- a/src/manifest_parser_test.cc +++ b/src/manifest_parser_test.cc @@ -762,6 +762,21 @@ TEST_F(ParserTest, MissingSubNinja) { , err); } +TEST_F(ParserTest, DuplicateRuleInDifferentSubninjas) { + // Test that rules live in a global namespace and aren't scoped to subninjas. + files_["test.ninja"] = "rule cat\n" + " command = cat\n"; + ManifestParser parser(&state, this); + string err; + EXPECT_FALSE(parser.ParseTest("rule cat\n" + " command = cat\n" + "subninja test.ninja\n", &err)); + EXPECT_EQ("test.ninja:1: duplicate rule 'cat'\n" + "rule cat\n" + " ^ near here" + , err); +} + TEST_F(ParserTest, Include) { files_["include.ninja"] = "var = inner\n"; ASSERT_NO_FATAL_FAILURE(AssertParse( -- cgit v0.12