diff options
author | Fredrik Medley <fredrik.medley@autoliv.com> | 2017-12-19 13:49:07 (GMT) |
---|---|---|
committer | Fredrik Medley <fredrik.medley@autoliv.com> | 2017-12-19 13:55:08 (GMT) |
commit | 6c864097ef11da366fb4070e6ab9f34d6a293766 (patch) | |
tree | 9bff85fbbb84b0d4c79cb67cbbb09a3cebfc4112 /src/disk_interface_test.cc | |
parent | ed11516a03583602fbaae2748f3d428542096136 (diff) | |
download | Ninja-6c864097ef11da366fb4070e6ab9f34d6a293766.zip Ninja-6c864097ef11da366fb4070e6ab9f34d6a293766.tar.gz Ninja-6c864097ef11da366fb4070e6ab9f34d6a293766.tar.bz2 |
Fix stat when subdirectory is a file
Make sure that stat on Windows, both with and without cache, returns
"missing file" when running stat on notadir/foo where notadir is a
file.
Diffstat (limited to 'src/disk_interface_test.cc')
-rw-r--r-- | src/disk_interface_test.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/disk_interface_test.cc b/src/disk_interface_test.cc index 81aa63a..5f7e468 100644 --- a/src/disk_interface_test.cc +++ b/src/disk_interface_test.cc @@ -63,6 +63,27 @@ TEST_F(DiskInterfaceTest, StatMissingFile) { EXPECT_EQ("", err); } +#ifdef _WIN32 +TEST_F(DiskInterfaceTest, StatMissingFileWithCache) { + string err; + disk_.AllowStatCache(true); + + EXPECT_EQ(0, disk_.Stat("nosuchfile", &err)); + EXPECT_EQ("", err); + + // On Windows, the errno for a file in a nonexistent directory + // is different. + EXPECT_EQ(0, disk_.Stat("nosuchdir/nosuchfile", &err)); + EXPECT_EQ("", err); + + // On POSIX systems, the errno is different if a component of the + // path prefix is not a directory. + ASSERT_TRUE(Touch("notadir")); + EXPECT_EQ(0, disk_.Stat("notadir/nosuchfile", &err)); + EXPECT_EQ("", err); +} +#endif + TEST_F(DiskInterfaceTest, StatBadPath) { string err; #ifdef _WIN32 |