forked from yt-project/yt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpytest_runner.py
38 lines (32 loc) · 1.05 KB
/
pytest_runner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""This is a helper script for running answer tests on CI services.
It's currently used on:
* Jenkins
* GHA
for executing answer tests and optionally generating new answers.
"""
import glob
import os
import pytest
if __name__ == "__main__":
os.environ["OMP_NUM_THREADS"] = "1"
pytest_args = [
"-s",
"-v",
"-rsfE", # it means -r "sfE" (show skipped, failed, errors), no -r -s -f -E
"--with-answer-testing",
"-m answer_test",
f"-n {int(os.environ.get('NUM_WORKERS', 1))}",
"--dist=loadscope",
]
pytest.main(pytest_args + ["--local-dir=answer-store", "--junitxml=answers.xml"])
if files := glob.glob("generate_test*.txt"):
tests = set()
for fname in files:
with open(fname) as fp:
tests |= set(fp.read().splitlines())
output_dir = "artifacts"
if not os.path.isdir(output_dir):
os.mkdir(output_dir)
pytest.main(
pytest_args + [f"--local-dir={output_dir}", "--answer-store"] + list(tests)
)