File: pytest_runner.py

package info (click to toggle)
yt 4.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,084 kB
  • sloc: python: 132,484; ansic: 5,628; cpp: 1,588; javascript: 352; makefile: 138; sh: 43; csh: 36
file content (37 lines) | stat: -rw-r--r-- 1,072 bytes parent folder | download
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
"""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)
        )