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_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)
|
fn C.sqlite3_free(voidptr)
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,13 @@ import sync
|
||||||
import runtime
|
import runtime
|
||||||
import benchmark
|
import benchmark
|
||||||
|
|
||||||
const (
|
const skip_files = [
|
||||||
skip_files = [
|
|
||||||
'vlib/v/checker/tests/custom_comptime_define_if_flag.vv',
|
'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 {
|
struct TaskDescription {
|
||||||
vexe string
|
vexe string
|
||||||
|
@ -138,7 +139,9 @@ fn (mut tasks []TaskDescription) run() {
|
||||||
bench.stop()
|
bench.stop()
|
||||||
eprintln(term.h_divider('-'))
|
eprintln(term.h_divider('-'))
|
||||||
eprintln(bench.total_message('all tests'))
|
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,
|
// 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) {
|
fn diff_content(s1 string, s2 string) {
|
||||||
diff_cmd := util.find_working_diff_command() or { return }
|
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(util.color_compare_strings(diff_cmd, s1, s2))
|
||||||
println('============\n')
|
println('============\n')
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,32 +3,28 @@ import term
|
||||||
import v.util
|
import v.util
|
||||||
import v.util.vtest
|
import v.util.vtest
|
||||||
|
|
||||||
|
const turn_off_vcolors = os.setenv('VCOLORS', 'never', true)
|
||||||
|
|
||||||
fn test_all() {
|
fn test_all() {
|
||||||
mut total_errors := 0
|
mut total_errors := 0
|
||||||
vexe := os.getenv('VEXE')
|
vexe := os.getenv('VEXE')
|
||||||
vroot := os.dir(vexe)
|
vroot := os.dir(vexe)
|
||||||
os.chdir(vroot)
|
os.chdir(vroot)
|
||||||
diff_cmd := util.find_working_diff_command() or {
|
diff_cmd := util.find_working_diff_command() or { '' }
|
||||||
''
|
|
||||||
}
|
|
||||||
dir := 'vlib/v/tests/inout'
|
dir := 'vlib/v/tests/inout'
|
||||||
files := os.ls(dir) or {
|
files := os.ls(dir) or { panic(err) }
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
tests := files.filter(it.ends_with('.vv'))
|
tests := files.filter(it.ends_with('.vv'))
|
||||||
if tests.len == 0 {
|
if tests.len == 0 {
|
||||||
println('no compiler tests found')
|
println('no compiler tests found')
|
||||||
assert false
|
assert false
|
||||||
}
|
}
|
||||||
paths := vtest.filter_vtest_only(tests, {
|
paths := vtest.filter_vtest_only(tests,
|
||||||
basepath: dir
|
basepath: dir
|
||||||
})
|
)
|
||||||
for path in paths {
|
for path in paths {
|
||||||
print(path + ' ')
|
print(path + ' ')
|
||||||
program := path
|
program := path
|
||||||
compilation := os.exec('$vexe -o test -cflags "-w" -cg $program') or {
|
compilation := os.exec('$vexe -o test -cflags "-w" -cg $program') or { panic(err) }
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
if compilation.exit_code != 0 {
|
if compilation.exit_code != 0 {
|
||||||
panic('compilation failed: $compilation.output')
|
panic('compilation failed: $compilation.output')
|
||||||
}
|
}
|
||||||
|
@ -49,9 +45,7 @@ fn test_all() {
|
||||||
// println(res.output)
|
// println(res.output)
|
||||||
// println('============')
|
// println('============')
|
||||||
mut found := res.output.trim_right('\r\n').replace('\r\n', '\n')
|
mut found := res.output.trim_right('\r\n').replace('\r\n', '\n')
|
||||||
mut expected := os.read_file(program.replace('.vv', '') + '.out') or {
|
mut expected := os.read_file(program.replace('.vv', '') + '.out') or { panic(err) }
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
expected = expected.trim_right('\r\n').replace('\r\n', '\n')
|
expected = expected.trim_right('\r\n').replace('\r\n', '\n')
|
||||||
if expected.contains('================ V panic ================') {
|
if expected.contains('================ V panic ================') {
|
||||||
// panic include backtraces and absolute file paths, so can't do char by char comparison
|
// panic include backtraces and absolute file paths, so can't do char by char comparison
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
const (
|
const turn_off_vcolors = os.setenv('VCOLORS', 'never', true)
|
||||||
vexe = os.getenv('VEXE')
|
|
||||||
vroot = os.dir(vexe)
|
const vexe = os.getenv('VEXE')
|
||||||
basepath = os.real_path(os.join_path(vroot, 'vlib', 'v', 'tests', 'multiple_paths_in_vmodules'))
|
|
||||||
mainvv = os.join_path(basepath, 'main.vv')
|
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() {
|
fn test_vexe_is_set() {
|
||||||
assert vexe != ''
|
assert vexe != ''
|
||||||
|
@ -15,9 +18,7 @@ fn test_vexe_is_set() {
|
||||||
fn test_compiling_without_vmodules_fails() {
|
fn test_compiling_without_vmodules_fails() {
|
||||||
os.chdir(vroot)
|
os.chdir(vroot)
|
||||||
os.setenv('VMODULES', '', true)
|
os.setenv('VMODULES', '', true)
|
||||||
res := os.exec('"$vexe" run "$mainvv"') or {
|
res := os.exec('"$vexe" run "$mainvv"') or { panic(err) }
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
assert res.exit_code == 1
|
assert res.exit_code == 1
|
||||||
assert res.output.trim_space() == 'builder error: cannot import module "yyy" (not found)'
|
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)
|
os.chdir(vroot)
|
||||||
vmpaths := ['path1', 'path2', 'path3'].map(os.join_path(basepath, it))
|
vmpaths := ['path1', 'path2', 'path3'].map(os.join_path(basepath, it))
|
||||||
os.setenv('VMODULES', vmpaths.join(os.path_delimiter), true)
|
os.setenv('VMODULES', vmpaths.join(os.path_delimiter), true)
|
||||||
res := os.exec('"$vexe" run "$mainvv"') or {
|
res := os.exec('"$vexe" run "$mainvv"') or { panic(err) }
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
assert res.exit_code == 0
|
assert res.exit_code == 0
|
||||||
assert res.output.trim_space() == "['x', 'y', 'z']"
|
assert res.output.trim_space() == "['x', 'y', 'z']"
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,20 +5,18 @@ import v.tests.repl.runner
|
||||||
import benchmark
|
import benchmark
|
||||||
import sync
|
import sync
|
||||||
|
|
||||||
|
const turn_off_vcolors = os.setenv('VCOLORS', 'never', true)
|
||||||
|
|
||||||
fn test_the_v_compiler_can_be_invoked() {
|
fn test_the_v_compiler_can_be_invoked() {
|
||||||
vexec := runner.full_path_to_v(5)
|
vexec := runner.full_path_to_v(5)
|
||||||
println('vexecutable: $vexec')
|
println('vexecutable: $vexec')
|
||||||
assert vexec != ''
|
assert vexec != ''
|
||||||
vcmd := '"$vexec" -version'
|
vcmd := '"$vexec" -version'
|
||||||
r := os.exec(vcmd) or {
|
r := os.exec(vcmd) or { panic(err) }
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
// println('"$vcmd" exit_code: $r.exit_code | output: $r.output')
|
// println('"$vcmd" exit_code: $r.exit_code | output: $r.output')
|
||||||
assert r.exit_code == 0
|
assert r.exit_code == 0
|
||||||
vcmd_error := '"$vexec" nonexisting.v'
|
vcmd_error := '"$vexec" nonexisting.v'
|
||||||
r_error := os.exec(vcmd_error) or {
|
r_error := os.exec(vcmd_error) or { panic(err) }
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
// println('"$vcmd_error" exit_code: $r_error.exit_code | output: $r_error.output')
|
// println('"$vcmd_error" exit_code: $r_error.exit_code | output: $r_error.output')
|
||||||
assert r_error.exit_code == 1
|
assert r_error.exit_code == 1
|
||||||
actual_error := r_error.output.trim_space()
|
actual_error := r_error.output.trim_space()
|
||||||
|
@ -41,9 +39,9 @@ fn test_all_v_repl_files() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
session.bmark.set_total_expected_steps(session.options.files.len)
|
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
|
callback: worker_repl
|
||||||
})
|
)
|
||||||
pool_repl.set_shared_context(session)
|
pool_repl.set_shared_context(session)
|
||||||
$if windows {
|
$if windows {
|
||||||
// See: https://docs.microsoft.com/en-us/cpp/build/reference/fs-force-synchronous-pdb-writes?view=vs-2019
|
// 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) {
|
if os.is_dir(tfolder) {
|
||||||
os.rmdir_all(tfolder)
|
os.rmdir_all(tfolder)
|
||||||
}
|
}
|
||||||
os.mkdir(tfolder) or {
|
os.mkdir(tfolder) or { panic(err) }
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
file := p.get_string_item(idx)
|
file := p.get_string_item(idx)
|
||||||
session.bmark.step()
|
session.bmark.step()
|
||||||
tls_bench.step()
|
tls_bench.step()
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
const (
|
const vexe = os.getenv('VEXE')
|
||||||
vexe = os.getenv('VEXE')
|
|
||||||
)
|
const turn_off_vcolors = os.setenv('VCOLORS', 'never', true)
|
||||||
|
|
||||||
fn test_vexe_is_set() {
|
fn test_vexe_is_set() {
|
||||||
assert vexe != ''
|
assert vexe != ''
|
||||||
|
@ -24,7 +24,5 @@ fn pipe_to_v_run() ? {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_pipe_to_v_run() {
|
fn test_pipe_to_v_run() {
|
||||||
pipe_to_v_run() or {
|
pipe_to_v_run() or { panic(err) }
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import benchmark
|
||||||
import v.util
|
import v.util
|
||||||
import v.util.vtest
|
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.
|
// 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
|
// .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 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
|
// Use: `./v -d noskipcompile -d noskip vlib/v/tests/valgrind/valgrind_test.v` to ignore both
|
||||||
//
|
//
|
||||||
const (
|
const skip_compile_files = [
|
||||||
skip_compile_files = [
|
|
||||||
'vlib/v/tests/valgrind/option_reassigned.v',
|
'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/struct_field.v',
|
||||||
'vlib/v/tests/valgrind/fn_returning_string_param.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/fn_with_return_should_free_local_vars.v',
|
||||||
'vlib/v/tests/valgrind/option_simple.v',
|
'vlib/v/tests/valgrind/option_simple.v',
|
||||||
]
|
]
|
||||||
)
|
|
||||||
|
|
||||||
fn vprintln(s string) {
|
fn vprintln(s string) {
|
||||||
$if verbose ? {
|
$if verbose ? {
|
||||||
|
@ -49,18 +50,16 @@ fn test_all() {
|
||||||
vroot := os.dir(vexe)
|
vroot := os.dir(vexe)
|
||||||
valgrind_test_path := 'vlib/v/tests/valgrind'
|
valgrind_test_path := 'vlib/v/tests/valgrind'
|
||||||
dir := os.join_path(vroot, valgrind_test_path)
|
dir := os.join_path(vroot, valgrind_test_path)
|
||||||
files := os.ls(dir) or {
|
files := os.ls(dir) or { panic(err) }
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
wrkdir := os.join_path(os.temp_dir(), 'vtests', 'valgrind')
|
wrkdir := os.join_path(os.temp_dir(), 'vtests', 'valgrind')
|
||||||
os.mkdir_all(wrkdir)
|
os.mkdir_all(wrkdir)
|
||||||
os.chdir(wrkdir)
|
os.chdir(wrkdir)
|
||||||
//
|
//
|
||||||
tests := vtest.filter_vtest_only(files.filter(it.ends_with('.v') && !it.ends_with('_test.v')),
|
tests := vtest.filter_vtest_only(files.filter(it.ends_with('.v') && !it.ends_with('_test.v')),
|
||||||
{
|
|
||||||
basepath: valgrind_test_path
|
basepath: valgrind_test_path
|
||||||
})
|
)
|
||||||
bench.set_total_expected_steps(tests.len)
|
bench.set_total_expected_steps(tests.len)
|
||||||
for test in tests {
|
for test in tests {
|
||||||
bench.step()
|
bench.step()
|
||||||
|
|
Loading…
Reference in New Issue