From 115493781b240a55f621de556890cf801b0b3aec Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Wed, 6 Oct 2021 10:15:18 +0300 Subject: [PATCH] tests: make the output of coutput_test.v more accurate/easily reproducible in case of failures --- vlib/v/gen/c/coutput_test.v | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/vlib/v/gen/c/coutput_test.v b/vlib/v/gen/c/coutput_test.v index 4b31e24707..a2d558b8ad 100644 --- a/vlib/v/gen/c/coutput_test.v +++ b/vlib/v/gen/c/coutput_test.v @@ -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()