tooling: use term.header for tests
parent
9d8116f895
commit
4bb5d7de8b
|
@ -80,17 +80,17 @@ pub fn (ts mut TestSession) test() {
|
|||
ts.files = remaining_files
|
||||
ts.benchmark.set_total_expected_steps(remaining_files.len)
|
||||
|
||||
mut ncpus := runtime.nr_cpus()
|
||||
mut njobs := runtime.nr_jobs()
|
||||
$if msvc {
|
||||
// NB: MSVC can not be launched in parallel, without giving it
|
||||
// the option /FS because it uses a shared PDB file, which should
|
||||
// be locked, but that makes writing slower...
|
||||
// See: https://docs.microsoft.com/en-us/cpp/build/reference/fs-force-synchronous-pdb-writes?view=vs-2019
|
||||
// Instead, just run tests on 1 core for now.
|
||||
ncpus = 1
|
||||
njobs = 1
|
||||
}
|
||||
ts.waitgroup.add( ncpus )
|
||||
for i:=0; i < ncpus; i++ {
|
||||
ts.waitgroup.add( njobs )
|
||||
for i:=0; i < njobs; i++ {
|
||||
go process_in_thread(ts)
|
||||
}
|
||||
ts.waitgroup.wait()
|
||||
|
@ -140,7 +140,7 @@ fn (ts mut TestSession) process_files() {
|
|||
ts.benchmark.step()
|
||||
tls_bench.step()
|
||||
if show_stats {
|
||||
eprintln('-------------------------------------------------')
|
||||
eprintln(term.h_divider('-'))
|
||||
status := os.system(cmd)
|
||||
if status == 0 {
|
||||
ts.benchmark.ok()
|
||||
|
@ -196,7 +196,7 @@ pub fn v_build_failing(zargs string, folder string) bool {
|
|||
parent_dir := filepath.dir(vexe)
|
||||
vlib_should_be_present(parent_dir)
|
||||
vargs := zargs.replace(vexe, '')
|
||||
eprintln(main_label)
|
||||
eheader(main_label)
|
||||
eprintln('v compiler args: "$vargs"')
|
||||
mut session := new_test_session(vargs)
|
||||
files := os.walk_ext(filepath.join(parent_dir,folder), '.v')
|
||||
|
@ -231,7 +231,7 @@ pub fn build_v_cmd_failed(cmd string) bool {
|
|||
}
|
||||
|
||||
pub fn building_any_v_binaries_failed() bool {
|
||||
eprintln('Building V binaries...')
|
||||
eheader('Building V binaries...')
|
||||
eprintln('VFLAGS is: "' + os.getenv('VFLAGS') + '"')
|
||||
vexe := testing.vexe_path()
|
||||
parent_dir := filepath.dir(vexe)
|
||||
|
@ -262,3 +262,11 @@ pub fn building_any_v_binaries_failed() bool {
|
|||
eprintln(bmark.total_message('building v binaries'))
|
||||
return failed
|
||||
}
|
||||
|
||||
pub fn eheader(msg string) {
|
||||
eprintln(term.header(msg,'-'))
|
||||
}
|
||||
|
||||
pub fn header(msg string) {
|
||||
println(term.header(msg,'-'))
|
||||
}
|
||||
|
|
|
@ -43,7 +43,8 @@ fn v_test_compiler(vargs string) {
|
|||
}
|
||||
}
|
||||
building_tools_failed := testing.v_build_failing(vargs, 'tools')
|
||||
eprintln('\nTesting all _test.v files...')
|
||||
eprintln('')
|
||||
testing.eheader('Testing all _test.v files...')
|
||||
mut compiler_test_session := testing.new_test_session(vargs)
|
||||
compiler_test_session.files << os.walk_ext(parent_dir, '_test.v')
|
||||
compiler_test_session.test()
|
||||
|
@ -54,7 +55,8 @@ fn v_test_compiler(vargs string) {
|
|||
building_live_failed := testing.v_build_failing(vargs + '-live', filepath.join('examples','hot_reload'))
|
||||
eprintln('')
|
||||
v_module_install_cmd := '$vexe install nedpals.args'
|
||||
eprintln('\nInstalling a v module with: $v_module_install_cmd ')
|
||||
eprintln('')
|
||||
testing.eheader('Installing a v module with: $v_module_install_cmd')
|
||||
mut vmark := benchmark.new_benchmark()
|
||||
ret := os.system(v_module_install_cmd)
|
||||
if ret != 0 {
|
||||
|
|
|
@ -45,7 +45,7 @@ fn main() {
|
|||
|
||||
fn v_test_formatting(vargs string) {
|
||||
all_v_files := v_files()
|
||||
eprintln('Run "v fmt" over all .v files')
|
||||
testing.eheader('Run "v fmt" over all .v files')
|
||||
mut vfmt_test_session := testing.new_test_session('$vargs fmt -worker')
|
||||
vfmt_test_session.files << all_v_files
|
||||
vfmt_test_session.test()
|
||||
|
|
|
@ -45,7 +45,7 @@ pub fn main() {
|
|||
println('Unrecognized test file $targ .')
|
||||
}
|
||||
|
||||
println('Testing...')
|
||||
testing.header('Testing...')
|
||||
ts.test()
|
||||
|
||||
println( ts.benchmark.total_message('running V _test.v files') )
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
module runtime
|
||||
|
||||
import os
|
||||
|
||||
//$if linux {
|
||||
fn C.sysconf(name int) i64
|
||||
//}
|
||||
|
@ -19,6 +21,16 @@ pub fn nr_cpus() int {
|
|||
return nr_cpus_nix()
|
||||
}
|
||||
|
||||
pub fn nr_jobs() int {
|
||||
mut cpus := nr_cpus()
|
||||
// allow for overrides, for example using `VJOBS=32 ./v test .`
|
||||
vjobs := os.getenv('VJOBS').int()
|
||||
if vjobs > 0 {
|
||||
cpus = vjobs
|
||||
}
|
||||
return cpus
|
||||
}
|
||||
|
||||
pub fn is_32bit() bool {
|
||||
mut x := false
|
||||
$if x32 { x = true }
|
||||
|
|
Loading…
Reference in New Issue