| ... | ... | @@ -27,6 +27,7 @@ struct TestCase { |
| 27 | 27 | ZigList<const char *> program_args; |
| 28 | 28 | bool is_parseh; |
| 29 | 29 | bool is_self_hosted; |
| 30 | bool is_release_mode; |
| 30 | 31 | bool is_debug_safety; |
| 31 | 32 | }; |
| 32 | 33 | |
| ... | ... | @@ -1623,28 +1624,44 @@ struct type { |
| 1623 | 1624 | })", R"(pub const @"type" = struct_type;)"); |
| 1624 | 1625 | } |
| 1625 | 1626 | |
| 1626 | | static void run_self_hosted_test(void) { |
| 1627 | static void run_self_hosted_test(bool is_release_mode) { |
| 1627 | 1628 | Buf zig_stderr = BUF_INIT; |
| 1628 | 1629 | Buf zig_stdout = BUF_INIT; |
| 1629 | 1630 | int return_code; |
| 1630 | 1631 | ZigList<const char *> args = {0}; |
| 1631 | 1632 | args.append("test"); |
| 1632 | 1633 | args.append("../test/self_hosted.zig"); |
| 1634 | if (is_release_mode) { |
| 1635 | args.append("--release"); |
| 1636 | } |
| 1633 | 1637 | os_exec_process(zig_exe, args, &return_code, &zig_stderr, &zig_stdout); |
| 1634 | 1638 | |
| 1635 | 1639 | if (return_code) { |
| 1636 | 1640 | printf("\nSelf-hosted tests failed:\n"); |
| 1637 | | printf("./zig test ../test/self_hosted.zig\n"); |
| 1638 | | printf("%s\n", buf_ptr(&zig_stderr)); |
| 1641 | printf("./zig"); |
| 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 | 1646 | exit(1); |
| 1640 | 1647 | } |
| 1641 | 1648 | } |
| 1642 | 1649 | |
| 1643 | 1650 | static void add_self_hosted_tests(void) { |
| 1644 | | TestCase *test_case = allocate<TestCase>(1); |
| 1645 | | test_case->case_name = "self hosted tests"; |
| 1646 | | test_case->is_self_hosted = true; |
| 1647 | | test_cases.append(test_case); |
| 1651 | { |
| 1652 | TestCase *test_case = allocate<TestCase>(1); |
| 1653 | test_case->case_name = "self hosted tests (debug)"; |
| 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 | } |
| 1649 | 1666 | |
| 1650 | 1667 | static void print_compiler_invocation(TestCase *test_case) { |
| ... | ... | @@ -1665,7 +1682,7 @@ static void print_exe_invocation(TestCase *test_case) { |
| 1665 | 1682 | |
| 1666 | 1683 | static void run_test(TestCase *test_case) { |
| 1667 | 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 | } |
| 1670 | 1687 | |
| 1671 | 1688 | for (int i = 0; i < test_case->source_files.length; i += 1) { |