| ... | @@ -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" |
| 11 | | 12 | |
| 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 { |
| 31 | static ZigList<TestCase*> test_cases = {0}; | 32 | static ZigList<TestCase*> test_cases = {0}; |
| 32 | static const char *tmp_source_path = ".tmp_source.zig"; | 33 | static const char *tmp_source_path = ".tmp_source.zig"; |
| 33 | static const char *tmp_h_path = ".tmp_header.h"; | 34 | static const char *tmp_h_path = ".tmp_header.h"; |
| | 35 | |
| | 36 | #if defined(_WIN32) |
| | 37 | static const char *tmp_exe_path = "./.tmp_exe.exe"; |
| | 38 | static const char *zig_exe = "./zig.exe"; |
| | 39 | #define NL "\r\n" |
| | 40 | #else |
| 34 | static const char *tmp_exe_path = "./.tmp_exe"; | 41 | static const char *tmp_exe_path = "./.tmp_exe"; |
| 35 | static const char *zig_exe = "./zig"; | 42 | static const char *zig_exe = "./zig"; |
| | 43 | #define NL "\n" |
| | 44 | #endif |
| 36 | | 45 | |
| 37 | static void add_source_file(TestCase *test_case, const char *path, const char *source) { | 46 | static 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); |
| 141 | | 150 | |
| 142 | add_simple_case("function call", R"SOURCE( | 151 | add_simple_case("function call", R"SOURCE( |
| 143 | import "std.zig"; | 152 | import "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 | } |
| 1985 | | 1997 | |
| 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) { |