test: save removing the nonexistent binary output for v fmt and v vet tests

pull/13987/head
Delyan Angelov 2022-04-09 13:03:52 +03:00
parent 2d867a2766
commit 60e718e7c6
4 changed files with 19 additions and 20 deletions

View File

@ -306,13 +306,15 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
mut run_js := false
is_fmt := ts.vargs.contains('fmt')
is_vet := ts.vargs.contains('vet')
produces_file_output := !(is_fmt || is_vet)
if relative_file.ends_with('js.v') {
if !is_fmt {
if produces_file_output {
cmd_options << ' -b js'
}
run_js = true
}
}
if relative_file.contains('global') && !is_fmt {
cmd_options << ' -enable-globals'
@ -333,13 +335,13 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
fname.replace('.v', '')
}
generated_binary_fpath := os.join_path_single(tmpd, generated_binary_fname)
if produces_file_output {
if os.exists(generated_binary_fpath) {
if ts.rm_binaries {
os.rm(generated_binary_fpath) or {}
}
}
if !ts.vargs.contains('fmt') {
cmd_options << ' -o ${os.quoted_path(generated_binary_fpath)}'
}
cmd := '${os.quoted_path(ts.vexe)} ' + cmd_options.join(' ') + ' ${os.quoted_path(file)}'
@ -421,11 +423,9 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
}
}
}
if os.exists(generated_binary_fpath) {
if ts.rm_binaries {
if produces_file_output && os.exists(generated_binary_fpath) && ts.rm_binaries {
os.rm(generated_binary_fpath) or {}
}
}
return pool.no_result
}

View File

@ -247,13 +247,9 @@ fn (mut foptions FormatOptions) post_process_file(file string, formatted_file_pa
if !is_formatted_different {
return
}
x := diff.color_compare_files(foptions.find_diff_cmd(), file, formatted_file_path)
if x.len != 0 {
println("$file is not vfmt'ed")
return error('')
}
return
}
if foptions.is_c {
if is_formatted_different {
eprintln('File is not formatted: $file')

View File

@ -332,7 +332,10 @@ pub fn execute(cmd string) Result {
// if cmd.contains(';') || cmd.contains('&&') || cmd.contains('||') || cmd.contains('\n') {
// return Result{ exit_code: -1, output: ';, &&, || and \\n are not allowed in shell commands' }
// }
pcmd := if cmd.contains('2>') { cmd } else { '$cmd 2>&1' }
pcmd := if cmd.contains('2>') { cmd.clone() } else { '$cmd 2>&1' }
defer {
unsafe { pcmd.free() }
}
f := vpopen(pcmd)
if isnil(f) {
return Result{

View File

@ -142,11 +142,11 @@ pub fn h_divider(divider string) string {
// ==== TITLE =========================
pub fn header_left(text string, divider string) string {
plain_text := strip_ansi(text)
xcols, _ := get_terminal_size()
xcols, _ := get_terminal_size() // can get 0 in lldb/gdb
cols := imax(1, xcols)
relement := if divider.len > 0 { divider } else { ' ' }
hstart := relement.repeat(4)[0..4]
remaining_cols := (cols - (hstart.len + 1 + plain_text.len + 1))
remaining_cols := imax(0, (cols - (hstart.len + 1 + plain_text.len + 1)))
hend := relement.repeat((remaining_cols + 1) / relement.len)[0..remaining_cols]
return '$hstart $text $hend'
}