Commit 811bb182 authored by BOHMRR's avatar BOHMRR
Browse files

pytest: add --param_file option to prepare_pytests.py and run_pytests.py

parent 0dafaac7
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -168,3 +168,6 @@ tests/run_pytests.py
# - either go back to 4.
# - or commit and push your changes
```

Both scripts allow to restrict the reference generation or the testing to test_param_file tests
with a custom `.prm` file via the `--param_file` option.
+11 −2
Original line number Diff line number Diff line
@@ -67,6 +67,11 @@ def main(argv):
        default="auto",
        help="Number of processes to use in pytest (default: auto)",
    )
    parser.add_argument(
        "--param_file",
        action="store",
        help="Restrict reference generation to test_param_file with specified param file.",
    )

    args = parser.parse_args(argv[1:])

@@ -99,8 +104,11 @@ def main(argv):
        base_cmd = ["pytest"]
    else:
        base_cmd = ["python3", "-m", "pytest"]
    if args.param_file:
        base_cmd += ["tests/test_param_file.py", "--param_file", args.param_file]
    else:
        base_cmd += ["tests"]
    base_cmd += [
        "tests",
        "-n",
        args.numprocesses,
        "--update_ref",
@@ -115,6 +123,7 @@ def main(argv):
        ]

    result = subprocess.run(base_cmd + ["-m", "create_ref"], check=False)
    if not args.param_file:
        result = subprocess.run(base_cmd + ["-m", "create_ref_part2"], check=False)
    return result.returncode

+12 −6
Original line number Diff line number Diff line
@@ -66,13 +66,18 @@ def main(argv):
        default="auto",
        help="Number of processes to use in pytest (default: auto)",
    )
    parser.add_argument(
        "--param_file",
        action="store",
        help="Restrict test run to test_param_file with specified param file.",
    )

    args = parser.parse_args(argv[1:])

    # check for references
    if not os.path.exists(REFERENCE_DIR):
        sys.exit(
            f"References directory {REFERENCE_DIR} not found.\n" "Please create the references."
            f"References directory {REFERENCE_DIR} not found.\nPlease create the references."
        )

    # check for DUT binaries
@@ -87,11 +92,12 @@ def main(argv):
        cmd = ["pytest"]
    else:
        cmd = ["python3", "-m", "pytest"]
    cmd += [
        "tests",
        "-n",
        args.numprocesses,
    ]
    if args.param_file:
        cmd += ["tests/test_param_file.py", "--param_file", args.param_file]
    else:
        cmd += ["tests"]
    cmd += ["-n", args.numprocesses]

    result = subprocess.run(cmd, check=False)
    return result.returncode