Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions scripts/test/test_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,37 +107,48 @@ def _verify(env: dict[str, str], *args: str) -> subprocess.CompletedProcess[str]
)


def test_mpd_build_precedes_identical_test_selections(tools: tuple[Path, dict[str, str]]) -> None:
@pytest.mark.parametrize("pattern", [None, "^identifier$"])
Comment thread
knoepfel marked this conversation as resolved.
Resolved
@pytest.mark.parametrize("verbose", [False, True])
def test_mpd_build_precedes_identical_test_selections(
tools: tuple[Path, dict[str, str]], pattern: str | None, verbose: bool
) -> None:
"""Verify the MPD workflow runs discover, select, build, list and test in order.

All phases must share one parent shell, and each phase's stdout and stderr
must appear in the verification output.

Args:
tools: Build directory and environment from the ``tools`` fixture.
pattern: Optional test-selection regex; ``None`` runs the full suite.
verbose: Whether to request verbose test output.

Raises:
AssertionError: If the return code, command order, arguments or output
differ from the expected MPD workflow.
"""
build, env = tools
result = _verify(env, "--project", "phlex-work-dir", "--tests", "^identifier$", "--verbose")
_, env = tools
args = ["--project", "phlex-work-dir"]
if pattern is not None:
args.extend(["--tests", pattern])
if verbose:
args.append("--verbose")
result = _verify(env, *args)
assert result.returncode == 0, result.stderr
commands = _commands(env)
assert [c[0] for c in commands] == ["discover", "select", "build", "list", "test"]
assert commands[0][2] == ["mpd", "info", "--build", "phlex-work-dir"]
assert commands[1][2] == ["mpd", "select", "--project", "phlex-work-dir"]
assert commands[2][2] == ["mpd", "build"]
assert commands[1][3] == commands[2][3] == commands[4][3]
selection = ["-R", "^identifier$"]
selection = ["-R", pattern] if pattern is not None else []
assert commands[3][1] == commands[4][1] == "spack"
assert commands[3][2] == ["mpd", "test", "--", *selection, "-N"]
assert commands[4][2] == [
"mpd",
"test",
"--",
*selection,
"-V",
*(["-V"] if verbose else []),
"--parallel",
"--output-on-failure",
"--no-tests=error",
Expand Down
12 changes: 5 additions & 7 deletions scripts/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,14 @@ fi

if [[ -n "$project" ]]; then
test_command=(spack mpd test --)
selection=()
else
test_command=(ctest)
selection=(--test-dir "$build_dir")
test_command=(ctest --test-dir "$build_dir")
fi
if [[ -n "$pattern" ]]; then
selection+=(-R "$pattern")
test_command+=(-R "$pattern")
fi
"${test_command[@]}" "${selection[@]}" -N
"${test_command[@]}" -N
if [[ "$verbose" == 1 ]]; then
selection+=(-V)
test_command+=(-V)
fi
"${test_command[@]}" "${selection[@]}" --parallel --output-on-failure --no-tests=error
"${test_command[@]}" --parallel --output-on-failure --no-tests=error
Loading