mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tests: unify all temporary files/folders under $VTMP/v
, that can be cleaned by v wipe-cache
(#15774)
This commit is contained in:
@ -4,6 +4,7 @@ import os
|
||||
import time
|
||||
import term
|
||||
import benchmark
|
||||
import sync
|
||||
import sync.pool
|
||||
import v.pref
|
||||
import v.util.vtest
|
||||
@ -281,13 +282,17 @@ pub fn (mut ts TestSession) test() {
|
||||
ts.append_message(.sentinel, '') // send the sentinel
|
||||
_ := <-ts.nprint_ended // wait for the stop of the printing thread
|
||||
eprintln(term.h_divider('-'))
|
||||
ts.show_list_of_failed_tests()
|
||||
// cleanup generated .tmp.c files after successful tests:
|
||||
if ts.benchmark.nfail == 0 {
|
||||
if ts.rm_binaries {
|
||||
os.rmdir_all(ts.vtmp_dir) or {}
|
||||
}
|
||||
}
|
||||
ts.show_list_of_failed_tests()
|
||||
// remove empty session folders:
|
||||
if os.ls(ts.vtmp_dir) or { [] }.len == 0 {
|
||||
os.rmdir_all(ts.vtmp_dir) or {}
|
||||
}
|
||||
}
|
||||
|
||||
fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
||||
@ -343,10 +348,8 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
||||
}
|
||||
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.rm_binaries {
|
||||
os.rm(generated_binary_fpath) or {}
|
||||
}
|
||||
|
||||
cmd_options << ' -o ${os.quoted_path(generated_binary_fpath)}'
|
||||
@ -439,7 +442,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
||||
}
|
||||
}
|
||||
}
|
||||
if produces_file_output && os.exists(generated_binary_fpath) && ts.rm_binaries {
|
||||
if produces_file_output && ts.rm_binaries {
|
||||
os.rm(generated_binary_fpath) or {}
|
||||
}
|
||||
return pool.no_result
|
||||
@ -571,7 +574,7 @@ pub fn header(msg string) {
|
||||
|
||||
pub fn setup_new_vtmp_folder() string {
|
||||
now := time.sys_mono_now()
|
||||
new_vtmp_dir := os.join_path(os.temp_dir(), 'v', 'test_session_$now')
|
||||
new_vtmp_dir := os.join_path(os.temp_dir(), 'v', 'tsession_${sync.thread_id().hex()}_$now')
|
||||
os.mkdir_all(new_vtmp_dir) or { panic(err) }
|
||||
os.setenv('VTMP', new_vtmp_dir, true)
|
||||
return new_vtmp_dir
|
||||
|
Reference in New Issue
Block a user