tests: reduce the likelyhood of naming collisions for v test session folders, started at the exact same time (the time resolution on windows is much lower)

This commit is contained in:
Delyan Angelov 2024-05-24 12:29:32 +03:00
parent 527559c656
commit 1cd561feb4
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED

View file

@ -303,7 +303,7 @@ pub fn new_test_session(_vargs string, will_compile bool) TestSession {
vargs := _vargs.replace('-progress', '') vargs := _vargs.replace('-progress', '')
vexe := pref.vexe_path() vexe := pref.vexe_path()
vroot := os.dir(vexe) vroot := os.dir(vexe)
hash := '${sync.thread_id().hex()}_${time.sys_mono_now()}' hash := '${sync.thread_id().hex()}_${rand.ulid()}'
new_vtmp_dir := setup_new_vtmp_folder(hash) new_vtmp_dir := setup_new_vtmp_folder(hash)
if term.can_show_color_on_stderr() { if term.can_show_color_on_stderr() {
os.setenv('VCOLORS', 'always', true) os.setenv('VCOLORS', 'always', true)
@ -504,7 +504,8 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
// where an executable is not writable, if it is running). // where an executable is not writable, if it is running).
// Note, that the common session temporary folder ts.vtmp_dir, // Note, that the common session temporary folder ts.vtmp_dir,
// will be removed after all tests are done. // will be removed after all tests are done.
mut test_folder_path := os.join_path(ts.vtmp_dir, rand.ulid()) test_id := '${idx}_${thread_id}'
mut test_folder_path := os.join_path(ts.vtmp_dir, test_id)
if ts.build_tools { if ts.build_tools {
// `v build-tools`, produce all executables in the same session folder, so that they can be copied later: // `v build-tools`, produce all executables in the same session folder, so that they can be copied later:
test_folder_path = ts.vtmp_dir test_folder_path = ts.vtmp_dir