summaryrefslogtreecommitdiffstats
path: root/src/build_log_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/build_log_test.cc')
-rwxr-xr-x[-rw-r--r--]src/build_log_test.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/build_log_test.cc b/src/build_log_test.cc
index 8bb2bfa..1df28db 100644..100755
--- a/src/build_log_test.cc
+++ b/src/build_log_test.cc
@@ -16,6 +16,10 @@
#include "test.h"
+#ifdef WIN32
+#include <fcntl.h>
+#endif
+
static const char kTestFilename[] = "BuildLogTest-tempfile";
struct BuildLogTest : public StateTestWithBuiltinRules {
@@ -90,7 +94,14 @@ TEST_F(BuildLogTest, Truncate) {
// For all possible truncations of the input file, assert that we don't
// crash or report an error when parsing.
for (off_t size = statbuf.st_size; size > 0; --size) {
+#ifndef WIN32
ASSERT_EQ(0, truncate(kTestFilename, size));
+#else
+ int fh;
+ ASSERT_EQ(0, _sopen_s(&fh, kTestFilename, _O_RDWR | _O_CREAT, _SH_DENYNO, _S_IREAD | _S_IWRITE));
+ ASSERT_EQ(0, _chsize(fh, size));
+ _close(fh);
+#endif
BuildLog log2;
EXPECT_TRUE(log2.Load(kTestFilename, &err));