Skip to content

Commit

Permalink
Changw to file when checking test output
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Jaegervall <[email protected]>
  • Loading branch information
erikbosch committed Nov 15, 2024
1 parent 3d3c28f commit 40c992d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
29 changes: 12 additions & 17 deletions tests/vspec/test_extended/test_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#
# SPDX-License-Identifier: MPL-2.0

import os
import subprocess
from pathlib import Path

Expand Down Expand Up @@ -48,25 +47,23 @@ def test_extended_ok(
tmp_path,
):
output = tmp_path / "out.json"
cmd = f"vspec export json --pretty -u {TEST_UNITS}"
log = tmp_path / "out.log"
cmd = f"vspec --log-file {log} export json --pretty -u {TEST_UNITS}"
cmd += f" -q {TEST_QUANT} {extended_args} -s {TEST_FILE} -o {output}"

# Make sure there is no line break that affects compare
env = os.environ.copy()
env["COLUMNS"] = "120"
subprocess.run(cmd.split(), capture_output=True, text=True)

process = subprocess.run(cmd.split(), capture_output=True, check=True, text=True, env=env)
log_content = log.read_text()

if known_extended is not None:
print(process.stdout)
check_str = KNOWN_PREFIX + known_extended + " "
assert check_str in process.stdout
check_str = KNOWN_PREFIX + known_extended
assert check_str in log_content
else:
assert KNOWN_PREFIX not in process.stdout
assert KNOWN_PREFIX not in log_content

if extended_warning:
for i in extended_warning.split(","):
assert (WARNING_PREFIX + f" 'A.SignalA':'{i.strip()}'") in process.stdout
assert (WARNING_PREFIX + f" 'A.SignalA':'{i.strip()}'") in log_content


@pytest.mark.parametrize(
Expand All @@ -81,13 +78,11 @@ def test_extended_ok(
)
def test_extended_error(extended_args: str, tmp_path):
output = tmp_path / "out.json"
cmd = f"vspec export json --pretty -u {TEST_UNITS}"
log = tmp_path / "out.log"
cmd = f"vspec --log-file {log} export json --pretty -u {TEST_UNITS}"
cmd += f" -q {TEST_QUANT} {extended_args} -s {TEST_FILE} -o {output}"

# Make sure there is no line break that affects compare
env = os.environ.copy()
env["COLUMNS"] = "120"
process = subprocess.run(cmd.split(), capture_output=True, text=True)

process = subprocess.run(cmd.split(), stdout=subprocess.PIPE, text=True, stderr=subprocess.STDOUT, env=env)
assert process.returncode != 0
assert "not allowed" in process.stdout
assert "not allowed" in log.read_text() or "not allowed" in process.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
def test_error(tmp_path, filename, error):
spec = HERE / filename
output = tmp_path / "out.json"
cmd = f"vspec export json -u {TEST_UNITS} -q {TEST_QUANT} --vspec {spec} --output {output}"
log = tmp_path / "out.log"
cmd = f"vspec --log-file {log} export json -u {TEST_UNITS} -q {TEST_QUANT} --vspec {spec} --output {output}"
process = subprocess.run(cmd.split(), capture_output=True, text=True)
assert process.returncode != 0
assert error in process.stdout
assert error in log.read_text()

0 comments on commit 40c992d

Please sign in to comment.