From 2d645be0f0ffb1ad257f72ae89182e1d153ca617 Mon Sep 17 00:00:00 2001 From: Mohamed Bamakhrama Date: Sun, 8 Mar 2015 04:13:12 +0100 Subject: Added a new test to illustrate scoped rules The new test shows the added value of scoped rules by demonstrating a multi-level build where a single rules file gets included at all the levels. By scoping rules, this is possible. --- src/manifest_parser_test.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/manifest_parser_test.cc b/src/manifest_parser_test.cc index 301a35c..e13d728 100644 --- a/src/manifest_parser_test.cc +++ b/src/manifest_parser_test.cc @@ -833,6 +833,19 @@ TEST_F(ParserTest, DuplicateRuleInDifferentSubninjas) { "subninja test.ninja\n", &err)); } +TEST_F(ParserTest, DuplicateRuleInDifferentSubninjasWithInclude) { + // Test that rules are scoped to subninjas even with includes. + files_["rules.ninja"] = "rule cat\n" + " command = cat\n"; + files_["test.ninja"] = "include rules.ninja\n" + "build x : cat\n"; + ManifestParser parser(&state, this); + string err; + EXPECT_TRUE(parser.ParseTest("include rules.ninja\n" + "subninja test.ninja\n" + "build y : cat\n", &err)); +} + TEST_F(ParserTest, Include) { files_["include.ninja"] = "var = inner\n"; ASSERT_NO_FATAL_FAILURE(AssertParse( -- cgit v0.12