| author | |
| committer | |
| log | 704cd977bdcdfa8cff4e70aaad93857d9b622fc7 |
| tree | 028ddaa40366b2a3b487751926f8d8d81cde88c4 |
| parent | 84323504acc2c872a55d0b59ff2c54b60b809405 |
| signature |
This adds `--test-evented-io` as a CLI parameter.
see #31174 files changed, 14 insertions(+), 0 deletions(-)
lib/std/special/test_runner.zig+2| ... | ... | @@ -2,6 +2,8 @@ const std = @import("std"); |
| 2 | 2 | const io = std.io; |
| 3 | 3 | const builtin = @import("builtin"); |
| 4 | 4 | |
| 5 | pub const io_mode = builtin.test_io_mode; | |
| 6 | ||
| 5 | 7 | pub fn main() anyerror!void { |
| 6 | 8 | const test_fn_list = builtin.test_functions; |
| 7 | 9 | var ok_count: usize = 0; |
src/all_types.hpp+1| ... | ... | @@ -2244,6 +2244,7 @@ struct CodeGen { |
| 2244 | 2244 | bool enable_dump_analysis; |
| 2245 | 2245 | bool enable_doc_generation; |
| 2246 | 2246 | bool disable_bin_generation; |
| 2247 | bool test_is_evented; | |
| 2247 | 2248 | CodeModel code_model; |
| 2248 | 2249 | |
| 2249 | 2250 | Buf *mmacosx_version_min; |
src/codegen.cpp+5| ... | ... | @@ -8602,6 +8602,9 @@ Buf *codegen_generate_builtin_source(CodeGen *g) { |
| 8602 | 8602 | buf_appendf(contents, |
| 8603 | 8603 | "pub var test_functions: []TestFn = undefined; // overwritten later\n" |
| 8604 | 8604 | ); |
| 8605 | ||
| 8606 | buf_appendf(contents, "pub const test_io_mode = %s;\n", | |
| 8607 | g->test_is_evented ? ".evented" : ".blocking"); | |
| 8605 | 8608 | } |
| 8606 | 8609 | |
| 8607 | 8610 | return contents; |
| ... | ... | @@ -8635,6 +8638,7 @@ static Error define_builtin_compile_vars(CodeGen *g) { |
| 8635 | 8638 | cache_bool(&cache_hash, g->is_dynamic); |
| 8636 | 8639 | cache_bool(&cache_hash, g->is_test_build); |
| 8637 | 8640 | cache_bool(&cache_hash, g->is_single_threaded); |
| 8641 | cache_bool(&cache_hash, g->test_is_evented); | |
| 8638 | 8642 | cache_int(&cache_hash, g->code_model); |
| 8639 | 8643 | cache_int(&cache_hash, g->zig_target->is_native); |
| 8640 | 8644 | cache_int(&cache_hash, g->zig_target->arch); |
| ... | ... | @@ -10350,6 +10354,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { |
| 10350 | 10354 | if (g->is_test_build) { |
| 10351 | 10355 | cache_buf_opt(ch, g->test_filter); |
| 10352 | 10356 | cache_buf_opt(ch, g->test_name_prefix); |
| 10357 | cache_bool(ch, g->test_is_evented); | |
| 10353 | 10358 | } |
| 10354 | 10359 | cache_bool(ch, g->link_eh_frame_hdr); |
| 10355 | 10360 | 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) { |
| 135 | 135 | " --test-name-prefix [text] add prefix to all tests\n" |
| 136 | 136 | " --test-cmd [arg] specify test execution command one arg at a time\n" |
| 137 | 137 | " --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" | |
| 138 | 139 | , arg0); |
| 139 | 140 | return return_code; |
| 140 | 141 | } |
| ... | ... | @@ -428,6 +429,7 @@ int main(int argc, char **argv) { |
| 428 | 429 | ZigList<CFile *> c_source_files = {0}; |
| 429 | 430 | const char *test_filter = nullptr; |
| 430 | 431 | const char *test_name_prefix = nullptr; |
| 432 | bool test_evented_io = false; | |
| 431 | 433 | size_t ver_major = 0; |
| 432 | 434 | size_t ver_minor = 0; |
| 433 | 435 | size_t ver_patch = 0; |
| ... | ... | @@ -709,6 +711,8 @@ int main(int argc, char **argv) { |
| 709 | 711 | cur_pkg = cur_pkg->parent; |
| 710 | 712 | } else if (strcmp(arg, "-ffunction-sections") == 0) { |
| 711 | 713 | function_sections = true; |
| 714 | } else if (strcmp(arg, "--test-evented-io") == 0) { | |
| 715 | test_evented_io = true; | |
| 712 | 716 | } else if (i + 1 >= argc) { |
| 713 | 717 | fprintf(stderr, "Expected another argument after %s\n", arg); |
| 714 | 718 | return print_error_usage(arg0); |
| ... | ... | @@ -1059,6 +1063,7 @@ int main(int argc, char **argv) { |
| 1059 | 1063 | g->want_stack_check = want_stack_check; |
| 1060 | 1064 | g->want_sanitize_c = want_sanitize_c; |
| 1061 | 1065 | g->want_single_threaded = want_single_threaded; |
| 1066 | g->test_is_evented = test_evented_io; | |
| 1062 | 1067 | Buf *builtin_source = codegen_generate_builtin_source(g); |
| 1063 | 1068 | if (fwrite(buf_ptr(builtin_source), 1, buf_len(builtin_source), stdout) != buf_len(builtin_source)) { |
| 1064 | 1069 | fprintf(stderr, "unable to write to stdout: %s\n", strerror(ferror(stdout))); |
| ... | ... | @@ -1232,6 +1237,7 @@ int main(int argc, char **argv) { |
| 1232 | 1237 | if (test_filter) { |
| 1233 | 1238 | codegen_set_test_filter(g, buf_create_from_str(test_filter)); |
| 1234 | 1239 | } |
| 1240 | g->test_is_evented = test_evented_io; | |
| 1235 | 1241 | |
| 1236 | 1242 | if (test_name_prefix) { |
| 1237 | 1243 | codegen_set_test_name_prefix(g, buf_create_from_str(test_name_prefix)); |