sincekit / tests /test_cli.py
pgg-engineering's picture
Release SinceKit 0.1.0 with native benchmarks and trace replay
ef8334d verified
Raw History Blame Contribute Delete
1.02 kB
"""Check the installed command protocol and its nonzero error exits."""
import json
import subprocess
import sys
cli = sys.argv[1]
def run(text, capacity="16"):
return subprocess.run([cli, capacity], input=text, text=True, capture_output=True)
result = run("touch 7\ntouch 3\ntouch 7\nerase 3\nplan 0 2 3 4\nplan\nrevision\n")
assert result.returncode == 0, result.stderr
batch, empty, revision = map(json.loads, result.stdout.splitlines())
assert batch == {"revision": "4", "rows": [[3, "4", True], [7, "3", False]],
"prefix_lengths": [2, 2, 1, 0]}
assert empty == {"revision": "4", "rows": [], "prefix_lengths": []}
assert revision == {"revision": "4"}
for text in ["touch -1", "erase 16", "touch 4294967296", "touch 1 2",
"plan 1", "revision extra", "erase", "hello"]:
failure = run(text)
assert failure.returncode and "line 1" in failure.stderr, (text, failure)
assert run("plan 0", "0").returncode == 0
assert run("", "1x").returncode
print("CLI checks passed")