From 6f0f357ee43fc02ad2dc1eb44ab127c0d741282c Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 7 May 2016 10:14:16 -0700 Subject: [PATCH] self hosted tests test release mode too closes #69 --- src/codegen.cpp | 2 +- test/run_tests.cpp | 33 +++++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index 6c73eff14..a6c5cc919 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -2609,7 +2609,7 @@ static LLVMValueRef gen_container_init_expr(CodeGen *g, AstNode *node) { } else if (type_entry->id == TypeTableEntryIdUnreachable) { assert(node->data.container_init_expr.entries.length == 0); set_debug_source_node(g, node); - if (want_debug_safety(g, node)) { + if (want_debug_safety(g, node) || g->is_test_build) { gen_debug_safety_crash(g); } else { LLVMBuildUnreachable(g->builder); diff --git a/test/run_tests.cpp b/test/run_tests.cpp index 0fc63ee81..b37147597 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -27,6 +27,7 @@ struct TestCase { ZigList program_args; bool is_parseh; bool is_self_hosted; + bool is_release_mode; bool is_debug_safety; }; @@ -1623,28 +1624,44 @@ struct type { })", R"(pub const @"type" = struct_type;)"); } -static void run_self_hosted_test(void) { +static void run_self_hosted_test(bool is_release_mode) { Buf zig_stderr = BUF_INIT; Buf zig_stdout = BUF_INIT; int return_code; ZigList args = {0}; args.append("test"); args.append("../test/self_hosted.zig"); + if (is_release_mode) { + args.append("--release"); + } os_exec_process(zig_exe, args, &return_code, &zig_stderr, &zig_stdout); if (return_code) { printf("\nSelf-hosted tests failed:\n"); - printf("./zig test ../test/self_hosted.zig\n"); - printf("%s\n", buf_ptr(&zig_stderr)); + printf("./zig"); + for (int i = 0; i < args.length; i += 1) { + printf(" %s", args.at(i)); + } + printf("\n%s\n", buf_ptr(&zig_stderr)); exit(1); } } static void add_self_hosted_tests(void) { - TestCase *test_case = allocate(1); - test_case->case_name = "self hosted tests"; - test_case->is_self_hosted = true; - test_cases.append(test_case); + { + TestCase *test_case = allocate(1); + test_case->case_name = "self hosted tests (debug)"; + test_case->is_self_hosted = true; + test_case->is_release_mode = false; + test_cases.append(test_case); + } + { + TestCase *test_case = allocate(1); + test_case->case_name = "self hosted tests (release)"; + test_case->is_self_hosted = true; + test_case->is_release_mode = true; + test_cases.append(test_case); + } } static void print_compiler_invocation(TestCase *test_case) { @@ -1665,7 +1682,7 @@ static void print_exe_invocation(TestCase *test_case) { static void run_test(TestCase *test_case) { if (test_case->is_self_hosted) { - return run_self_hosted_test(); + return run_self_hosted_test(test_case->is_release_mode); } for (int i = 0; i < test_case->source_files.length; i += 1) {