| 1 | import os |
| 2 | |
| 3 | const vroot = os.dir(@VEXE) |
| 4 | const test_vexe = os.quoted_path(@VEXE) |
| 5 | const testdata_file = os.join_path(vroot, |
| 6 | 'vlib/v/gen/c/testdata/autofree_labeled_continue_boehm_leak.vv') |
| 7 | |
| 8 | fn missing_boehm_leak_lib(output string) bool { |
| 9 | return output.contains('ld: cannot find -lgc') || output.contains('library not found for -lgc') |
| 10 | || output.contains('gc/gc.h') || output.contains('bdw-gc') |
| 11 | } |
| 12 | |
| 13 | fn test_autofree_labeled_continue_boehm_leak_cleanup() { |
| 14 | mut exe_path := os.join_path(os.vtmp_dir(), 'autofree_labeled_continue_boehm_leak') |
| 15 | $if windows { |
| 16 | exe_path += '.exe' |
| 17 | } |
| 18 | cmd := '${test_vexe} -autofree -gc boehm_leak -o ${os.quoted_path(exe_path)} ${os.quoted_path(testdata_file)}' |
| 19 | res := os.execute(cmd) |
| 20 | if res.exit_code != 0 && missing_boehm_leak_lib(res.output) { |
| 21 | eprintln('skipping boehm_leak labeled continue cleanup test: missing libgc') |
| 22 | return |
| 23 | } |
| 24 | assert res.exit_code == 0, '${cmd}\n${res.output}' |
| 25 | run_res := os.execute(os.quoted_path(exe_path)) |
| 26 | assert run_res.exit_code == 0, run_res.output |
| 27 | os.rm(exe_path) or {} |
| 28 | } |
| 29 | |