Skip to content

Commit 91a3844

Browse files
committed
tools: add support for // vtest vflags: -w in _test.v files, to allow v -W test . later, for files, that have known warnings
1 parent e6a1983 commit 91a3844

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

cmd/tools/modules/testing/common.v

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,11 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
450450
} else {
451451
fname_without_extension
452452
}
453+
mut details := get_test_details(file)
454+
if details.vflags != '' && !is_fmt {
455+
cmd_options << details.vflags
456+
}
457+
453458
reproduce_options := cmd_options.clone()
454459
generated_binary_fpath := os.join_path_single(test_folder_path, generated_binary_fname)
455460
if produces_file_output {
@@ -475,7 +480,6 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
475480
} else {
476481
os.quoted_path(generated_binary_fpath)
477482
}
478-
mut details := get_test_details(file)
479483
mut should_be_built := true
480484
if details.vbuild != '' {
481485
should_be_built = ts.build_environment.eval(details.vbuild) or {
@@ -817,6 +821,7 @@ pub mut:
817821
hide_retries bool // when true, all retry tries are silent; used by `vlib/v/tests/retry_test.v`
818822
vbuild string // could be `!(windows && tinyc)`
819823
vbuild_line int // for more precise error reporting, if the `vbuild` expression is incorrect
824+
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)
820825
}
821826

822827
pub fn get_test_details(file string) TestDetails {
@@ -836,6 +841,9 @@ pub fn get_test_details(file string) TestDetails {
836841
res.vbuild = line.all_after(':').trim_space()
837842
res.vbuild_line = idx + 1
838843
}
844+
if line.starts_with('// vtest vflags:') {
845+
res.vflags = line.all_after(':').trim_space()
846+
}
839847
if line.starts_with('// vtest hide_retries') {
840848
res.hide_retries = true
841849
}

vlib/json/tests/json_encode_default_option_none_test.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// vtest vflags: -w
12
module main
23

34
import json

vlib/v/pref/pref.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,12 +797,14 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
797797
}
798798
'-w' {
799799
res.skip_warnings = true
800+
res.warns_are_errors = false
800801
}
801802
'-N' {
802803
res.notes_are_errors = true
803804
}
804805
'-n' {
805806
res.skip_notes = true
807+
res.notes_are_errors = false
806808
}
807809
'-no-rsp' {
808810
res.no_rsp = true

0 commit comments

Comments
 (0)