Skip to content

Commit

Permalink
make vlib/v/gen/native/tests/native_test.v even more detailed
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Sep 8, 2023
1 parent 7a6120f commit 9b93d0d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions vlib/v/gen/native/tests/native_test.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import time
import benchmark
import term

Expand All @@ -9,11 +10,6 @@ fn test_native() {
$if arm64 {
return
}
// some tests are running fine in macos
// if os.user_os() != 'linux' && os.user_os() != 'macos' {
// eprintln('native tests only run on Linux and macOS for now.')
// exit(0)
// }
mut bench := benchmark.new_benchmark()
vexe := os.getenv('VEXE')
vroot := os.dir(vexe)
Expand Down Expand Up @@ -41,12 +37,13 @@ fn test_native() {
exe_test_path := os.join_path(wrkdir, test_file_name + '.exe')
tmperrfile := os.join_path(dir, test + '.tmperr')
cmd := '${os.quoted_path(vexe)} -o ${os.quoted_path(exe_test_path)} -b native -skip-unused ${os.quoted_path(full_test_path)} -d custom_define 2> ${os.quoted_path(tmperrfile)}'

if is_verbose {
println(cmd)
}

sw_compile := time.new_stopwatch()
res_native := os.execute(cmd)
compile_time_ms := sw_compile.elapsed().milliseconds()
if res_native.exit_code != 0 {
bench.fail()
eprintln(bench.step_message_fail(cmd))
Expand All @@ -59,7 +56,9 @@ fn test_native() {
continue
}

sw_run := time.new_stopwatch()
res := os.execute('${os.quoted_path(exe_test_path)} 2> ${os.quoted_path(tmperrfile)}')
runtime_ms := sw_run.elapsed().milliseconds()
if res.exit_code != 0 {
bench.fail()
eprintln(bench.step_message_fail('${full_test_path} failed to run'))
Expand Down Expand Up @@ -102,7 +101,7 @@ fn test_native() {
continue
}
bench.ok()
eprintln(bench.step_message_ok(relative_test_path))
eprintln(bench.step_message_ok('${relative_test_path:-45} , took ${compile_time_ms:4}ms to compile, ${runtime_ms:4}ms to run'))
}
bench.stop()
eprintln(term.h_divider('-'))
Expand Down

0 comments on commit 9b93d0d

Please sign in to comment.