Skip to content

Commit 45a1dfd

Browse files
committed
Using a lock file to protect against multiple regression testing jobs by the
same user running at the same time. We use a shared account for regression testing. Without the lock, we often step on each other's toes.
1 parent 992af12 commit 45a1dfd

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

regtest.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
import time
2222
import re
2323
import json
24+
import fasteners
25+
import tempfile
26+
import getpass
2427

2528
import params
2629
import test_util
@@ -1293,5 +1296,17 @@ def email_developers():
12931296

12941297

12951298
if __name__ == "__main__":
1296-
n = test_suite(sys.argv[1:])
1297-
sys.exit(n)
1299+
temp_dir = tempfile.gettempdir()
1300+
temp_file = os.path.join(temp_dir, 'amrex_regtest_lock_file_'+getpass.getuser())
1301+
test_lock = fasteners.InterProcessLock(temp_file)
1302+
gotten = test_lock.acquire(blocking=False)
1303+
status = 255
1304+
try:
1305+
if gotten:
1306+
status = test_suite(sys.argv[1:])
1307+
else:
1308+
print("Wait please! Another process is running regression tests.")
1309+
finally:
1310+
if gotten:
1311+
test_lock.release()
1312+
sys.exit(status)

0 commit comments

Comments
 (0)