From 8b929cf7c82b5ff84a874c5a25e919446c3874d5 Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Mon, 19 Dec 2011 10:59:29 -0800 Subject: [PATCH] split out depfile parser tests into new file --- configure.py | 1 + src/depfile_parser_test.cc | 50 ++++++++++++++++++++++++++++++++++++++ src/parsers_test.cc | 34 -------------------------- 3 files changed, 51 insertions(+), 34 deletions(-) create mode 100644 src/depfile_parser_test.cc diff --git a/configure.py b/configure.py index 0267290..400cf42 100755 --- a/configure.py +++ b/configure.py @@ -189,6 +189,7 @@ objs = [] for name in ['build_log_test', 'build_test', 'clean_test', + 'depfile_parser_test', 'disk_interface_test', 'edit_distance_test', 'eval_env_test', diff --git a/src/depfile_parser_test.cc b/src/depfile_parser_test.cc new file mode 100644 index 0000000..3258529 --- /dev/null +++ b/src/depfile_parser_test.cc @@ -0,0 +1,50 @@ +// Copyright 2011 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "depfile_parser.h" + +#include + +TEST(DepfileParser, Basic) { + DepfileParser parser; + string err; + EXPECT_TRUE(parser.Parse( +"build/ninja.o: ninja.cc ninja.h eval_env.h manifest_parser.h\n", + &err)); + ASSERT_EQ("", err); + EXPECT_EQ("build/ninja.o", parser.out_.AsString()); + EXPECT_EQ(4u, parser.ins_.size()); +} + +TEST(DepfileParser, EarlyNewlineAndWhitespace) { + DepfileParser parser; + string err; + EXPECT_TRUE(parser.Parse( +" \\\n" +" out: in\n", + &err)); + ASSERT_EQ("", err); +} + +TEST(DepfileParser, Continuation) { + DepfileParser parser; + string err; + EXPECT_TRUE(parser.Parse( +"foo.o: \\\n" +" bar.h baz.h\n", + &err)); + ASSERT_EQ("", err); + EXPECT_EQ("foo.o", parser.out_.AsString()); + EXPECT_EQ(2u, parser.ins_.size()); +} diff --git a/src/parsers_test.cc b/src/parsers_test.cc index 0e6d532..71cfed3 100644 --- a/src/parsers_test.cc +++ b/src/parsers_test.cc @@ -16,7 +16,6 @@ #include -#include "depfile_parser.h" #include "graph.h" #include "state.h" @@ -487,36 +486,3 @@ TEST_F(ParserTest, DefaultStatements) { EXPECT_EQ("b", nodes[1]->path()); EXPECT_EQ("c", nodes[2]->path()); } - -TEST(DepfileParser, Basic) { - DepfileParser parser; - string err; - EXPECT_TRUE(parser.Parse( -"build/ninja.o: ninja.cc ninja.h eval_env.h manifest_parser.h\n", - &err)); - ASSERT_EQ("", err); - EXPECT_EQ("build/ninja.o", parser.out_.AsString()); - EXPECT_EQ(4u, parser.ins_.size()); -} - -TEST(DepfileParser, EarlyNewlineAndWhitespace) { - DepfileParser parser; - string err; - EXPECT_TRUE(parser.Parse( -" \\\n" -" out: in\n", - &err)); - ASSERT_EQ("", err); -} - -TEST(DepfileParser, Continuation) { - DepfileParser parser; - string err; - EXPECT_TRUE(parser.Parse( -"foo.o: \\\n" -" bar.h baz.h\n", - &err)); - ASSERT_EQ("", err); - EXPECT_EQ("foo.o", parser.out_.AsString()); - EXPECT_EQ(2u, parser.ins_.size()); -}