v2 / vlib / v / parser / v_silent_works_test.v
22 lines · 19 sloc · 780 bytes · e2e5cf8db56f3562c7baa735061690be936bdf3e
Raw
1import os
2import term
3
4const vexe = @VEXE
5const vroot = os.dir(vexe)
6
7fn test_check_syntax_in_silent_mode() {
8 check_parsing_files_in_folder('vlib/v/parser/testdata/silent', '-silent -check-syntax')
9}
10
11fn check_parsing_files_in_folder(folder string, options string) {
12 println(term.colorize(term.magenta,
13 '> checking .vv files in folder: `${folder}`, with `${options}` ...'))
14 files := os.walk_ext(os.join_path(vroot, folder), '.vv')
15 for f in files {
16 cmd := '${os.quoted_path(vexe)} ${options} ${os.quoted_path(f)}'
17 eprintln('> cmd: ${cmd}')
18 res := os.execute(cmd)
19 assert res.exit_code == 1, 'Command should fail silently, but did not: `${cmd}`, output:\n${res.output}'
20 assert res.output.trim_space() == '', 'there should be no output printed by comd: `${cmd}`'
21 }
22}
23