summaryrefslogtreecommitdiffstats
path: root/src/manifest_parser_test.cc
diff options
context:
space:
mode:
authorScott Graham <scottmg@chromium.org>2016-01-27 19:10:34 (GMT)
committerScott Graham <scottmg@chromium.org>2016-01-27 19:10:34 (GMT)
commit56bab441b70e6f09f3faf7936118c309f9ce48cb (patch)
tree1b71d58b91645b4e770ad5bbf2a40d635a0069d5 /src/manifest_parser_test.cc
parent233acbad4dea6410b567f077ecc8699525a46683 (diff)
downloadNinja-56bab441b70e6f09f3faf7936118c309f9ce48cb.zip
Ninja-56bab441b70e6f09f3faf7936118c309f9ce48cb.tar.gz
Ninja-56bab441b70e6f09f3faf7936118c309f9ce48cb.tar.bz2
dupe_edge_should_err from bool to enum
Diffstat (limited to 'src/manifest_parser_test.cc')
-rw-r--r--src/manifest_parser_test.cc92
1 files changed, 46 insertions, 46 deletions
diff --git a/src/manifest_parser_test.cc b/src/manifest_parser_test.cc
index dc90599..a18433a 100644
--- a/src/manifest_parser_test.cc
+++ b/src/manifest_parser_test.cc
@@ -24,7 +24,7 @@
struct ParserTest : public testing::Test,
public ManifestParser::FileReader {
void AssertParse(const char* input) {
- ManifestParser parser(&state, this, false);
+ ManifestParser parser(&state, this, kDupeEdgeActionWarn);
string err;
EXPECT_TRUE(parser.ParseTest(input, &err));
ASSERT_EQ("", err);
@@ -371,7 +371,7 @@ TEST_F(ParserTest, DuplicateEdgeWithMultipleOutputsError) {
"build out1 out2: cat in1\n"
"build out1: cat in2\n"
"build final: cat out1\n";
- ManifestParser parser(&state, this, /*dupe_edges_should_err=*/true);
+ ManifestParser parser(&state, this, kDupeEdgeActionError);
string err;
EXPECT_FALSE(parser.ParseTest(kInput, &err));
EXPECT_EQ("input:5: multiple rules generate out1 [-w dupbuild=err]\n", err);
@@ -386,7 +386,7 @@ TEST_F(ParserTest, DuplicateEdgeInIncludedFile) {
"build final: cat out1\n";
const char kInput[] =
"subninja sub.ninja\n";
- ManifestParser parser(&state, this, /*dupe_edges_should_err=*/true);
+ ManifestParser parser(&state, this, kDupeEdgeActionError);
string err;
EXPECT_FALSE(parser.ParseTest(kInput, &err));
EXPECT_EQ("sub.ninja:5: multiple rules generate out1 [-w dupbuild=err]\n",
@@ -404,7 +404,7 @@ TEST_F(ParserTest, ReservedWords) {
TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest(string("subn", 4), &err));
EXPECT_EQ("input:1: expected '=', got eof\n"
@@ -415,7 +415,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("foobar", &err));
EXPECT_EQ("input:1: expected '=', got eof\n"
@@ -426,7 +426,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("x 3", &err));
EXPECT_EQ("input:1: expected '=', got identifier\n"
@@ -437,7 +437,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("x = 3", &err));
EXPECT_EQ("input:1: unexpected EOF\n"
@@ -448,7 +448,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("x = 3\ny 2", &err));
EXPECT_EQ("input:2: expected '=', got identifier\n"
@@ -459,7 +459,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("x = $", &err));
EXPECT_EQ("input:1: bad $-escape (literal $ must be written as $$)\n"
@@ -470,7 +470,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("x = $\n $[\n", &err));
EXPECT_EQ("input:2: bad $-escape (literal $ must be written as $$)\n"
@@ -481,7 +481,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("x = a$\n b$\n $\n", &err));
EXPECT_EQ("input:4: unexpected EOF\n"
@@ -490,7 +490,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("build\n", &err));
EXPECT_EQ("input:1: expected path\n"
@@ -501,7 +501,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("build x: y z\n", &err));
EXPECT_EQ("input:1: unknown build rule 'y'\n"
@@ -512,7 +512,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("build x:: y z\n", &err));
EXPECT_EQ("input:1: expected build command name\n"
@@ -523,7 +523,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("rule cat\n command = cat ok\n"
"build x: cat $\n :\n",
@@ -536,7 +536,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("rule cat\n",
&err));
@@ -545,7 +545,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("rule cat\n"
" command = echo\n"
@@ -559,7 +559,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("rule cat\n"
" command = echo\n"
@@ -571,7 +571,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("rule cat\n"
" command = ${fafsd\n"
@@ -586,7 +586,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("rule cat\n"
" command = cat\n"
@@ -601,7 +601,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("rule cat\n"
" command = cat\n"
@@ -615,7 +615,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("rule %foo\n",
&err));
@@ -624,7 +624,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("rule cc\n"
" command = foo\n"
@@ -638,7 +638,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("rule cc\n command = foo\n"
"build $.: cc bar.cc\n",
@@ -651,7 +651,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("rule cc\n command = foo\n && bar",
&err));
@@ -660,7 +660,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("rule cc\n command = foo\n"
"build $: cc bar.cc\n",
@@ -673,7 +673,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("default\n",
&err));
@@ -685,7 +685,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("default nonexistent\n",
&err));
@@ -697,7 +697,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("rule r\n command = r\n"
"build b: r\n"
@@ -711,7 +711,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("default $a\n", &err));
EXPECT_EQ("input:1: empty path\n"
@@ -722,7 +722,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("rule r\n"
" command = r\n"
@@ -734,7 +734,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
// the indented blank line must terminate the rule
// this also verifies that "unexpected (token)" errors are correct
@@ -747,7 +747,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("pool\n", &err));
EXPECT_EQ("input:1: expected pool name\n", err);
@@ -755,7 +755,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("pool foo\n", &err));
EXPECT_EQ("input:2: expected 'depth =' line\n", err);
@@ -763,7 +763,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("pool foo\n"
" depth = 4\n"
@@ -776,7 +776,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("pool foo\n"
" depth = -1\n", &err));
@@ -788,7 +788,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("pool foo\n"
" bar = 1\n", &err));
@@ -800,7 +800,7 @@ TEST_F(ParserTest, Errors) {
{
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
// Pool names are dereferenced at edge parsing time.
EXPECT_FALSE(parser.ParseTest("rule run\n"
@@ -813,7 +813,7 @@ TEST_F(ParserTest, Errors) {
TEST_F(ParserTest, MissingInput) {
State state;
- ManifestParser parser(&state, this, false);
+ ManifestParser parser(&state, this, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.Load("build.ninja", &err));
EXPECT_EQ("loading 'build.ninja': No such file or directory", err);
@@ -821,7 +821,7 @@ TEST_F(ParserTest, MissingInput) {
TEST_F(ParserTest, MultipleOutputs) {
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_TRUE(parser.ParseTest("rule cc\n command = foo\n depfile = bar\n"
"build a.o b.o: cc c.cc\n",
@@ -831,7 +831,7 @@ TEST_F(ParserTest, MultipleOutputs) {
TEST_F(ParserTest, MultipleOutputsWithDeps) {
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("rule cc\n command = foo\n deps = gcc\n"
"build a.o b.o: cc c.cc\n",
@@ -866,7 +866,7 @@ TEST_F(ParserTest, SubNinja) {
}
TEST_F(ParserTest, MissingSubNinja) {
- ManifestParser parser(&state, this, false);
+ ManifestParser parser(&state, this, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("subninja foo.ninja\n", &err));
EXPECT_EQ("input:1: loading 'foo.ninja': No such file or directory\n"
@@ -879,7 +879,7 @@ TEST_F(ParserTest, DuplicateRuleInDifferentSubninjas) {
// Test that rules are scoped to subninjas.
files_["test.ninja"] = "rule cat\n"
" command = cat\n";
- ManifestParser parser(&state, this, false);
+ ManifestParser parser(&state, this, kDupeEdgeActionWarn);
string err;
EXPECT_TRUE(parser.ParseTest("rule cat\n"
" command = cat\n"
@@ -892,7 +892,7 @@ TEST_F(ParserTest, DuplicateRuleInDifferentSubninjasWithInclude) {
" command = cat\n";
files_["test.ninja"] = "include rules.ninja\n"
"build x : cat\n";
- ManifestParser parser(&state, this, false);
+ ManifestParser parser(&state, this, kDupeEdgeActionWarn);
string err;
EXPECT_TRUE(parser.ParseTest("include rules.ninja\n"
"subninja test.ninja\n"
@@ -912,7 +912,7 @@ TEST_F(ParserTest, Include) {
TEST_F(ParserTest, BrokenInclude) {
files_["include.ninja"] = "build\n";
- ManifestParser parser(&state, this, false);
+ ManifestParser parser(&state, this, kDupeEdgeActionWarn);
string err;
EXPECT_FALSE(parser.ParseTest("include include.ninja\n", &err));
EXPECT_EQ("include.ninja:1: expected path\n"
@@ -992,7 +992,7 @@ TEST_F(ParserTest, UTF8) {
TEST_F(ParserTest, CRLF) {
State state;
- ManifestParser parser(&state, NULL, false);
+ ManifestParser parser(&state, NULL, kDupeEdgeActionWarn);
string err;
EXPECT_TRUE(parser.ParseTest("# comment with crlf\r\n", &err));