22 TEST(CLParserTest, ShowIncludes) {
26 ASSERT_EQ(
"c:\\Some Files\\foobar.h",
28 "c:\\Some Files\\foobar.h",
""));
29 ASSERT_EQ(
"c:\\initspaces.h",
31 "c:\\initspaces.h",
""));
32 ASSERT_EQ(
"c:\\initspaces.h",
35 "Non-default prefix: inc file:"));
38 TEST(CLParserTest, FilterInputFilename) {
45 "src\\cl_helper.cc(166) : fatal error C1075: end "
46 "of file found ..."));
49 TEST(CLParserTest, ParseSimple) {
52 ASSERT_TRUE(parser.
Parse(
54 "Note: inc file prefix: foo.h\r\n"
56 "Note: inc file prefix:", &output, &err));
58 ASSERT_EQ(
"foo\nbar\n", output);
60 ASSERT_EQ(
"foo.h", *parser.
includes_.begin());
63 TEST(CLParserTest, ParseFilenameFilter) {
66 ASSERT_TRUE(parser.
Parse(
70 ASSERT_EQ(
"cl: warning\n", output);
73 TEST(CLParserTest, NoFilenameFilterAfterShowIncludes) {
76 ASSERT_TRUE(parser.
Parse(
78 "Note: including file: foo.h\r\n"
79 "something something foo.cc\r\n",
81 ASSERT_EQ(
"something something foo.cc\n", output);
84 TEST(CLParserTest, ParseSystemInclude) {
87 ASSERT_TRUE(parser.
Parse(
88 "Note: including file: c:\\Program Files\\foo.h\r\n"
89 "Note: including file: d:\\Microsoft Visual Studio\\bar.h\r\n"
90 "Note: including file: path.h\r\n",
94 ASSERT_EQ(
"", output);
96 ASSERT_EQ(
"path.h", *parser.
includes_.begin());
99 TEST(CLParserTest, DuplicatedHeader) {
102 ASSERT_TRUE(parser.
Parse(
103 "Note: including file: foo.h\r\n"
104 "Note: including file: bar.h\r\n"
105 "Note: including file: foo.h\r\n",
108 ASSERT_EQ(
"", output);
112 TEST(CLParserTest, DuplicatedHeaderPathConverted) {
118 const char kInput[] =
119 "Note: including file: sub/./foo.h\r\n"
120 "Note: including file: bar.h\r\n"
122 "Note: including file: sub\\foo.h\r\n";
124 "Note: including file: sub/foo.h\r\n";
126 ASSERT_TRUE(parser.
Parse(kInput,
"", &output, &err));
128 ASSERT_EQ(
"", output);
TEST(CLParserTest, ShowIncludes)
Visual Studio's cl.exe requires some massaging to work with Ninja; for example, it emits include info...
static bool FilterInputFilename(std::string line)
Parse a line of cl.exe output and return true if it looks like it's printing an input filename.
static std::string FilterShowIncludes(const std::string &line, const std::string &deps_prefix)
Parse a line of cl.exe output and extract /showIncludes info.
std::set< std::string > includes_
bool Parse(const std::string &output, const std::string &deps_prefix, std::string *filtered_output, std::string *err)
Parse the full output of cl, filling filtered_output with the text that should be printed (if any).