summaryrefslogtreecommitdiffstats
path: root/src/manifest_parser_test.cc
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2013-10-27 19:38:34 (GMT)
committerNico Weber <nicolasweber@gmx.de>2013-10-27 19:38:34 (GMT)
commita36038f990db1b347ecb4cc3bfb984fc3045d04f (patch)
treebcfc2ea838659f73df2bac99cf9ea5181a860dce /src/manifest_parser_test.cc
parentdc9bd0a90d739bc79b8d7130817bf0f0d2914eeb (diff)
downloadNinja-a36038f990db1b347ecb4cc3bfb984fc3045d04f.zip
Ninja-a36038f990db1b347ecb4cc3bfb984fc3045d04f.tar.gz
Ninja-a36038f990db1b347ecb4cc3bfb984fc3045d04f.tar.bz2
Add a test that shows that there is a single global namespace for rules.
Diffstat (limited to 'src/manifest_parser_test.cc')
-rw-r--r--src/manifest_parser_test.cc15
1 files changed, 15 insertions, 0 deletions
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(