tests: fix random color mismatches in the CI
parent
349eb95a28
commit
0d25091afd
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -21,12 +22,12 @@ struct TaskDescription {
|
|||
result_extension string
|
||||
path string
|
||||
mut:
|
||||
is_error bool
|
||||
is_skipped bool
|
||||
is_module bool
|
||||
expected string
|
||||
found___ string
|
||||
took time.Duration
|
||||
is_error bool
|
||||
is_skipped bool
|
||||
is_module bool
|
||||
expected string
|
||||
found___ string
|
||||
took time.Duration
|
||||
}
|
||||
|
||||
fn test_all() {
|
||||
|
@ -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')
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,20 +18,16 @@ 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)'
|
||||
}
|
||||
|
||||
fn test_compiling_with_vmodules_works() {
|
||||
os.chdir(vroot)
|
||||
vmpaths := ['path1', 'path2', 'path3'].map(os.join_path(basepath, it))
|
||||
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']"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -64,13 +62,11 @@ fn worker_repl(mut p sync.PoolProcessor, idx int, thread_id int) voidptr {
|
|||
p.set_thread_context(idx, tls_bench)
|
||||
}
|
||||
tls_bench.cstep = idx
|
||||
tfolder := os.join_path(cdir,'vrepl_tests_$idx')
|
||||
tfolder := os.join_path(cdir, 'vrepl_tests_$idx')
|
||||
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()
|
||||
|
|
|
@ -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) }
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue