perf: cache completion scripts in shell completion tests#166
Open
perf: cache completion scripts in shell completion tests#166
Conversation
Pre-generate completion scripts once per shell in setupTestContext() instead of spawning tsx/Node.js on every test invocation. This eliminates ~500-1500ms overhead per test call and significantly reduces total test duration and CI timeout risk.
There was a problem hiding this comment.
Pull request overview
Improves shell completion test performance by generating each shell’s completion script once per test context and reusing it across all completion helper calls and interactive completion tests, avoiding repeated Node/tsx startup.
Changes:
- Add
completionScripts(bash/zsh/fish) to the shell test context and generate scripts duringsetupTestContext()/setupNestedTestContext(). - Update bash/zsh/fish completion helpers to optionally
sourcea cached script file viascriptPathinstead of runningeval "$(app completion ...)"each time. - Update interactive completion tests (bash/expect, zsh/zpty, fish/complete --do-complete) to source cached scripts.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/shell-completion/helpers.ts | Generates and stores cached completion scripts; adds scriptPath support to completion helpers. |
| tests/shell-completion/bash.test.ts | Uses cached bash completion script for raw and interactive completion tests. |
| tests/shell-completion/zsh.test.ts | Uses cached zsh completion script for raw and zpty-based interactive completion tests. |
| tests/shell-completion/fish.test.ts | Uses cached fish completion script for raw and complete --do-complete interactive tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
setupTestContext()/setupNestedTestContext()instead of spawning tsx/Node.js on every test invocation*Complete()helper now accepts an optionalscriptPathto source from file instead of runningeval "$(app completion shell)"This eliminates ~500-1500ms tsx/Node.js startup overhead per test call, reducing fish tests from ~44s to ~6s, zsh from ~94s to ~37s, and bash from ~121s to ~64s. Fixes intermittent CI timeouts in shell completion tests.
Code Metrics Report
Details
| | main (3bebf51) | #166 (3953751) | +/- | |---------------------|----------------|----------------|------| | Coverage | 88.6% | 88.6% | 0.0% | | Files | 41 | 41 | 0 | | Lines | 3164 | 3164 | 0 | | Covered | 2804 | 2804 | 0 | + | Test Execution Time | 50s | 42s | -8s |Reported by octocov