1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tests: improved test output formatting

This commit is contained in:
Delyan Angelov
2019-12-30 06:23:54 +02:00
committed by Alexander Medvednikov
parent 4f173c8900
commit a0f32f5c29
11 changed files with 144 additions and 95 deletions

View File

@ -1,6 +1,5 @@
// Build and run files in ./prod/ folder, comparing their output to *.expected.txt files.
// (Similar to REPL tests, but in -prod mode.)
// import os
import compiler.tests.repl.runner
import benchmark
@ -15,15 +14,15 @@ fn test_all_v_prod_files() {
bmark.step()
fres := runner.run_prod_file(options.wd, options.vexec, file) or {
bmark.fail()
eprintln( bmark.step_message(err) )
eprintln(bmark.step_message_fail(err))
assert false
continue
}
bmark.ok()
println( bmark.step_message(fres) )
println(bmark.step_message_ok(fres))
assert true
}
bmark.stop()
println( bmark.total_message('total time spent running PROD files') )
println(bmark.total_message('total time spent running PROD files'))
}
}

View File

@ -8,15 +8,17 @@ 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) }
//println('"$vcmd" exit_code: $r.exit_code | output: $r.output')
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) }
//println('"$vcmd_error" exit_code: $r_error.exit_code | output: $r_error.output')
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
assert r_error.output == '`nonexisting.v` does not exist'
}
@ -28,15 +30,14 @@ fn test_all_v_repl_files() {
bmark.step()
fres := runner.run_repl_file(options.wd, options.vexec, file) or {
bmark.fail()
eprintln( bmark.step_message(err) )
eprintln(bmark.step_message_fail(err))
assert false
continue
}
bmark.ok()
println( bmark.step_message(fres) )
println(bmark.step_message_ok(fres))
assert true
}
bmark.stop()
println( bmark.total_message('total time spent running REPL files') )
println(bmark.total_message('total time spent running REPL files'))
}

View File

@ -4,22 +4,21 @@ import compiler.tests.repl.runner
import log
import benchmark
fn main(){
fn main() {
mut logger := log.Log{}
logger.set_level(log.DEBUG)
options := runner.new_options()
mut bmark := benchmark.new_benchmark()
for file in options.files {
bmark.step()
fres := runner.run_repl_file(options.wd, options.vexec, file) or {
bmark.fail()
logger.error( bmark.step_message( err ) )
logger.error(bmark.step_message_fail(err))
continue
}
bmark.ok()
logger.info( bmark.step_message( fres ) )
logger.info(bmark.step_message_ok(fres))
}
bmark.stop()
logger.info( bmark.total_message('total time spent running REPL files') )
logger.info(bmark.total_message('total time spent running REPL files'))
}