2019-10-30 12:15:33 +03:00
|
|
|
module main
|
|
|
|
|
|
|
|
import os
|
|
|
|
import term
|
2019-12-22 02:22:32 +03:00
|
|
|
// //////////////////////////////////////////////////////////////////
|
|
|
|
// / This file will get compiled as part of the main program,
|
|
|
|
// / for a _test.v file.
|
|
|
|
// / The methods defined here are called back by the test program's
|
|
|
|
// / assert statements, on each success/fail. The goal is to make
|
|
|
|
// / customizing the look & feel of the assertions results easier,
|
|
|
|
// / since it is done in normal V code, instead of in embedded C ...
|
|
|
|
// //////////////////////////////////////////////////////////////////
|
|
|
|
fn cb_assertion_failed(filename string, line int, sourceline string, funcname string) {
|
2020-04-22 02:52:56 +03:00
|
|
|
// color_on := term.can_show_color_on_stderr()
|
2019-10-30 12:15:33 +03:00
|
|
|
use_relative_paths := match os.getenv('VERROR_PATHS') {
|
2019-12-22 02:22:32 +03:00
|
|
|
'absolute'{
|
|
|
|
false
|
|
|
|
}
|
|
|
|
else {
|
2019-12-30 07:23:54 +03:00
|
|
|
true}
|
|
|
|
}
|
2020-03-20 18:41:18 +03:00
|
|
|
final_filename := if use_relative_paths { filename } else { os.real_path(filename) }
|
2019-12-22 02:22:32 +03:00
|
|
|
final_funcname := funcname.replace('main__', '').replace('__', '.')
|
2020-04-08 03:45:49 +03:00
|
|
|
eprintln('$final_filename:$line: failed assert in ${final_funcname}')
|
2019-10-30 12:15:33 +03:00
|
|
|
eprintln('Source : $sourceline')
|
|
|
|
}
|
|
|
|
|
2019-12-22 02:22:32 +03:00
|
|
|
fn cb_assertion_ok(filename string, line int, sourceline string, funcname string) {
|
|
|
|
// do nothing for now on an OK assertion
|
|
|
|
// println('OK ${line:5d}|$sourceline ')
|
2019-12-30 07:23:54 +03:00
|
|
|
}
|