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

test: use 'stty size' for vtest --- line instead of 'tput cols'

This commit is contained in:
Delyan Angelov 2019-12-23 12:23:53 +02:00 committed by Alexander Medvednikov
parent 6c4ef368d7
commit cf37028a52
4 changed files with 16 additions and 10 deletions

View File

@ -94,6 +94,7 @@ pub fn (ts mut TestSession) test() {
os.rm( tmpc_filepath ) os.rm( tmpc_filepath )
} }
ts.benchmark.stop() ts.benchmark.stop()
eprintln(term.h_divider())
} }
pub fn vlib_should_be_present( parent_dir string ) { 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}')) eprintln(bmark.step_message('$cmd => ${bok}'))
} }
bmark.stop() bmark.stop()
eprintln(term.h_divider())
eprintln( bmark.total_message( 'building v binaries' ) ) eprintln( bmark.total_message( 'building v binaries' ) )
return failed return failed

View File

@ -47,15 +47,6 @@ pub fn main() {
println('Testing...') println('Testing...')
ts.test() 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') ) println( ts.benchmark.total_message('running V _test.v files') )
if ts.failed { if ts.failed {
exit(1) exit(1)

View File

@ -27,3 +27,17 @@ pub fn fail_message(s string) string {
return if can_show_color_on_stdout() { red(s) } else { s } 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)
}

View File

@ -95,4 +95,3 @@ pub fn show_cursor() {
pub fn hide_cursor() { pub fn hide_cursor() {
print('\x1b[?25l') print('\x1b[?25l')
} }