mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tests: make the output of coutput_test.v more accurate/easily reproducible in case of failures
This commit is contained in:
parent
5bc8b4dadb
commit
115493781b
@ -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 { '' }
|
const diff_cmd = diff.find_working_diff_command() or { '' }
|
||||||
|
|
||||||
|
fn mm(s string) string {
|
||||||
|
return term.colorize(term.magenta, s)
|
||||||
|
}
|
||||||
|
|
||||||
fn test_out_files() ? {
|
fn test_out_files() ? {
|
||||||
println(term.colorize(term.green, '> testing whether .out files match:'))
|
println(term.colorize(term.green, '> testing whether .out files match:'))
|
||||||
os.chdir(vroot) or {}
|
os.chdir(vroot) or {}
|
||||||
@ -30,8 +34,7 @@ fn test_out_files() ? {
|
|||||||
mut total_errors := 0
|
mut total_errors := 0
|
||||||
for out_path in paths {
|
for out_path in paths {
|
||||||
basename, path, relpath, out_relpath := target2paths(out_path, '.out')
|
basename, path, relpath, out_relpath := target2paths(out_path, '.out')
|
||||||
print(term.colorize(term.magenta, 'v run $relpath') + ' == ' +
|
print(mm('v run $relpath') + ' == ${mm(out_relpath)} ')
|
||||||
term.colorize(term.magenta, out_relpath) + ' ')
|
|
||||||
pexe := os.join_path(output_path, '${basename}.exe')
|
pexe := os.join_path(output_path, '${basename}.exe')
|
||||||
compilation := os.execute('"$vexe" -o "$pexe" "$path"')
|
compilation := os.execute('"$vexe" -o "$pexe" "$path"')
|
||||||
ensure_compilation_succeeded(compilation)
|
ensure_compilation_succeeded(compilation)
|
||||||
@ -98,10 +101,11 @@ fn test_c_must_have_files() ? {
|
|||||||
mut total_errors := 0
|
mut total_errors := 0
|
||||||
for must_have_path in paths {
|
for must_have_path in paths {
|
||||||
basename, path, relpath, must_have_relpath := target2paths(must_have_path, '.c.must_have')
|
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)
|
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)
|
ensure_compilation_succeeded(compilation)
|
||||||
expected_lines := os.read_lines(must_have_path) or { [] }
|
expected_lines := os.read_lines(must_have_path) or { [] }
|
||||||
generated_c_lines := compilation.output.split_into_lines()
|
generated_c_lines := compilation.output.split_into_lines()
|
||||||
|
Loading…
Reference in New Issue
Block a user