diff --git a/cmd/tools/modules/testing/common.v b/cmd/tools/modules/testing/common.v index 901201ff5e..b751941403 100644 --- a/cmd/tools/modules/testing/common.v +++ b/cmd/tools/modules/testing/common.v @@ -450,6 +450,11 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr { } else { fname_without_extension } + mut details := get_test_details(file) + if details.vflags != '' && !is_fmt { + cmd_options << details.vflags + } + reproduce_options := cmd_options.clone() generated_binary_fpath := os.join_path_single(test_folder_path, generated_binary_fname) if produces_file_output { @@ -475,7 +480,6 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr { } else { os.quoted_path(generated_binary_fpath) } - mut details := get_test_details(file) mut should_be_built := true if details.vbuild != '' { should_be_built = ts.build_environment.eval(details.vbuild) or { @@ -817,6 +821,7 @@ pub mut: hide_retries bool // when true, all retry tries are silent; used by `vlib/v/tests/retry_test.v` vbuild string // could be `!(windows && tinyc)` vbuild_line int // for more precise error reporting, if the `vbuild` expression is incorrect + vflags string // custom compilation flags for the test (enables for example: `// vtest vflags: -w`, for tests that have known warnings, but should still pass with -W) } pub fn get_test_details(file string) TestDetails { @@ -836,6 +841,9 @@ pub fn get_test_details(file string) TestDetails { res.vbuild = line.all_after(':').trim_space() res.vbuild_line = idx + 1 } + if line.starts_with('// vtest vflags:') { + res.vflags = line.all_after(':').trim_space() + } if line.starts_with('// vtest hide_retries') { res.hide_retries = true } diff --git a/vlib/json/tests/json_encode_default_option_none_test.v b/vlib/json/tests/json_encode_default_option_none_test.v index 3add0e3425..cbfdd6e240 100644 --- a/vlib/json/tests/json_encode_default_option_none_test.v +++ b/vlib/json/tests/json_encode_default_option_none_test.v @@ -1,3 +1,4 @@ +// vtest vflags: -w module main import json diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index 35214e5b2d..3df32ed565 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -797,12 +797,14 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin } '-w' { res.skip_warnings = true + res.warns_are_errors = false } '-N' { res.notes_are_errors = true } '-n' { res.skip_notes = true + res.notes_are_errors = false } '-no-rsp' { res.no_rsp = true