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...@@ -57,6 +57,7 @@ set(TEST_SOURCES
57 "${CMAKE_SOURCE_DIR}/src/buffer.cpp"57 "${CMAKE_SOURCE_DIR}/src/buffer.cpp"
58 "${CMAKE_SOURCE_DIR}/src/util.cpp"58 "${CMAKE_SOURCE_DIR}/src/util.cpp"
59 "${CMAKE_SOURCE_DIR}/src/os.cpp"59 "${CMAKE_SOURCE_DIR}/src/os.cpp"
60 "${CMAKE_SOURCE_DIR}/src/error.cpp"
60 "${CMAKE_SOURCE_DIR}/test/run_tests.cpp"61 "${CMAKE_SOURCE_DIR}/test/run_tests.cpp"
61)62)
6263
test/run_tests.cpp+14-2
...@@ -8,6 +8,7 @@...@@ -8,6 +8,7 @@
8#include "list.hpp"8#include "list.hpp"
9#include "buffer.hpp"9#include "buffer.hpp"
10#include "os.hpp"10#include "os.hpp"
11#include "error.hpp"
1112
12#include <stdio.h>13#include <stdio.h>
13#include <stdarg.h>14#include <stdarg.h>
...@@ -31,8 +32,16 @@ struct TestCase {...@@ -31,8 +32,16 @@ struct TestCase {
31static ZigList<TestCase*> test_cases = {0};32static ZigList<TestCase*> test_cases = {0};
32static const char *tmp_source_path = ".tmp_source.zig";33static const char *tmp_source_path = ".tmp_source.zig";
33static const char *tmp_h_path = ".tmp_header.h";34static 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
34static const char *tmp_exe_path = "./.tmp_exe";41static const char *tmp_exe_path = "./.tmp_exe";
35static const char *zig_exe = "./zig";42static const char *zig_exe = "./zig";
43#define NL "\n"
44#endif
3645
37static void add_source_file(TestCase *test_case, const char *path, const char *source) {46static void add_source_file(TestCase *test_case, const char *path, const char *source) {
38 test_case->source_files.add_one();47 test_case->source_files.add_one();
...@@ -137,7 +146,7 @@ export fn main(argc: c_int, argv: &&u8) -> c_int {...@@ -137,7 +146,7 @@ export fn main(argc: c_int, argv: &&u8) -> c_int {
137 puts(c"Hello, world!");146 puts(c"Hello, world!");
138 return 0;147 return 0;
139}148}
140 )SOURCE", "Hello, world!\n");149 )SOURCE", "Hello, world!" NL);
141150
142 add_simple_case("function call", R"SOURCE(151 add_simple_case("function call", R"SOURCE(
143import "std.zig";152import "std.zig";
...@@ -1981,7 +1990,10 @@ static void run_test(TestCase *test_case) {...@@ -1981,7 +1990,10 @@ static void run_test(TestCase *test_case) {
1981 Buf zig_stderr = BUF_INIT;1990 Buf zig_stderr = BUF_INIT;
1982 Buf zig_stdout = BUF_INIT;1991 Buf zig_stdout = BUF_INIT;
1983 int return_code;1992 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
1986 if (!test_case->is_parseh && test_case->compile_errors.length) {1998 if (!test_case->is_parseh && test_case->compile_errors.length) {
1987 if (return_code) {1999 if (return_code) {