authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-17 06:58:36-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-17 06:58:36-04:00
log401eed8153d909eda4146b5a1815dee7130cf1c3
tree88aa4d79c7e4a56b9d66834f776dc70ace32d6ce
parent05b3082121e225ec2dfc9a062c765b4b60befaef

build examples in ./run_tests

closes #325

1 files changed, 33 insertions(+), 1 deletions(-)

test/run_tests.cpp+33-1
......@@ -211,6 +211,28 @@ static TestCase *add_parseh_case(const char *case_name, AllowWarnings allow_warn
211211 return test_case;
212212}
213213
214static 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
228static TestCase *add_example_compile(const char *root_source_file) {
229 return add_example_compile_extra(root_source_file, false);
230}
231
232static TestCase *add_example_compile_libc(const char *root_source_file) {
233 return add_example_compile_extra(root_source_file, true);
234}
235
214236static void add_compiling_test_cases(void) {
215237 add_simple_case_libc("hello world with libc", R"SOURCE(
216238const c = @cImport(@cInclude("stdio.h"));
......@@ -617,6 +639,15 @@ pub fn main() -> %void {
617639 }
618640}
619641
642////////////////////////////////////////////////////////////////////////////////////
643
644static 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
620651
621652////////////////////////////////////////////////////////////////////////////////////
622653
......@@ -2825,7 +2856,7 @@ static void run_test(TestCase *test_case) {
28252856 exit(1);
28262857 }
28272858
2828 if (!buf_eql_str(&program_stdout, test_case->output)) {
2859 if (test_case->output != nullptr && !buf_eql_str(&program_stdout, test_case->output)) {
28292860 printf("\n");
28302861 print_compiler_invocation(test_case);
28312862 print_exe_invocation(test_case);
......@@ -2887,6 +2918,7 @@ int main(int argc, char **argv) {
28872918 }
28882919 }
28892920 add_compiling_test_cases();
2921 add_build_examples();
28902922 add_debug_safety_test_cases();
28912923 add_compile_failure_test_cases();
28922924 add_parse_error_tests();