Skip to content

Commit b3cb8a1

Browse files
committed
ci: make sure that only one copy of native_test.v is executed at once, when run through v test vlib (fix #24505)
1 parent e90c0a8 commit b3cb8a1

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

vlib/v/gen/native/macho_test.v

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import os
22
import v.gen.native
33
import v.pref
4+
import log
45

56
fn test_macho() {
6-
os.chdir(os.temp_dir()) or {}
7+
log.info('start')
8+
os.chdir(os.vtmp_dir()) or {}
9+
log.info('chdir')
710
mut g := native.macho_test_new_gen(&pref.Preferences{
811
arch: .amd64
912
}, 'test.bin')
13+
log.info('native.macho_test_new_gen')
1014
g.generate_macho_header()
15+
log.info('g.generate_macho_header')
1116
g.generate_macho_footer()
17+
log.info('g.generate_macho_footer')
1218
}

vlib/v/gen/native/tests/native_test.v

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,36 @@
11
// vtest build: (amd64 || arm64) && !self_sandboxed_packaging? && !gcc-windows
2+
@[has_globals]
3+
module main
4+
25
import os
36
import time
47
import benchmark
58
import term
9+
import log
10+
import os.filelock
611

712
const is_verbose = os.getenv('VTEST_SHOW_CMD') != ''
813
const user_os = os.user_os()
914
const wrkdir = os.join_path(os.vtmp_dir(), 'native_tests')
1015

16+
const flock_path = os.join_path(os.vtmp_dir(), 'native_tests.lock')
17+
18+
__global flock_singleton = filelock.new(flock_path)
19+
1120
fn testsuite_begin() {
21+
log.info(@FN)
22+
if !flock_singleton.try_acquire() {
23+
log.info('>>>> skipping ${@FILE}, since it has been already started and ${flock_path} is present...')
24+
exit(0)
25+
}
1226
os.mkdir_all(wrkdir) or {}
1327
os.chdir(wrkdir) or {}
1428
}
1529

1630
fn testsuite_end() {
1731
os.rmdir_all(wrkdir) or {}
32+
flock_singleton.release()
33+
log.info(@FN)
1834
}
1935

2036
// TODO: some logic copy pasted from valgrind_test.v and compiler_test.v, move to a module

0 commit comments

Comments
 (0)