Repository navigation
test(hostlock): run the advice we print, instead of reading a prefix of it - #2289
Open
justinchuby wants to merge 2 commits into
Open
justinchuby wants to merge 2 commits into
justinchuby wants to merge 2 commits into
Conversation
…of it Both places that tell someone how to take the lock are checked by asserting `"hostlock.sh run --owner"` appears somewhere -- a prefix that the accepted form and the form #1926 refuses both satisfy. So the advice can drift into a command that exits 1 with every test still green, and the reader is the person about to publish numbers: the one we most want to succeed. Measured on 0e6d01d, not argued. Stripping `--reason` from `Report::warning` leaves the whole `onnx-runtime-hostmon` suite green (29/11/31/1/2 all ok), and stripping it from `hostlock_gate.remedy` leaves `test_the_remedy_points_at_the_outer_wrapper` green. Neither guard can fire on the defect it names -- the Python one's own comment states the property exactly ("refusing is only useful if what it prints is the thing that would have worked") and then tests something weaker. Both new tests extract the command from the real advice, fill its placeholders, and run it through a shell from the repository root, which is what the reader does -- so they also pin the relative path the message quotes. Each requires exactly one command before running anything, because a reword that dropped the command would otherwise leave nothing to run and reach the result line as a pass. Both strip HOSTLOCK_REASON and HOSTLOCK_OWNER from the child, since the script accepts either as a substitute for the flag and an inherited value would let advice that had lost the flag still exit 0. Mutation-proved in both directions. Rust: drop-reason FAILED, no-command FAILED, stale-path FAILED, drop-owner ok -- the last is a true negative, `--owner` is genuinely optional (verified: `hostlock.sh run --reason X -- true` exits 0). Python, same mutant side by side: the new test FAILED, the existing prefix assertion OK. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2289 +/- ##
==========================================
- Coverage 81.19% 80.76% -0.44%
==========================================
Files 434 434
Lines 222250 222250
Branches 222250 222250
==========================================
- Hits 180452 179494 -958
- Misses 35869 36826 +957
- Partials 5929 5930 +1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
main moved 9 commits, including +365 lines in scripts/ort_ab/test_gate_conformance.py and a change to .github/workflows/hostlock.yml -- the lane that produced this PR's Host lock conformance green. Re-measure against the tree that would actually land.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Holden flagged (#1926 thread) that
Report::warningtells a benchmarker to runscripts/hostlock.sh run, which #1926 made exit 1 without--reason— advice aimed at exactly the person we most want to succeed, telling them to run something the tool refuses.His diagnosis is right and his reading of current
mainis stale.--reasonentered that string in #1926 itself (23af6afbc,git log -S), and the advice runs clean today:What is real is that nothing holds it that way. Both advice sites are checked by asserting the substring
"hostlock.sh run --owner"— a prefix that the accepted form and the refused form both satisfy.The measurement
On
0e6d01d39. Stripping--reasonfromReport::warning:The whole crate stays green while the advice has become a refused command. The advice text is referenced by no file but
window.rsitself — positive control run first, so the zero means absence rather than a dead grep.The Python side is the sharper instance, because the existing test states the correct property in its own comment and then tests something weaker:
Same mutant, the two tests side by side:
--reasonfromremedy()The change
Two tests, no production code. Each pulls the command out of the real advice —
Report::warning()'s return value andhostlock_gate.remedy()'s return value, not a copy and not the file's source text — fills its placeholders, and runs it through a shell from the repository root, which is what the reader of the message does. That also pins the relative path the message quotes.Three details that are load-bearing:
<you>.HOSTLOCK_REASONandHOSTLOCK_OWNERare stripped from the child. The script accepts both as substitutes for the flags, so an inherited value would let advice that had lost a flag still exit 0 — the test would pass on the strength of this process's environment rather than of the string under test.Neither test touches the shared lock:
HOSTLOCK_DIRis redirected to scratch (CARGO_TARGET_TMPDIR/target/tmp, removed after), withHOSTLOCK_PRIVATE_OK=1as the suite already does.Mutation battery, both directions
--reasonscripts/→tools/--ownerThe last is a true negative, not a gap:
--owneris genuinely optional, verified rather than assumed —hostlock.sh run --reason X -- trueexits 0 and derives the owner from$USER. That mutant is still a command the script accepts, which is what this test claims to check.Gates
cargo fmt --checkclean ·cargo clippy -p onnx-runtime-hostmon --all-targets -- -D warningsexit 0 ·cargo test -p onnx-runtime-hostmon12/12 in theagrees_with_hostlock_shbinary (was 11), 0 ignored ·python3 -m unittest scripts.ort_ab.test_gate_conformance123 tests OK (was 122).onnx-runtime-hostmonis inoffline-linux,offline-cross-platformandlint, so these run — checked withworkspace_test_packages.py cargo-args, after my first attempt at that query returnedhostmon=0for every lane because I passed--laneto a positional argument and was counting a usage error. Second dead instrument this session; the control caught both.Limit
This pins two advice strings to the script's exit status. It does not check that the advice is the right advice — a remedy that suggested a valid command which locked the wrong scope would pass. That property is what
test_the_remedy_points_at_the_outer_wrapperis for, and it stays.Reported by Holden. Related: #1926, #1817.