TEST_F(BuildTest, MakeDirs) {
string err;
- ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
-"build subdir/dir2/file: cat in1\n"));
+#ifdef WIN32
+ ASSERT_NO_FATAL_FAILURE(AssertParse(&state_, "build subdir\\dir2\\file: cat in1\n"));
+ EXPECT_TRUE(builder_.AddTarget("subdir\\dir2\\file", &err));
+#else
+ ASSERT_NO_FATAL_FAILURE(AssertParse(&state_, "build subdir/dir2/file: cat in1\n"));
EXPECT_TRUE(builder_.AddTarget("subdir/dir2/file", &err));
+#endif
+
EXPECT_EQ("", err);
now_ = 0; // Make all stat()s return file not found.
EXPECT_TRUE(builder_.Build(&err));
ASSERT_EQ("", err);
ASSERT_EQ(2u, fs_.directories_made_.size());
EXPECT_EQ("subdir", fs_.directories_made_[0]);
+#ifdef WIN32
+ EXPECT_EQ("subdir\\dir2", fs_.directories_made_[1]);
+#else
EXPECT_EQ("subdir/dir2", fs_.directories_made_[1]);
+#endif
}
TEST_F(BuildTest, DepFileMissing) {
}
string DirName(const string& path) {
- string::size_type slash_pos = path.rfind('/');
+
+#ifdef WIN32
+ const char kPathSeparator = '\\';
+#else
+ const char kPathSeparator = '/';
+#endif
+
+ string::size_type slash_pos = path.rfind(kPathSeparator);
if (slash_pos == string::npos)
return ""; // Nothing to do.
- while (slash_pos > 0 && path[slash_pos - 1] == '/')
+ while (slash_pos > 0 && path[slash_pos - 1] == kPathSeparator)
--slash_pos;
return path.substr(0, slash_pos);
}