tests: automatically add an .out file if not found, with VAUTOFIX=1 (#8250)

pull/8255/head
Daniel Däschle 2021-01-21 14:48:57 +01:00 committed by GitHub
parent ee663364de
commit 6c24e9ba84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -175,6 +175,9 @@ fn (mut task TaskDescription) execute() {
cli_cmd := '$task.vexe $task.voptions $program' cli_cmd := '$task.vexe $task.voptions $program'
res := os.exec(cli_cmd) or { panic(err) } res := os.exec(cli_cmd) or { panic(err) }
expected_out_path := program.replace('.vv', '') + task.result_extension expected_out_path := program.replace('.vv', '') + task.result_extension
if should_autofix && !os.exists(expected_out_path) {
os.write_file(expected_out_path, '')
}
mut expected := os.read_file(expected_out_path) or { panic(err) } mut expected := os.read_file(expected_out_path) or { panic(err) }
task.expected = clean_line_endings(expected) task.expected = clean_line_endings(expected)
task.found___ = clean_line_endings(res.output) task.found___ = clean_line_endings(res.output)