tests: fix random color mismatches in the CI

pull/8101/head
Delyan Angelov 2021-01-13 21:27:24 +02:00
parent 349eb95a28
commit 0d25091afd
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
7 changed files with 57 additions and 68 deletions

View File

@ -2823,7 +2823,7 @@ fn C.sqlite3_step(&sqlite3_stmt)
fn C.sqlite3_finalize(&sqlite3_stmt)
fn C.sqlite3_exec(db &sqlite3, sql charptr, FnSqlite3Callback voidptr, cb_arg voidptr, emsg &charptr) int
fn C.sqlite3_exec(db &sqlite3, sql charptr, cb FnSqlite3Callback, cb_arg voidptr, emsg &charptr) int
fn C.sqlite3_free(voidptr)

View File

@ -7,12 +7,13 @@ import sync
import runtime
import benchmark
const (
skip_files = [
const skip_files = [
'vlib/v/checker/tests/custom_comptime_define_if_flag.vv',
]
should_autofix = os.getenv('VAUTOFIX') != ''
)
const turn_off_vcolors = os.setenv('VCOLORS', 'never', true)
const should_autofix = os.getenv('VAUTOFIX') != ''
struct TaskDescription {
vexe string
@ -138,7 +139,9 @@ fn (mut tasks []TaskDescription) run() {
bench.stop()
eprintln(term.h_divider('-'))
eprintln(bench.total_message('all tests'))
assert total_errors == 0
if total_errors != 0 {
exit(1)
}
}
// a single worker thread spends its time getting work from the `work` channel,
@ -192,7 +195,7 @@ fn clean_line_endings(s string) string {
fn diff_content(s1 string, s2 string) {
diff_cmd := util.find_working_diff_command() or { return }
println('diff: ')
println(term.bold(term.yellow('diff: ')))
println(util.color_compare_strings(diff_cmd, s1, s2))
println('============\n')
}

View File

@ -3,32 +3,28 @@ import term
import v.util
import v.util.vtest
const turn_off_vcolors = os.setenv('VCOLORS', 'never', true)
fn test_all() {
mut total_errors := 0
vexe := os.getenv('VEXE')
vroot := os.dir(vexe)
os.chdir(vroot)
diff_cmd := util.find_working_diff_command() or {
''
}
diff_cmd := util.find_working_diff_command() or { '' }
dir := 'vlib/v/tests/inout'
files := os.ls(dir) or {
panic(err)
}
files := os.ls(dir) or { panic(err) }
tests := files.filter(it.ends_with('.vv'))
if tests.len == 0 {
println('no compiler tests found')
assert false
}
paths := vtest.filter_vtest_only(tests, {
paths := vtest.filter_vtest_only(tests,
basepath: dir
})
)
for path in paths {
print(path + ' ')
program := path
compilation := os.exec('$vexe -o test -cflags "-w" -cg $program') or {
panic(err)
}
compilation := os.exec('$vexe -o test -cflags "-w" -cg $program') or { panic(err) }
if compilation.exit_code != 0 {
panic('compilation failed: $compilation.output')
}
@ -49,9 +45,7 @@ fn test_all() {
// println(res.output)
// println('============')
mut found := res.output.trim_right('\r\n').replace('\r\n', '\n')
mut expected := os.read_file(program.replace('.vv', '') + '.out') or {
panic(err)
}
mut expected := os.read_file(program.replace('.vv', '') + '.out') or { panic(err) }
expected = expected.trim_right('\r\n').replace('\r\n', '\n')
if expected.contains('================ V panic ================') {
// panic include backtraces and absolute file paths, so can't do char by char comparison

View File

@ -1,11 +1,14 @@
import os
const (
vexe = os.getenv('VEXE')
vroot = os.dir(vexe)
basepath = os.real_path(os.join_path(vroot, 'vlib', 'v', 'tests', 'multiple_paths_in_vmodules'))
mainvv = os.join_path(basepath, 'main.vv')
)
const turn_off_vcolors = os.setenv('VCOLORS', 'never', true)
const vexe = os.getenv('VEXE')
const vroot = os.dir(vexe)
const basepath = os.real_path(os.join_path(vroot, 'vlib', 'v', 'tests', 'multiple_paths_in_vmodules'))
const mainvv = os.join_path(basepath, 'main.vv')
fn test_vexe_is_set() {
assert vexe != ''
@ -15,9 +18,7 @@ fn test_vexe_is_set() {
fn test_compiling_without_vmodules_fails() {
os.chdir(vroot)
os.setenv('VMODULES', '', true)
res := os.exec('"$vexe" run "$mainvv"') or {
panic(err)
}
res := os.exec('"$vexe" run "$mainvv"') or { panic(err) }
assert res.exit_code == 1
assert res.output.trim_space() == 'builder error: cannot import module "yyy" (not found)'
}
@ -26,9 +27,7 @@ fn test_compiling_with_vmodules_works() {
os.chdir(vroot)
vmpaths := ['path1', 'path2', 'path3'].map(os.join_path(basepath, it))
os.setenv('VMODULES', vmpaths.join(os.path_delimiter), true)
res := os.exec('"$vexe" run "$mainvv"') or {
panic(err)
}
res := os.exec('"$vexe" run "$mainvv"') or { panic(err) }
assert res.exit_code == 0
assert res.output.trim_space() == "['x', 'y', 'z']"
}

View File

@ -5,20 +5,18 @@ import v.tests.repl.runner
import benchmark
import sync
const turn_off_vcolors = os.setenv('VCOLORS', 'never', true)
fn test_the_v_compiler_can_be_invoked() {
vexec := runner.full_path_to_v(5)
println('vexecutable: $vexec')
assert vexec != ''
vcmd := '"$vexec" -version'
r := os.exec(vcmd) or {
panic(err)
}
r := os.exec(vcmd) or { panic(err) }
// println('"$vcmd" exit_code: $r.exit_code | output: $r.output')
assert r.exit_code == 0
vcmd_error := '"$vexec" nonexisting.v'
r_error := os.exec(vcmd_error) or {
panic(err)
}
r_error := os.exec(vcmd_error) or { panic(err) }
// println('"$vcmd_error" exit_code: $r_error.exit_code | output: $r_error.output')
assert r_error.exit_code == 1
actual_error := r_error.output.trim_space()
@ -41,9 +39,9 @@ fn test_all_v_repl_files() {
panic(err)
}
session.bmark.set_total_expected_steps(session.options.files.len)
mut pool_repl := sync.new_pool_processor({
mut pool_repl := sync.new_pool_processor(
callback: worker_repl
})
)
pool_repl.set_shared_context(session)
$if windows {
// See: https://docs.microsoft.com/en-us/cpp/build/reference/fs-force-synchronous-pdb-writes?view=vs-2019
@ -68,9 +66,7 @@ fn worker_repl(mut p sync.PoolProcessor, idx int, thread_id int) voidptr {
if os.is_dir(tfolder) {
os.rmdir_all(tfolder)
}
os.mkdir(tfolder) or {
panic(err)
}
os.mkdir(tfolder) or { panic(err) }
file := p.get_string_item(idx)
session.bmark.step()
tls_bench.step()

View File

@ -1,8 +1,8 @@
import os
const (
vexe = os.getenv('VEXE')
)
const vexe = os.getenv('VEXE')
const turn_off_vcolors = os.setenv('VCOLORS', 'never', true)
fn test_vexe_is_set() {
assert vexe != ''
@ -24,7 +24,5 @@ fn pipe_to_v_run() ? {
}
fn test_pipe_to_v_run() {
pipe_to_v_run() or {
panic(err)
}
pipe_to_v_run() or { panic(err) }
}

View File

@ -4,6 +4,8 @@ import benchmark
import v.util
import v.util.vtest
const turn_off_vcolors = os.setenv('VCOLORS', 'never', true)
//
// NB: skip_compile_files can be used for totally skipping .v files temporarily.
// .v files in skip_valgrind_files will be compiled, but will not be run under
@ -14,17 +16,16 @@ import v.util.vtest
// Use: `./v -d noskip vlib/v/tests/valgrind/valgrind_test.v` to ignore skip_valgrind_files
// Use: `./v -d noskipcompile -d noskip vlib/v/tests/valgrind/valgrind_test.v` to ignore both
//
const (
skip_compile_files = [
const skip_compile_files = [
'vlib/v/tests/valgrind/option_reassigned.v',
]
skip_valgrind_files = [
const skip_valgrind_files = [
'vlib/v/tests/valgrind/struct_field.v',
'vlib/v/tests/valgrind/fn_returning_string_param.v',
'vlib/v/tests/valgrind/fn_with_return_should_free_local_vars.v',
'vlib/v/tests/valgrind/option_simple.v',
]
)
fn vprintln(s string) {
$if verbose ? {
@ -49,18 +50,16 @@ fn test_all() {
vroot := os.dir(vexe)
valgrind_test_path := 'vlib/v/tests/valgrind'
dir := os.join_path(vroot, valgrind_test_path)
files := os.ls(dir) or {
panic(err)
}
files := os.ls(dir) or { panic(err) }
//
wrkdir := os.join_path(os.temp_dir(), 'vtests', 'valgrind')
os.mkdir_all(wrkdir)
os.chdir(wrkdir)
//
tests := vtest.filter_vtest_only(files.filter(it.ends_with('.v') && !it.ends_with('_test.v')),
{
basepath: valgrind_test_path
})
)
bench.set_total_expected_steps(tests.len)
for test in tests {
bench.step()