tests: make the output of coutput_test.v more accurate/easily reproducible in case of failures

pull/12080/head
Delyan Angelov 2021-10-06 10:15:18 +03:00
parent 5bc8b4dadb
commit 115493781b
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 9 additions and 5 deletions

View File

@ -12,6 +12,10 @@ const testdata_folder = os.join_path(vroot, 'vlib', 'v', 'gen', 'c', 'testdata')
const diff_cmd = diff.find_working_diff_command() or { '' }
fn mm(s string) string {
return term.colorize(term.magenta, s)
}
fn test_out_files() ? {
println(term.colorize(term.green, '> testing whether .out files match:'))
os.chdir(vroot) or {}
@ -30,8 +34,7 @@ fn test_out_files() ? {
mut total_errors := 0
for out_path in paths {
basename, path, relpath, out_relpath := target2paths(out_path, '.out')
print(term.colorize(term.magenta, 'v run $relpath') + ' == ' +
term.colorize(term.magenta, out_relpath) + ' ')
print(mm('v run $relpath') + ' == ${mm(out_relpath)} ')
pexe := os.join_path(output_path, '${basename}.exe')
compilation := os.execute('"$vexe" -o "$pexe" "$path"')
ensure_compilation_succeeded(compilation)
@ -98,10 +101,11 @@ fn test_c_must_have_files() ? {
mut total_errors := 0
for must_have_path in paths {
basename, path, relpath, must_have_relpath := target2paths(must_have_path, '.c.must_have')
print(term.colorize(term.magenta, 'v -o - $relpath') + ' matches all line patterns in ' +
term.colorize(term.magenta, must_have_relpath) + ' ')
file_options := get_file_options(path)
compilation := os.execute('$vexe -o - $file_options.vflags $path')
alloptions := '-o - $file_options.vflags'
print(mm('v $alloptions $relpath') +
' matches all line patterns in ${mm(must_have_relpath)} ')
compilation := os.execute('$vexe $alloptions $path')
ensure_compilation_succeeded(compilation)
expected_lines := os.read_lines(must_have_path) or { [] }
generated_c_lines := compilation.output.split_into_lines()