-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: integration test suite (#2081)
- Move helper functions to own file - Use physical rather than logical CPU cores for parallel runs - Add verbose flag when running on CI, which makes it much easier to debug failures
- Loading branch information
1 parent
5be2597
commit 194639d
Showing
4 changed files
with
57 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from enum import IntEnum | ||
from pathlib import Path | ||
import subprocess | ||
|
||
PIXI_VERSION = "0.29.0" | ||
|
||
|
||
class ExitCode(IntEnum): | ||
SUCCESS = 0 | ||
FAILURE = 1 | ||
INCORRECT_USAGE = 2 | ||
|
||
|
||
def verify_cli_command( | ||
command: list[Path | str], | ||
expected_exit_code: ExitCode, | ||
stdout_contains: str | list[str] | None = None, | ||
stdout_excludes: str | list[str] | None = None, | ||
stderr_contains: str | list[str] | None = None, | ||
stderr_excludes: str | list[str] | None = None, | ||
) -> None: | ||
process = subprocess.run(command, capture_output=True, text=True) | ||
stdout, stderr, returncode = process.stdout, process.stderr, process.returncode | ||
print(f"command: {command}, stdout: {stdout}, stderr: {stderr}, code: {returncode}") | ||
if expected_exit_code is not None: | ||
assert ( | ||
returncode == expected_exit_code | ||
), f"Return code was {returncode}, expected {expected_exit_code}, stderr: {stderr}" | ||
|
||
if stdout_contains: | ||
if isinstance(stdout_contains, str): | ||
stdout_contains = [stdout_contains] | ||
for substring in stdout_contains: | ||
assert substring in stdout, f"'{substring}' not found in stdout: {stdout}" | ||
|
||
if stdout_excludes: | ||
if isinstance(stdout_excludes, str): | ||
stdout_excludes = [stdout_excludes] | ||
for substring in stdout_excludes: | ||
assert substring not in stdout, f"'{substring}' unexpectedly found in stdout: {stdout}" | ||
|
||
if stderr_contains: | ||
if isinstance(stderr_contains, str): | ||
stderr_contains = [stderr_contains] | ||
for substring in stderr_contains: | ||
assert substring in stderr, f"'{substring}' not found in stderr: {stderr}" | ||
|
||
if stderr_excludes: | ||
if isinstance(stderr_excludes, str): | ||
stderr_excludes = [stderr_excludes] | ||
for substring in stderr_excludes: | ||
assert substring not in stderr, f"'{substring}' unexpectedly found in stderr: {stderr}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters