Skip to content
Browse files

Tests now build on a native Windows build (tested with VS2010)

All tests except SubProcess pass on a native Windows build
Tests continue not to build on a platform=mingw build
  • Loading branch information...
1 parent 511613c commit 41a4e2604ba4a4add4dc5f2fd6213ef5c2243ca4 @philipcraig philipcraig committed
Showing with 20 additions and 2 deletions.
  1. +1 −1 src/build_log.cc
  2. +11 −0 src/build_log_test.cc
  3. +1 −1 src/ninja_test.cc
  4. +3 −0 src/util.cc
  5. +4 −0 src/util.h
View
2 src/build_log.cc 100644 → 100755
@@ -54,7 +54,7 @@ bool BuildLog::OpenForWrite(const string& path, string* err) {
*err = strerror(errno);
return false;
}
- setvbuf(log_file_, NULL, _IOLBF, 0);
+ setvbuf(log_file_, NULL, _IOLBF, BUFSIZ);
if (ftell(log_file_) == 0) {
if (fwrite(kFileSignature, sizeof(kFileSignature) - 1, 1, log_file_) < 1) {
View
11 src/build_log_test.cc 100644 → 100755
@@ -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));
View
2 src/ninja_test.cc 100644 → 100755
@@ -217,7 +217,7 @@ TEST_F(StatTest, Middle) {
#ifndef _mktemp_s
/// mingw has no mktemp. Implement one with the same type as the one
/// found in the Windows API.
-int _mktemp_s(const char* templ) {
+int _mktemp_s(char* templ) {
char* ofs = strchr(templ, 'X');
sprintf(ofs, "%d", rand() % 1000000);
return 0;
View
3 src/util.cc 100644 → 100755
@@ -25,7 +25,10 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
+
+#ifndef _WIN32
#include <sys/time.h>
+#endif
#include <vector>
View
4 src/util.h 100644 → 100755
@@ -46,4 +46,8 @@ int ReadFile(const string& path, string* contents, string* err);
/// time.
int64_t GetTimeMillis();
+#ifdef _WIN32
+#define snprintf _snprintf
+#endif
+
#endif // NINJA_UTIL_H_

0 comments on commit 41a4e26

Please sign in to comment.
Something went wrong with that request. Please try again.