17 #include <gtest/gtest.h>
22 TEST(CLParserTest, ShowIncludes) {
26 ASSERT_EQ(
"c:\\Some Files\\foobar.h",
28 "c:\\Some Files\\foobar.h"));
29 ASSERT_EQ(
"c:\\initspaces.h",
34 TEST(CLParserTest, FilterInputFilename) {
41 "src\\cl_helper.cc(166) : fatal error C1075: end "
42 "of file found ..."));
45 TEST(CLParserTest, ParseSimple) {
47 string output = parser.
Parse(
49 "Note: including file: foo.h\r\n"
52 ASSERT_EQ(
"foo\nbar\n", output);
54 ASSERT_EQ(
"foo.h", *parser.
includes_.begin());
57 TEST(CLParserTest, ParseFilenameFilter) {
59 string output = parser.
Parse(
62 ASSERT_EQ(
"cl: warning\n", output);
65 TEST(CLParserTest, ParseSystemInclude) {
67 string output = parser.
Parse(
68 "Note: including file: c:\\Program Files\\foo.h\r\n"
69 "Note: including file: d:\\Microsoft Visual Studio\\bar.h\r\n"
70 "Note: including file: path.h\r\n");
73 ASSERT_EQ(
"", output);
75 ASSERT_EQ(
"path.h", *parser.
includes_.begin());
78 TEST(CLParserTest, DuplicatedHeader) {
80 string output = parser.
Parse(
81 "Note: including file: foo.h\r\n"
82 "Note: including file: bar.h\r\n"
83 "Note: including file: foo.h\r\n");
85 ASSERT_EQ(
"", output);
89 TEST(CLParserTest, DuplicatedHeaderPathConverted) {
91 string output = parser.
Parse(
92 "Note: including file: sub/foo.h\r\n"
93 "Note: including file: bar.h\r\n"
94 "Note: including file: sub\\foo.h\r\n");
96 ASSERT_EQ(
"", output);
100 TEST(CLParserTest, SpacesInFilename) {
101 ASSERT_EQ(
"sub\\some\\ sdk\\foo.h",
105 TEST(MSVCHelperTest, EnvBlock) {
106 char env_block[] =
"foo=bar\0";
110 cl.
Run(
"cmd /c \"echo foo is %foo%", &output);
111 ASSERT_EQ(
"foo is bar\r\n", output);
static string FilterShowIncludes(const string &line)
Parse a line of cl.exe output and extract /showIncludes info.
static bool FilterInputFilename(string line)
Parse a line of cl.exe output and return true if it looks like it's printing an input filename...
string Parse(const string &output)
Parse the full output of cl, returning the output (if any) that should printed.
int Run(const string &command, string *output)
Start a process and gather its raw output.
TEST(CLParserTest, ShowIncludes)
Visual Studio's cl.exe requires some massaging to work with Ninja; for example, it emits include info...
Wraps a synchronous execution of a CL subprocess.
string EscapeForDepfile(const string &path)
void SetEnvBlock(void *env_block)
Set the environment block (as suitable for CreateProcess) to be used by Run().