test: use 'stty size' for vtest --- line instead of 'tput cols'
parent
6c4ef368d7
commit
cf37028a52
|
@ -94,6 +94,7 @@ pub fn (ts mut TestSession) test() {
|
|||
os.rm( tmpc_filepath )
|
||||
}
|
||||
ts.benchmark.stop()
|
||||
eprintln(term.h_divider())
|
||||
}
|
||||
|
||||
pub fn vlib_should_be_present( parent_dir string ) {
|
||||
|
@ -177,6 +178,7 @@ pub fn building_any_v_binaries_failed() bool {
|
|||
eprintln(bmark.step_message('$cmd => ${bok}'))
|
||||
}
|
||||
bmark.stop()
|
||||
eprintln(term.h_divider())
|
||||
eprintln( bmark.total_message( 'building v binaries' ) )
|
||||
|
||||
return failed
|
||||
|
|
|
@ -47,15 +47,6 @@ pub fn main() {
|
|||
println('Testing...')
|
||||
ts.test()
|
||||
|
||||
// Print separator with dynamic width
|
||||
mut cols := 76
|
||||
if tput := os.exec("tput cols; echo") {
|
||||
if tput.exit_code == 0 {
|
||||
cols = tput.output.int()
|
||||
}
|
||||
}
|
||||
println("-".repeat(cols))
|
||||
|
||||
println( ts.benchmark.total_message('running V _test.v files') )
|
||||
if ts.failed {
|
||||
exit(1)
|
||||
|
|
|
@ -27,3 +27,17 @@ pub fn fail_message(s string) string {
|
|||
return if can_show_color_on_stdout() { red(s) } else { s }
|
||||
}
|
||||
|
||||
// h_divider will return a horizontal divider line with a dynamic width,
|
||||
// that depends on the current terminal settings
|
||||
pub fn h_divider() string {
|
||||
mut cols := 76
|
||||
if term_size := os.exec('stty size') {
|
||||
if term_size.exit_code == 0 {
|
||||
term_cols := term_size.output.split(' ')[1].int()
|
||||
if term_cols > 0 {
|
||||
cols = term_cols
|
||||
}
|
||||
}
|
||||
}
|
||||
return '-'.repeat(cols)
|
||||
}
|
||||
|
|
|
@ -95,4 +95,3 @@ pub fn show_cursor() {
|
|||
pub fn hide_cursor() {
|
||||
print('\x1b[?25l')
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue