From bbf49835248340057d899037a178cb487ea14654 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 14 Sep 2020 12:50:11 +0300 Subject: [PATCH] autofree: add option_reassigned.v and option_simple.v tests. --- vlib/v/tests/valgrind/option_reassigned.v | 9 +++++++ vlib/v/tests/valgrind/option_simple.v | 8 ++++++ vlib/v/tests/valgrind/valgrind_test.v | 31 +++++++++++++++++------ 3 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 vlib/v/tests/valgrind/option_reassigned.v create mode 100644 vlib/v/tests/valgrind/option_simple.v diff --git a/vlib/v/tests/valgrind/option_reassigned.v b/vlib/v/tests/valgrind/option_reassigned.v new file mode 100644 index 0000000000..26ce1c1c32 --- /dev/null +++ b/vlib/v/tests/valgrind/option_reassigned.v @@ -0,0 +1,9 @@ +import os + +fn main() { + mut a := 'abc' + a = os.find_abs_path_of_executable('ls') or { + '' + } + eprintln(a) +} diff --git a/vlib/v/tests/valgrind/option_simple.v b/vlib/v/tests/valgrind/option_simple.v new file mode 100644 index 0000000000..bdd8691a15 --- /dev/null +++ b/vlib/v/tests/valgrind/option_simple.v @@ -0,0 +1,8 @@ +import os + +fn main() { + a := os.find_abs_path_of_executable('ls') or { + '' + } + eprintln(a) +} diff --git a/vlib/v/tests/valgrind/valgrind_test.v b/vlib/v/tests/valgrind/valgrind_test.v index 289798892c..71e3d8fa5d 100644 --- a/vlib/v/tests/valgrind/valgrind_test.v +++ b/vlib/v/tests/valgrind/valgrind_test.v @@ -4,11 +4,25 @@ import benchmark import v.util import v.util.vtest +// +// NB: skip_compile_files can be used for totally skipping .v files temporarily. +// .v files in skip_valgrind_files will be compiled, but will not be run under +// valgrind. This ensures that at least the generated code does not have C syntax +// errors. +// Use: `./v -d noskipcompile vlib/v/tests/valgrind/valgrind_test.v` to ignore the +// skip_compile_files list. +// Use: `./v -d noskip vlib/v/tests/valgrind/valgrind_test.v` to ignore skip_valgrind_files +// Use: `./v -d noskipcompile -d noskip vlib/v/tests/valgrind/valgrind_test.v` to ignore both +// const ( + skip_compile_files = [ + 'vlib/v/tests/valgrind/option_reassigned.v', + ] skip_valgrind_files = [ 'vlib/v/tests/valgrind/struct_field.v', 'vlib/v/tests/valgrind/fn_returning_string_param.v', 'vlib/v/tests/valgrind/fn_with_return_should_free_local_vars.v', + 'vlib/v/tests/valgrind/option_simple.v', ] ) @@ -50,14 +64,8 @@ fn test_all() { bench.set_total_expected_steps(tests.len) for test in tests { bench.step() - if !test.contains('1.') { - bench.skip() - eprintln(bench.step_message_skip(test)) - continue - } - // - if test in skip_valgrind_files { - $if !noskip ? { + if test in skip_compile_files { + $if !noskipcompile ? { bench.skip() eprintln(bench.step_message_skip(test)) continue @@ -79,6 +87,13 @@ fn test_all() { eprintln(res.output) continue } + if test in skip_valgrind_files { + $if !noskip ? { + bench.skip() + eprintln(bench.step_message_skip(test)) + continue + } + } valgrind_cmd := 'valgrind --error-exitcode=1 --leak-check=full $exe_filename' vprintln('valgrind cmd: ${util.bold(valgrind_cmd)}') valgrind_res := os.exec(valgrind_cmd) or {