authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-02-17 20:23:56-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-02-17 20:44:07-07:00
log04cc59be65d525dc2f3cb4585e1ec2d47473b461
treefe94368b9d070c840dca762fcdb4363f4d24dc6a
parenta7b6fa5bee58f40aafa64665b73ff3efc68f7930

update run_tests to work on windows


2 files changed, 15 insertions(+), 2 deletions(-)

CMakeLists.txt+1
......@@ -57,6 +57,7 @@ set(TEST_SOURCES
5757 "${CMAKE_SOURCE_DIR}/src/buffer.cpp"
5858 "${CMAKE_SOURCE_DIR}/src/util.cpp"
5959 "${CMAKE_SOURCE_DIR}/src/os.cpp"
60 "${CMAKE_SOURCE_DIR}/src/error.cpp"
6061 "${CMAKE_SOURCE_DIR}/test/run_tests.cpp"
6162)
6263
test/run_tests.cpp+14-2
......@@ -8,6 +8,7 @@
88#include "list.hpp"
99#include "buffer.hpp"
1010#include "os.hpp"
11#include "error.hpp"
1112
1213#include <stdio.h>
1314#include <stdarg.h>
......@@ -31,8 +32,16 @@ struct TestCase {
3132static ZigList<TestCase*> test_cases = {0};
3233static const char *tmp_source_path = ".tmp_source.zig";
3334static const char *tmp_h_path = ".tmp_header.h";
35
36#if defined(_WIN32)
37static const char *tmp_exe_path = "./.tmp_exe.exe";
38static const char *zig_exe = "./zig.exe";
39#define NL "\r\n"
40#else
3441static const char *tmp_exe_path = "./.tmp_exe";
3542static const char *zig_exe = "./zig";
43#define NL "\n"
44#endif
3645
3746static void add_source_file(TestCase *test_case, const char *path, const char *source) {
3847 test_case->source_files.add_one();
......@@ -137,7 +146,7 @@ export fn main(argc: c_int, argv: &&u8) -> c_int {
137146 puts(c"Hello, world!");
138147 return 0;
139148}
140 )SOURCE", "Hello, world!\n");
149 )SOURCE", "Hello, world!" NL);
141150
142151 add_simple_case("function call", R"SOURCE(
143152import "std.zig";
......@@ -1981,7 +1990,10 @@ static void run_test(TestCase *test_case) {
19811990 Buf zig_stderr = BUF_INIT;
19821991 Buf zig_stdout = BUF_INIT;
19831992 int return_code;
1984 os_exec_process(zig_exe, test_case->compiler_args, &return_code, &zig_stderr, &zig_stdout);
1993 int err;
1994 if ((err = os_exec_process(zig_exe, test_case->compiler_args, &return_code, &zig_stderr, &zig_stdout))) {
1995 fprintf(stderr, "Unable to exec %s: %s\n", zig_exe, err_str(err));
1996 }
19851997
19861998 if (!test_case->is_parseh && test_case->compile_errors.length) {
19871999 if (return_code) {