mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
tools,testing: limit header length used in v test
, make CI assertion failures easier to read
This commit is contained in:
parent
1b9a8b996d
commit
65038a4a2a
2 changed files with 29 additions and 9 deletions
|
@ -13,6 +13,8 @@ import runtime
|
||||||
import rand
|
import rand
|
||||||
import strings
|
import strings
|
||||||
|
|
||||||
|
pub const max_header_len = get_max_header_len()
|
||||||
|
|
||||||
pub const host_os = pref.get_host_os()
|
pub const host_os = pref.get_host_os()
|
||||||
|
|
||||||
pub const github_job = os.getenv('GITHUB_JOB')
|
pub const github_job = os.getenv('GITHUB_JOB')
|
||||||
|
@ -45,7 +47,8 @@ pub const is_go_present = os.execute('go version').exit_code == 0
|
||||||
pub const all_processes = get_all_processes()
|
pub const all_processes = get_all_processes()
|
||||||
|
|
||||||
pub const header_bytes_to_search_for_module_main = 500
|
pub const header_bytes_to_search_for_module_main = 500
|
||||||
pub const separator = '-'.repeat(100)
|
|
||||||
|
pub const separator = '-'.repeat(max_header_len)
|
||||||
|
|
||||||
pub const max_compilation_retries = get_max_compilation_retries()
|
pub const max_compilation_retries = get_max_compilation_retries()
|
||||||
|
|
||||||
|
@ -676,7 +679,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
||||||
details.retry++
|
details.retry++
|
||||||
}
|
}
|
||||||
failure_output.write_string(separator)
|
failure_output.write_string(separator)
|
||||||
failure_output.writeln(' retry: 0 ; max_retry: ${details.retry} ; r.exit_code: ${r.exit_code} ; trimmed_output.len: ${trimmed_output.len}')
|
failure_output.writeln('\n retry: 0 ; max_retry: ${details.retry} ; r.exit_code: ${r.exit_code} ; trimmed_output.len: ${trimmed_output.len}')
|
||||||
failure_output.writeln(trimmed_output)
|
failure_output.writeln(trimmed_output)
|
||||||
os.setenv('VTEST_RETRY_MAX', '${details.retry}', true)
|
os.setenv('VTEST_RETRY_MAX', '${details.retry}', true)
|
||||||
for retry = 1; retry <= details.retry; retry++ {
|
for retry = 1; retry <= details.retry; retry++ {
|
||||||
|
@ -699,7 +702,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
||||||
}
|
}
|
||||||
trimmed_output = r.output.trim_space()
|
trimmed_output = r.output.trim_space()
|
||||||
failure_output.write_string(separator)
|
failure_output.write_string(separator)
|
||||||
failure_output.writeln(' retry: ${retry} ; max_retry: ${details.retry} ; r.exit_code: ${r.exit_code} ; trimmed_output.len: ${trimmed_output.len}')
|
failure_output.writeln('\n retry: ${retry} ; max_retry: ${details.retry} ; r.exit_code: ${r.exit_code} ; trimmed_output.len: ${trimmed_output.len}')
|
||||||
failure_output.writeln(trimmed_output)
|
failure_output.writeln(trimmed_output)
|
||||||
time.sleep(fail_retry_delay_ms)
|
time.sleep(fail_retry_delay_ms)
|
||||||
}
|
}
|
||||||
|
@ -850,11 +853,15 @@ pub fn building_any_v_binaries_failed() bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bmark.stop()
|
bmark.stop()
|
||||||
eprintln(term.h_divider('-'))
|
h_divider()
|
||||||
eprintln(bmark.total_message('building v binaries'))
|
eprintln(bmark.total_message('building v binaries'))
|
||||||
return failed
|
return failed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn h_divider() {
|
||||||
|
eprintln(term.h_divider('-')#[..max_header_len])
|
||||||
|
}
|
||||||
|
|
||||||
// setup_new_vtmp_folder creates a new nested folder inside VTMP, then resets VTMP to it,
|
// setup_new_vtmp_folder creates a new nested folder inside VTMP, then resets VTMP to it,
|
||||||
// so that V programs/tests will write their temporary files to new location.
|
// so that V programs/tests will write their temporary files to new location.
|
||||||
// The new nested folder, and its contents, will get removed after all tests/programs succeed.
|
// The new nested folder, and its contents, will get removed after all tests/programs succeed.
|
||||||
|
@ -899,15 +906,28 @@ pub fn find_started_process(pname string) !string {
|
||||||
return error('could not find process matching ${pname}')
|
return error('could not find process matching ${pname}')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn limited_header(msg string) string {
|
||||||
|
return term.header_left(msg, '-')#[..max_header_len]
|
||||||
|
}
|
||||||
|
|
||||||
pub fn eheader(msg string) {
|
pub fn eheader(msg string) {
|
||||||
eprintln(term.header_left(msg, '-'))
|
eprintln(limited_header(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn header(msg string) {
|
pub fn header(msg string) {
|
||||||
println(term.header_left(msg, '-'))
|
println(limited_header(msg))
|
||||||
flush_stdout()
|
flush_stdout()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn random_sleep_ms(min_ms int, random_add_ms int) {
|
fn random_sleep_ms(min_ms int, random_add_ms int) {
|
||||||
time.sleep((100 + rand.intn(100) or { 0 }) * time.millisecond)
|
time.sleep((50 + rand.intn(50) or { 0 }) * time.millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_max_header_len() int {
|
||||||
|
maximum := 140
|
||||||
|
cols, _ := term.get_terminal_size()
|
||||||
|
if cols > maximum {
|
||||||
|
return maximum
|
||||||
|
}
|
||||||
|
return cols
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ module testing
|
||||||
import time
|
import time
|
||||||
import term
|
import term
|
||||||
|
|
||||||
pub const empty = term.header(' ', ' ')
|
pub const empty = term.header(' ', ' ')#[..max_header_len]
|
||||||
|
|
||||||
// NormalReporter implements the interface testing.Reporter.
|
// NormalReporter implements the interface testing.Reporter.
|
||||||
// It is used by default by `v test .`
|
// It is used by default by `v test .`
|
||||||
|
@ -63,7 +63,7 @@ pub fn (r NormalReporter) message(index int, message string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (r NormalReporter) divider() {
|
pub fn (r NormalReporter) divider() {
|
||||||
eprintln(term.h_divider('-'))
|
h_divider()
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue