| ... | @@ -211,6 +211,28 @@ static TestCase *add_parseh_case(const char *case_name, AllowWarnings allow_warn | ... | @@ -211,6 +211,28 @@ static TestCase *add_parseh_case(const char *case_name, AllowWarnings allow_warn |
| 211 | return test_case; | 211 | return test_case; |
| 212 | } | 212 | } |
| 213 | | 213 | |
| | 214 | static TestCase *add_example_compile_extra(const char *root_source_file, bool libc) { |
| | 215 | TestCase *test_case = allocate<TestCase>(1); |
| | 216 | test_case->case_name = buf_ptr(buf_sprintf("build example %s", root_source_file)); |
| | 217 | test_case->output = nullptr; |
| | 218 | test_case->special = TestSpecialNone; |
| | 219 | |
| | 220 | test_case->compiler_args.append("build_exe"); |
| | 221 | test_case->compiler_args.append(buf_ptr(buf_sprintf("../%s", root_source_file))); |
| | 222 | |
| | 223 | test_cases.append(test_case); |
| | 224 | |
| | 225 | return test_case; |
| | 226 | } |
| | 227 | |
| | 228 | static TestCase *add_example_compile(const char *root_source_file) { |
| | 229 | return add_example_compile_extra(root_source_file, false); |
| | 230 | } |
| | 231 | |
| | 232 | static TestCase *add_example_compile_libc(const char *root_source_file) { |
| | 233 | return add_example_compile_extra(root_source_file, true); |
| | 234 | } |
| | 235 | |
| 214 | static void add_compiling_test_cases(void) { | 236 | static void add_compiling_test_cases(void) { |
| 215 | add_simple_case_libc("hello world with libc", R"SOURCE( | 237 | add_simple_case_libc("hello world with libc", R"SOURCE( |
| 216 | const c = @cImport(@cInclude("stdio.h")); | 238 | const c = @cImport(@cInclude("stdio.h")); |
| ... | @@ -617,6 +639,15 @@ pub fn main() -> %void { | ... | @@ -617,6 +639,15 @@ pub fn main() -> %void { |
| 617 | } | 639 | } |
| 618 | } | 640 | } |
| 619 | | 641 | |
| | 642 | //////////////////////////////////////////////////////////////////////////////////// |
| | 643 | |
| | 644 | static void add_build_examples(void) { |
| | 645 | add_example_compile("example/hello_world/hello.zig"); |
| | 646 | add_example_compile_libc("example/hello_world/hello_libc.zig"); |
| | 647 | add_example_compile("example/cat/main.zig"); |
| | 648 | add_example_compile("example/guess_number/main.zig"); |
| | 649 | } |
| | 650 | |
| 620 | | 651 | |
| 621 | //////////////////////////////////////////////////////////////////////////////////// | 652 | //////////////////////////////////////////////////////////////////////////////////// |
| 622 | | 653 | |
| ... | @@ -2825,7 +2856,7 @@ static void run_test(TestCase *test_case) { | ... | @@ -2825,7 +2856,7 @@ static void run_test(TestCase *test_case) { |
| 2825 | exit(1); | 2856 | exit(1); |
| 2826 | } | 2857 | } |
| 2827 | | 2858 | |
| 2828 | if (!buf_eql_str(&program_stdout, test_case->output)) { | 2859 | if (test_case->output != nullptr && !buf_eql_str(&program_stdout, test_case->output)) { |
| 2829 | printf("\n"); | 2860 | printf("\n"); |
| 2830 | print_compiler_invocation(test_case); | 2861 | print_compiler_invocation(test_case); |
| 2831 | print_exe_invocation(test_case); | 2862 | print_exe_invocation(test_case); |
| ... | @@ -2887,6 +2918,7 @@ int main(int argc, char **argv) { | ... | @@ -2887,6 +2918,7 @@ int main(int argc, char **argv) { |
| 2887 | } | 2918 | } |
| 2888 | } | 2919 | } |
| 2889 | add_compiling_test_cases(); | 2920 | add_compiling_test_cases(); |
| | 2921 | add_build_examples(); |
| 2890 | add_debug_safety_test_cases(); | 2922 | add_debug_safety_test_cases(); |
| 2891 | add_compile_failure_test_cases(); | 2923 | add_compile_failure_test_cases(); |
| 2892 | add_parse_error_tests(); | 2924 | add_parse_error_tests(); |