test(shell-completion): stabilize flaky zpty zsh completion tests#436
Open
dqn wants to merge 2 commits into
Open
test(shell-completion): stabilize flaky zpty zsh completion tests#436dqn wants to merge 2 commits into
dqn wants to merge 2 commits into
Conversation
The zpty-based zsh interactive completion tests were intermittently failing (~10-20%) with `NMATCHES:-1`. Root cause was a TAB-vs-ZLE race in the test harness: TAB was sent before zsh's line editor finished consuming the command, so it was inserted as a literal character instead of triggering completion. Changes: - Wait for the command echo from zpty before sending TAB, plus a 0.1s ZLE settle delay - Use the correct lowercase `compprefuncs` array (the camelCase `comppreFuncs` is not a real zsh hook and was silently inactive) - Add a `_test_pre` / `_test_cap` split using `compprefuncs` and `comppostfuncs` so diagnostics distinguish "TAB never triggered completion" (test infra race) from "completion ran but produced no matches" (potential politty bug) Verified 20/20 consecutive zpty suite runs pass.
commit: |
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.
Summary
The zpty-based zsh interactive completion tests were intermittently
failing (~10–20%) with
NMATCHES:-1. Root cause: a TAB-vs-ZLE race inthe test harness — TAB was sent before zsh's line editor finished
consuming the command, so it was inserted as a literal character instead
of triggering completion. Waiting for the command to be echoed back
(i.e. ZLE ingested the input) and letting ZLE settle before sending TAB
removes the race; no timeout extensions or retry logic were needed.
Main changes
ZLE settle delay
compprefuncsarray; the previously usedcamelCase
comppreFuncsis not a real zsh hook, so the pre-hook wassilently inactive
_test_pre/_test_capsplit usingcompprefuncsandcomppostfuncsso diagnostics distinguish "TAB never triggeredcompletion" (test infra race) from "completion ran but produced no
matches" (potential politty bug)
Verification
npm test(1290 tests) greenNotes
zsh.test.tsis an automaticreorder by lefthook's
organize-imports-clipre-commit hook. The hookonly touches staged files, so older files drift out of sync until they
are next edited — unrelated to the stabilization itself.
Code Metrics Report
Details
Reported by octocov