tools: support `VJOBS=1 VTEST_FAIL_FAST=1 ./v test .`
parent
5e75c89b71
commit
7b723262e4
|
@ -9,13 +9,15 @@ import v.pref
|
||||||
import v.util.vtest
|
import v.util.vtest
|
||||||
import runtime
|
import runtime
|
||||||
|
|
||||||
const github_job = os.getenv('GITHUB_JOB')
|
pub const github_job = os.getenv('GITHUB_JOB')
|
||||||
|
|
||||||
const show_start = os.getenv('VTEST_SHOW_START') == '1'
|
pub const show_start = os.getenv('VTEST_SHOW_START') == '1'
|
||||||
|
|
||||||
const hide_skips = os.getenv('VTEST_HIDE_SKIP') == '1'
|
pub const hide_skips = os.getenv('VTEST_HIDE_SKIP') == '1'
|
||||||
|
|
||||||
const hide_oks = os.getenv('VTEST_HIDE_OK') == '1'
|
pub const hide_oks = os.getenv('VTEST_HIDE_OK') == '1'
|
||||||
|
|
||||||
|
pub const fail_fast = os.getenv('VTEST_FAIL_FAST') == '1'
|
||||||
|
|
||||||
pub struct TestSession {
|
pub struct TestSession {
|
||||||
pub mut:
|
pub mut:
|
||||||
|
@ -26,6 +28,7 @@ pub mut:
|
||||||
vtmp_dir string
|
vtmp_dir string
|
||||||
vargs string
|
vargs string
|
||||||
failed bool
|
failed bool
|
||||||
|
fail_fast bool
|
||||||
benchmark benchmark.Benchmark
|
benchmark benchmark.Benchmark
|
||||||
rm_binaries bool = true
|
rm_binaries bool = true
|
||||||
silent_mode bool
|
silent_mode bool
|
||||||
|
@ -186,6 +189,7 @@ pub fn new_test_session(_vargs string, will_compile bool) TestSession {
|
||||||
vexe: vexe
|
vexe: vexe
|
||||||
vroot: vroot
|
vroot: vroot
|
||||||
skip_files: skip_files
|
skip_files: skip_files
|
||||||
|
fail_fast: testing.fail_fast
|
||||||
vargs: vargs
|
vargs: vargs
|
||||||
vtmp_dir: new_vtmp_dir
|
vtmp_dir: new_vtmp_dir
|
||||||
silent_mode: _vargs.contains('-silent')
|
silent_mode: _vargs.contains('-silent')
|
||||||
|
@ -258,6 +262,11 @@ pub fn (mut ts TestSession) test() {
|
||||||
|
|
||||||
fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
||||||
mut ts := &TestSession(p.get_shared_context())
|
mut ts := &TestSession(p.get_shared_context())
|
||||||
|
if ts.fail_fast {
|
||||||
|
if ts.failed {
|
||||||
|
return pool.no_result
|
||||||
|
}
|
||||||
|
}
|
||||||
tmpd := ts.vtmp_dir
|
tmpd := ts.vtmp_dir
|
||||||
show_stats := '-stats' in ts.vargs.split(' ')
|
show_stats := '-stats' in ts.vargs.split(' ')
|
||||||
// tls_bench is used to format the step messages/timings
|
// tls_bench is used to format the step messages/timings
|
||||||
|
|
|
@ -12,9 +12,10 @@ fn main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
args_to_executable := args[1..]
|
args_to_executable := args[1..]
|
||||||
args_before := cmdline.options_before(args_to_executable, ['test'])
|
mut args_before := cmdline.options_before(args_to_executable, ['test'])
|
||||||
args_after := cmdline.options_after(args_to_executable, ['test'])
|
mut args_after := cmdline.options_after(args_to_executable, ['test'])
|
||||||
if args_after.join(' ') == 'v' {
|
fail_fast := extract_flag('-fail-fast', mut args_after, testing.fail_fast)
|
||||||
|
if args_after == ['v'] {
|
||||||
eprintln('`v test v` has been deprecated.')
|
eprintln('`v test v` has been deprecated.')
|
||||||
eprintln('Use `v test-all` instead.')
|
eprintln('Use `v test-all` instead.')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
@ -23,6 +24,7 @@ fn main() {
|
||||||
backend := if backend_pos == -1 { '.c' } else { args_before[backend_pos + 1] } // this giant mess because closures are not implemented
|
backend := if backend_pos == -1 { '.c' } else { args_before[backend_pos + 1] } // this giant mess because closures are not implemented
|
||||||
|
|
||||||
mut ts := testing.new_test_session(args_before.join(' '), true)
|
mut ts := testing.new_test_session(args_before.join(' '), true)
|
||||||
|
ts.fail_fast = fail_fast
|
||||||
for targ in args_after {
|
for targ in args_after {
|
||||||
if os.is_dir(targ) {
|
if os.is_dir(targ) {
|
||||||
// Fetch all tests from the directory
|
// Fetch all tests from the directory
|
||||||
|
@ -133,3 +135,14 @@ fn should_test(path string, backend string) ShouldTestStatus {
|
||||||
}
|
}
|
||||||
return .ignore
|
return .ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn extract_flag(flag_name string, mut after []string, flag_default bool) bool {
|
||||||
|
mut res := flag_default
|
||||||
|
orig_after := after.clone() // workaround for after.filter() codegen bug, when `mut after []string`
|
||||||
|
matches_after := orig_after.filter(it != flag_name)
|
||||||
|
if matches_after.len < after.len {
|
||||||
|
after = matches_after.clone()
|
||||||
|
res = true
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue