diff options
author | Nico Weber <nicolasweber@gmx.de> | 2018-04-06 16:43:49 (GMT) |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2018-04-06 16:45:32 (GMT) |
commit | 001b1e3cf01aa4befe011b7f17bcd22c12d4c8c4 (patch) | |
tree | dc94861ab8065feb21e438fb3a745cd0ed82fe59 /src/manifest_parser_test.cc | |
parent | 04ba59b2ad986bd5765b14c5b497ccb0a2e909d4 (diff) | |
download | Ninja-001b1e3cf01aa4befe011b7f17bcd22c12d4c8c4.zip Ninja-001b1e3cf01aa4befe011b7f17bcd22c12d4c8c4.tar.gz Ninja-001b1e3cf01aa4befe011b7f17bcd22c12d4c8c4.tar.bz2 |
Improve location of error messages around identifiers.
Lexer::ReadIdent() now sets last_token_ before returning, like
Lexer::ReadEvalString() does. So all "expected identifiers" and things
that call ReadIdent (pool parser, rule parser, let parser, code parsing
the rule name after a : in a build line) now point the "^ near here" at
what was there instead of the previous last_token
According to manifest_parser_perftest, this is perf-neutral.
Diffstat (limited to 'src/manifest_parser_test.cc')
-rw-r--r-- | src/manifest_parser_test.cc | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/manifest_parser_test.cc b/src/manifest_parser_test.cc index 39ed810..c91d8d1 100644 --- a/src/manifest_parser_test.cc +++ b/src/manifest_parser_test.cc @@ -523,7 +523,7 @@ TEST_F(ParserTest, Errors) { EXPECT_FALSE(parser.ParseTest("build x: y z\n", &err)); EXPECT_EQ("input:1: unknown build rule 'y'\n" "build x: y z\n" - " ^ near here" + " ^ near here" , err); } @@ -534,7 +534,7 @@ TEST_F(ParserTest, Errors) { EXPECT_FALSE(parser.ParseTest("build x:: y z\n", &err)); EXPECT_EQ("input:1: expected build command name\n" "build x:: y z\n" - " ^ near here" + " ^ near here" , err); } @@ -636,7 +636,10 @@ TEST_F(ParserTest, Errors) { string err; EXPECT_FALSE(parser.ParseTest("rule %foo\n", &err)); - EXPECT_EQ("input:1: expected rule name\n", err); + EXPECT_EQ("input:1: expected rule name\n" + "rule %foo\n" + " ^ near here", + err); } { @@ -672,7 +675,10 @@ TEST_F(ParserTest, Errors) { string err; EXPECT_FALSE(parser.ParseTest("rule cc\n command = foo\n && bar", &err)); - EXPECT_EQ("input:3: expected variable name\n", err); + EXPECT_EQ("input:3: expected variable name\n" + " && bar\n" + " ^ near here", + err); } { @@ -767,7 +773,9 @@ TEST_F(ParserTest, Errors) { ManifestParser parser(&local_state, NULL); string err; EXPECT_FALSE(parser.ParseTest("pool\n", &err)); - EXPECT_EQ("input:1: expected pool name\n", err); + EXPECT_EQ("input:1: expected pool name\n" + "pool\n" + " ^ near here", err); } { |