authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-05 16:53:29-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-05 16:53:29-05:00
log704cd977bdcdfa8cff4e70aaad93857d9b622fc7
tree028ddaa40366b2a3b487751926f8d8d81cde88c4
parent84323504acc2c872a55d0b59ff2c54b60b809405
signaturelock-open Commit is signed but in an unrecognized format.

ability to run tests in evented I/O mode

This adds `--test-evented-io` as a CLI parameter. see #3117

4 files changed, 14 insertions(+), 0 deletions(-)

lib/std/special/test_runner.zig+2
......@@ -2,6 +2,8 @@ const std = @import("std");
22const io = std.io;
33const builtin = @import("builtin");
44
5pub const io_mode = builtin.test_io_mode;
6
57pub fn main() anyerror!void {
68 const test_fn_list = builtin.test_functions;
79 var ok_count: usize = 0;
src/all_types.hpp+1
......@@ -2244,6 +2244,7 @@ struct CodeGen {
22442244 bool enable_dump_analysis;
22452245 bool enable_doc_generation;
22462246 bool disable_bin_generation;
2247 bool test_is_evented;
22472248 CodeModel code_model;
22482249
22492250 Buf *mmacosx_version_min;
src/codegen.cpp+5
......@@ -8602,6 +8602,9 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
86028602 buf_appendf(contents,
86038603 "pub var test_functions: []TestFn = undefined; // overwritten later\n"
86048604 );
8605
8606 buf_appendf(contents, "pub const test_io_mode = %s;\n",
8607 g->test_is_evented ? ".evented" : ".blocking");
86058608 }
86068609
86078610 return contents;
......@@ -8635,6 +8638,7 @@ static Error define_builtin_compile_vars(CodeGen *g) {
86358638 cache_bool(&cache_hash, g->is_dynamic);
86368639 cache_bool(&cache_hash, g->is_test_build);
86378640 cache_bool(&cache_hash, g->is_single_threaded);
8641 cache_bool(&cache_hash, g->test_is_evented);
86388642 cache_int(&cache_hash, g->code_model);
86398643 cache_int(&cache_hash, g->zig_target->is_native);
86408644 cache_int(&cache_hash, g->zig_target->arch);
......@@ -10350,6 +10354,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
1035010354 if (g->is_test_build) {
1035110355 cache_buf_opt(ch, g->test_filter);
1035210356 cache_buf_opt(ch, g->test_name_prefix);
10357 cache_bool(ch, g->test_is_evented);
1035310358 }
1035410359 cache_bool(ch, g->link_eh_frame_hdr);
1035510360 cache_bool(ch, g->is_single_threaded);
src/main.cpp+6
......@@ -135,6 +135,7 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
135135 " --test-name-prefix [text] add prefix to all tests\n"
136136 " --test-cmd [arg] specify test execution command one arg at a time\n"
137137 " --test-cmd-bin appends test binary path to test cmd args\n"
138 " --test-evented-io runs the test in evented I/O mode\n"
138139 , arg0);
139140 return return_code;
140141}
......@@ -428,6 +429,7 @@ int main(int argc, char **argv) {
428429 ZigList<CFile *> c_source_files = {0};
429430 const char *test_filter = nullptr;
430431 const char *test_name_prefix = nullptr;
432 bool test_evented_io = false;
431433 size_t ver_major = 0;
432434 size_t ver_minor = 0;
433435 size_t ver_patch = 0;
......@@ -709,6 +711,8 @@ int main(int argc, char **argv) {
709711 cur_pkg = cur_pkg->parent;
710712 } else if (strcmp(arg, "-ffunction-sections") == 0) {
711713 function_sections = true;
714 } else if (strcmp(arg, "--test-evented-io") == 0) {
715 test_evented_io = true;
712716 } else if (i + 1 >= argc) {
713717 fprintf(stderr, "Expected another argument after %s\n", arg);
714718 return print_error_usage(arg0);
......@@ -1059,6 +1063,7 @@ int main(int argc, char **argv) {
10591063 g->want_stack_check = want_stack_check;
10601064 g->want_sanitize_c = want_sanitize_c;
10611065 g->want_single_threaded = want_single_threaded;
1066 g->test_is_evented = test_evented_io;
10621067 Buf *builtin_source = codegen_generate_builtin_source(g);
10631068 if (fwrite(buf_ptr(builtin_source), 1, buf_len(builtin_source), stdout) != buf_len(builtin_source)) {
10641069 fprintf(stderr, "unable to write to stdout: %s\n", strerror(ferror(stdout)));
......@@ -1232,6 +1237,7 @@ int main(int argc, char **argv) {
12321237 if (test_filter) {
12331238 codegen_set_test_filter(g, buf_create_from_str(test_filter));
12341239 }
1240 g->test_is_evented = test_evented_io;
12351241
12361242 if (test_name_prefix) {
12371243 codegen_set_test_name_prefix(g, buf_create_from_str(test_name_prefix));