What needs doing
Add a directory of shell shims for squeue, sinfo, scontrol, scancel and sacctmgr, plus a small helper that puts that directory first on PATH for the process under test. Each shim reads a scenario name from an env var, appends its argv to a log file so a test can assert what was called and how often, and then either prints a recorded fixture or fails with a chosen exit code.
Why
All 16 tests in the project are pure functions: argument building, state parsing, regex filtering, output decoding. Nothing that shells out is covered. So the failure handling v0.2.0 shipped has no regression protection, and neither does scancel, which is the one destructive operation in the tool.
Every SLURM call is a Command::new with a bare program name resolved through PATH, and none uses an absolute or configurable location, so shims need no mocking layer and no new abstraction. The call-count assertions are the valuable part and the part a mock would give you awkwardly: "scontrol fails, assert exactly one invocation rather than one per frame" and "scancel fails on the first of three batches, assert all three still went out" are each one line against a shim. The approach is already proven, the reproductions in #24, #25 and #36 were produced with shims of exactly this shape.
A recorded squeue fixture also makes Dashboard constructible in a test. Dashboard::new calls check_slurm_available before anything else, which is why the refresh throttle and the cursor and mark preservation in set_jobs have no coverage today.
Please do not reach for a trait SlurmBackend with a mock implementation instead. That is a single-implementation interface existing only for tests, it touches every call site, and it buys nothing over a shim directory.
Two things to settle while doing it. The shims must not ship in the published crate, which is the same include allowlist problem as #21, so fix both together. And the executable bit needs to survive a fresh clone, which git tracks but a zip download does not. CI needs no change, the shims are sh and every job is ubuntu.
What needs doing
Add a directory of shell shims for
squeue,sinfo,scontrol,scancelandsacctmgr, plus a small helper that puts that directory first onPATHfor the process under test. Each shim reads a scenario name from an env var, appends its argv to a log file so a test can assert what was called and how often, and then either prints a recorded fixture or fails with a chosen exit code.Why
All 16 tests in the project are pure functions: argument building, state parsing, regex filtering, output decoding. Nothing that shells out is covered. So the failure handling v0.2.0 shipped has no regression protection, and neither does
scancel, which is the one destructive operation in the tool.Every SLURM call is a
Command::newwith a bare program name resolved throughPATH, and none uses an absolute or configurable location, so shims need no mocking layer and no new abstraction. The call-count assertions are the valuable part and the part a mock would give you awkwardly: "scontrolfails, assert exactly one invocation rather than one per frame" and "scancelfails on the first of three batches, assert all three still went out" are each one line against a shim. The approach is already proven, the reproductions in #24, #25 and #36 were produced with shims of exactly this shape.A recorded
squeuefixture also makesDashboardconstructible in a test.Dashboard::newcallscheck_slurm_availablebefore anything else, which is why the refresh throttle and the cursor and mark preservation inset_jobshave no coverage today.Please do not reach for a
trait SlurmBackendwith a mock implementation instead. That is a single-implementation interface existing only for tests, it touches every call site, and it buys nothing over a shim directory.Two things to settle while doing it. The shims must not ship in the published crate, which is the same
includeallowlist problem as #21, so fix both together. And the executable bit needs to survive a fresh clone, which git tracks but a zip download does not. CI needs no change, the shims areshand every job is ubuntu.