summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/manifest_parser.cc8
-rw-r--r--src/manifest_parser.h2
-rw-r--r--src/manifest_parser_test.cc11
3 files changed, 17 insertions, 4 deletions
diff --git a/src/manifest_parser.cc b/src/manifest_parser.cc
index a1bb904..20be7f3 100644
--- a/src/manifest_parser.cc
+++ b/src/manifest_parser.cc
@@ -29,12 +29,14 @@ ManifestParser::ManifestParser(State* state, FileReader* file_reader)
env_ = &state->bindings_;
}
-bool ManifestParser::Load(const string& filename, string* err) {
+bool ManifestParser::Load(const string& filename, string* err, Lexer* parent) {
METRIC_RECORD(".ninja parse");
string contents;
string read_err;
if (!file_reader_->ReadFile(filename, &contents, &read_err)) {
*err = "loading '" + filename + "': " + read_err;
+ if (parent)
+ parent->Error(string(*err), err);
return false;
}
@@ -358,8 +360,8 @@ bool ManifestParser::ParseFileInclude(bool new_scope, string* err) {
subparser.env_ = env_;
}
- if (!subparser.Load(path, err))
- return lexer_.Error(string(*err), err);
+ if (!subparser.Load(path, err, &lexer_))
+ return false;
if (!ExpectToken(Lexer::NEWLINE, err))
return false;
diff --git a/src/manifest_parser.h b/src/manifest_parser.h
index 967dfdd..5212f72 100644
--- a/src/manifest_parser.h
+++ b/src/manifest_parser.h
@@ -35,7 +35,7 @@ struct ManifestParser {
ManifestParser(State* state, FileReader* file_reader);
/// Load and parse a file.
- bool Load(const string& filename, string* err);
+ bool Load(const string& filename, string* err, Lexer* parent=NULL);
/// Parse a text string of input. Used by tests.
bool ParseTest(const string& input, string* err) {
diff --git a/src/manifest_parser_test.cc b/src/manifest_parser_test.cc
index b333549..67c422b 100644
--- a/src/manifest_parser_test.cc
+++ b/src/manifest_parser_test.cc
@@ -762,6 +762,17 @@ TEST_F(ParserTest, Include) {
EXPECT_EQ("inner", state.bindings_.LookupVariable("var"));
}
+TEST_F(ParserTest, BrokenInclude) {
+ files_["include.ninja"] = "build\n";
+ ManifestParser parser(&state, this);
+ string err;
+ EXPECT_FALSE(parser.ParseTest("include include.ninja\n", &err));
+ EXPECT_EQ("include.ninja:1: expected path\n"
+ "build\n"
+ " ^ near here"
+ , err);
+}
+
TEST_F(ParserTest, Implicit) {
ASSERT_NO_FATAL_FAILURE(AssertParse(
"rule cat\n"