Harden CLI paths and coupling export checks
This commit is contained in:
@@ -72,14 +72,30 @@ def main() -> int:
|
||||
):
|
||||
require_field(inspect.stdout, field)
|
||||
inspect_fields = read_fields(inspect.stdout)
|
||||
if inspect_fields["version"] != "0.2.1":
|
||||
raise AssertionError("inspect version field mismatch")
|
||||
if Path(inspect_fields["input"]) != Path(model):
|
||||
raise AssertionError("inspect input field mismatch")
|
||||
if inspect_fields["mode"] != "inspect":
|
||||
raise AssertionError("inspect mode not reported")
|
||||
if int(inspect_fields["particles"]) != 4:
|
||||
raise AssertionError("CLI particle count mismatch")
|
||||
if int(inspect_fields["warnings"]) != 0:
|
||||
raise AssertionError("CLI warning count mismatch")
|
||||
if abs(float(inspect_fields["time"])) > 1.0e-15:
|
||||
raise AssertionError("inspect time should be zero")
|
||||
if int(inspect_fields["step"]) != 0:
|
||||
raise AssertionError("inspect step should be zero")
|
||||
if int(inspect_fields["water_particles"]) != 4:
|
||||
raise AssertionError("CLI water particle count mismatch")
|
||||
if float(inspect_fields["water_mass"]) <= 0.0:
|
||||
raise AssertionError("CLI water mass mismatch")
|
||||
if float(inspect_fields["max_pressure"]) < 0.0:
|
||||
raise AssertionError("CLI max pressure mismatch")
|
||||
if float(inspect_fields["dtcrit"]) <= 0.0:
|
||||
raise AssertionError("CLI dtcrit mismatch")
|
||||
if inspect_fields["status"] != "ok":
|
||||
raise AssertionError("CLI status field mismatch")
|
||||
|
||||
check = run_command([exe, model, "--check"])
|
||||
if "mode: check" not in check.stdout:
|
||||
@@ -89,6 +105,8 @@ def main() -> int:
|
||||
run_fields = read_fields(run.stdout)
|
||||
if run_fields["mode"] != "run":
|
||||
raise AssertionError("run mode not reported")
|
||||
if float(run_fields["time"]) <= 0.0:
|
||||
raise AssertionError("run mode time did not advance")
|
||||
if int(run_fields["step"]) <= 0:
|
||||
raise AssertionError("run mode did not advance")
|
||||
output_step = int(run_fields["step"])
|
||||
@@ -105,6 +123,22 @@ def main() -> int:
|
||||
bad = run_command([exe, bad_model, "--check"], expect_ok=False)
|
||||
require_field(bad.stderr, "error_code")
|
||||
require_field(bad.stderr, "error_message")
|
||||
missing_arg = run_command([exe], expect_ok=False)
|
||||
if "usage:" not in missing_arg.stdout:
|
||||
raise AssertionError("missing input did not print usage")
|
||||
missing_file = run_command([exe, str(Path(output_dir) / "missing.inp")], expect_ok=False)
|
||||
require_field(missing_file.stderr, "error_code")
|
||||
conflict = run_command([exe, model, "--run", "--check"], expect_ok=False)
|
||||
if "usage:" not in conflict.stdout:
|
||||
raise AssertionError("conflicting modes did not print usage")
|
||||
missing_output = run_command([exe, model, "--run", "--output"], expect_ok=False)
|
||||
if "usage:" not in missing_output.stdout:
|
||||
raise AssertionError("missing output path did not print usage")
|
||||
illegal_output = run_command(
|
||||
[exe, model, "--run", "--output", str(Path(output_dir) / "missing-dir" / "nested")],
|
||||
expect_ok=False,
|
||||
)
|
||||
require_field(illegal_output.stderr, "error_code")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user