Skip to content

Commit

Permalink
Update after review
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Jaegervall <[email protected]>
  • Loading branch information
erikbosch committed Oct 25, 2024
1 parent 8fdfd70 commit e54be57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
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 / "log.txt"
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() or error in process.stderr
16 changes: 7 additions & 9 deletions tests/vspec/test_structs/test_data_type_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,18 +364,17 @@ def test_error_default_for_struct(tmp_path, file):
vspec = HERE / file
types_file = HERE / "VehicleDataTypes.vspec"
out = tmp_path / "out.json"
log = tmp_path / "log.txt"
cmd = (
f"vspec export json -u {TEST_UNITS} -q {TEST_QUANT} --pretty --vspec {vspec} "
f"vspec --log-file {log} export json -u {TEST_UNITS} -q {TEST_QUANT} --pretty --vspec {vspec} "
f"--output {out} --types {types_file}"
)
env = os.environ.copy()
env["COLUMNS"] = "200"
process = subprocess.run(cmd.split(), capture_output=True, text=True, env=env)
process = subprocess.run(cmd.split(), capture_output=True, text=True)
assert process.returncode != 0

# Only checking first of type name to be able to handle both test cases
error_msg = "Default values not allowed for user defined type 'VehicleDataTypes.TestBranch1.ParentStruct"
assert error_msg in process.stdout
assert error_msg in log.read_text() or error_msg in process.stderr


def test_error_default_for_struct_array_empty(tmp_path):
Expand All @@ -385,11 +384,10 @@ def test_error_default_for_struct_array_empty(tmp_path):
vspec = HERE / "test_struct_default_array_empty.vspec"
types_file = HERE / "VehicleDataTypes.vspec"
out = tmp_path / "out.json"
log = tmp_path / "log.txt"
cmd = (
f"vspec export json -u {TEST_UNITS} -q {TEST_QUANT} --pretty --vspec {vspec} "
f"vspec --log-file {log} export json -u {TEST_UNITS} -q {TEST_QUANT} --pretty --vspec {vspec} "
+ f"--output {out} --types {types_file}"
)
env = os.environ.copy()
env["COLUMNS"] = "200"
process = subprocess.run(cmd.split(), capture_output=True, text=True, env=env)
process = subprocess.run(cmd.split(), capture_output=True, text=True)
assert process.returncode == 0

0 comments on commit e54be57

Please sign in to comment.