authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-05-07 10:14:16-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-05-07 10:14:16-07:00
log6f0f357ee43fc02ad2dc1eb44ab127c0d741282c
tree09ea3e8200ab19cd5441648372580b2b7501796f
parent8c79438f6b76f1ad4b4941cdb46ae1e7aa12ce14

self hosted tests test release mode too

closes #69

2 files changed, 26 insertions(+), 9 deletions(-)

src/codegen.cpp+1-1
...@@ -2609,7 +2609,7 @@ static LLVMValueRef gen_container_init_expr(CodeGen *g, AstNode *node) {...@@ -2609,7 +2609,7 @@ static LLVMValueRef gen_container_init_expr(CodeGen *g, AstNode *node) {
2609 } else if (type_entry->id == TypeTableEntryIdUnreachable) {2609 } else if (type_entry->id == TypeTableEntryIdUnreachable) {
2610 assert(node->data.container_init_expr.entries.length == 0);2610 assert(node->data.container_init_expr.entries.length == 0);
2611 set_debug_source_node(g, node);2611 set_debug_source_node(g, node);
2612 if (want_debug_safety(g, node)) {2612 if (want_debug_safety(g, node) || g->is_test_build) {
2613 gen_debug_safety_crash(g);2613 gen_debug_safety_crash(g);
2614 } else {2614 } else {
2615 LLVMBuildUnreachable(g->builder);2615 LLVMBuildUnreachable(g->builder);
test/run_tests.cpp+25-8
...@@ -27,6 +27,7 @@ struct TestCase {...@@ -27,6 +27,7 @@ struct TestCase {
27 ZigList<const char *> program_args;27 ZigList<const char *> program_args;
28 bool is_parseh;28 bool is_parseh;
29 bool is_self_hosted;29 bool is_self_hosted;
30 bool is_release_mode;
30 bool is_debug_safety;31 bool is_debug_safety;
31};32};
3233
...@@ -1623,28 +1624,44 @@ struct type {...@@ -1623,28 +1624,44 @@ struct type {
1623})", R"(pub const @"type" = struct_type;)");1624})", R"(pub const @"type" = struct_type;)");
1624}1625}
16251626
1626static void run_self_hosted_test(void) {1627static void run_self_hosted_test(bool is_release_mode) {
1627 Buf zig_stderr = BUF_INIT;1628 Buf zig_stderr = BUF_INIT;
1628 Buf zig_stdout = BUF_INIT;1629 Buf zig_stdout = BUF_INIT;
1629 int return_code;1630 int return_code;
1630 ZigList<const char *> args = {0};1631 ZigList<const char *> args = {0};
1631 args.append("test");1632 args.append("test");
1632 args.append("../test/self_hosted.zig");1633 args.append("../test/self_hosted.zig");
1634 if (is_release_mode) {
1635 args.append("--release");
1636 }
1633 os_exec_process(zig_exe, args, &return_code, &zig_stderr, &zig_stdout);1637 os_exec_process(zig_exe, args, &return_code, &zig_stderr, &zig_stdout);
16341638
1635 if (return_code) {1639 if (return_code) {
1636 printf("\nSelf-hosted tests failed:\n");1640 printf("\nSelf-hosted tests failed:\n");
1637 printf("./zig test ../test/self_hosted.zig\n");1641 printf("./zig");
1638 printf("%s\n", buf_ptr(&zig_stderr));1642 for (int i = 0; i < args.length; i += 1) {
1643 printf(" %s", args.at(i));
1644 }
1645 printf("\n%s\n", buf_ptr(&zig_stderr));
1639 exit(1);1646 exit(1);
1640 }1647 }
1641}1648}
16421649
1643static void add_self_hosted_tests(void) {1650static void add_self_hosted_tests(void) {
1644 TestCase *test_case = allocate<TestCase>(1);1651 {
1645 test_case->case_name = "self hosted tests";1652 TestCase *test_case = allocate<TestCase>(1);
1646 test_case->is_self_hosted = true;1653 test_case->case_name = "self hosted tests (debug)";
1647 test_cases.append(test_case);1654 test_case->is_self_hosted = true;
1655 test_case->is_release_mode = false;
1656 test_cases.append(test_case);
1657 }
1658 {
1659 TestCase *test_case = allocate<TestCase>(1);
1660 test_case->case_name = "self hosted tests (release)";
1661 test_case->is_self_hosted = true;
1662 test_case->is_release_mode = true;
1663 test_cases.append(test_case);
1664 }
1648}1665}
16491666
1650static void print_compiler_invocation(TestCase *test_case) {1667static void print_compiler_invocation(TestCase *test_case) {
...@@ -1665,7 +1682,7 @@ static void print_exe_invocation(TestCase *test_case) {...@@ -1665,7 +1682,7 @@ static void print_exe_invocation(TestCase *test_case) {
16651682
1666static void run_test(TestCase *test_case) {1683static void run_test(TestCase *test_case) {
1667 if (test_case->is_self_hosted) {1684 if (test_case->is_self_hosted) {
1668 return run_self_hosted_test();1685 return run_self_hosted_test(test_case->is_release_mode);
1669 }1686 }
16701687
1671 for (int i = 0; i < test_case->source_files.length; i += 1) {1688 for (int i = 0; i < test_case->source_files.length; i += 1) {