summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2014-06-27 23:32:31 (GMT)
committerNico Weber <nicolasweber@gmx.de>2014-06-27 23:32:31 (GMT)
commit47e40867aed4980cf484f8394c379326dd88dbf9 (patch)
treeb083f3c7cccd7ee3529704faee769e816ec2bcf3
parent916ba1ae261761f288ebfd8218dc7ad80545148a (diff)
parent72e1ea3b2353b059ea094114203813e6c7d00f16 (diff)
downloadNinja-47e40867aed4980cf484f8394c379326dd88dbf9.zip
Ninja-47e40867aed4980cf484f8394c379326dd88dbf9.tar.gz
Ninja-47e40867aed4980cf484f8394c379326dd88dbf9.tar.bz2
Merge pull request #792 from nico/statdir
try to fix stat()ing directories on windows in statcache code
-rw-r--r--src/disk_interface.cc2
-rw-r--r--src/disk_interface_test.cc21
2 files changed, 21 insertions, 2 deletions
diff --git a/src/disk_interface.cc b/src/disk_interface.cc
index ae2146e..b170f63 100644
--- a/src/disk_interface.cc
+++ b/src/disk_interface.cc
@@ -117,8 +117,6 @@ bool StatAllFilesInDir(const string& dir, map<string, TimeStamp>* stamps,
return false;
}
do {
- if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- continue;
string lowername = ffd.cFileName;
transform(lowername.begin(), lowername.end(), lowername.begin(), ::tolower);
stamps->insert(make_pair(lowername,
diff --git a/src/disk_interface_test.cc b/src/disk_interface_test.cc
index f4e0bb0..b2e8cb5 100644
--- a/src/disk_interface_test.cc
+++ b/src/disk_interface_test.cc
@@ -76,6 +76,18 @@ TEST_F(DiskInterfaceTest, StatExistingFile) {
EXPECT_GT(disk_.Stat("file"), 1);
}
+TEST_F(DiskInterfaceTest, StatExistingDir) {
+ ASSERT_TRUE(disk_.MakeDir("subdir"));
+ ASSERT_TRUE(disk_.MakeDir("subdir/subsubdir"));
+ EXPECT_GT(disk_.Stat("."), 1);
+ EXPECT_GT(disk_.Stat("subdir"), 1);
+ EXPECT_GT(disk_.Stat("subdir/subsubdir"), 1);
+
+ EXPECT_EQ(disk_.Stat("subdir"), disk_.Stat("subdir/."));
+ EXPECT_EQ(disk_.Stat("subdir"), disk_.Stat("subdir/subsubdir/.."));
+ EXPECT_EQ(disk_.Stat("subdir/subsubdir"), disk_.Stat("subdir/subsubdir/."));
+}
+
#ifdef _WIN32
TEST_F(DiskInterfaceTest, StatCache) {
disk_.AllowStatCache(true);
@@ -83,6 +95,7 @@ TEST_F(DiskInterfaceTest, StatCache) {
ASSERT_TRUE(Touch("file1"));
ASSERT_TRUE(Touch("fiLE2"));
ASSERT_TRUE(disk_.MakeDir("subdir"));
+ ASSERT_TRUE(disk_.MakeDir("subdir/subsubdir"));
ASSERT_TRUE(Touch("subdir\\subfile1"));
ASSERT_TRUE(Touch("subdir\\SUBFILE2"));
ASSERT_TRUE(Touch("subdir\\SUBFILE3"));
@@ -93,6 +106,14 @@ TEST_F(DiskInterfaceTest, StatCache) {
EXPECT_GT(disk_.Stat("subdir/subfile2"), 1);
EXPECT_GT(disk_.Stat("sUbdir\\suBFile1"), 1);
+ EXPECT_GT(disk_.Stat("."), 1);
+ EXPECT_GT(disk_.Stat("subdir"), 1);
+ EXPECT_GT(disk_.Stat("subdir/subsubdir"), 1);
+
+ EXPECT_EQ(disk_.Stat("subdir"), disk_.Stat("subdir/."));
+ EXPECT_EQ(disk_.Stat("subdir"), disk_.Stat("subdir/subsubdir/.."));
+ EXPECT_EQ(disk_.Stat("subdir/subsubdir"), disk_.Stat("subdir/subsubdir/."));
+
// Test error cases.
disk_.quiet_ = true;
string bad_path("cc:\\foo");