Repository navigation
test(plugins): isolate plugin dir per test process - #15296
Merged
diegosouzapw merged 2 commits intoOct 6, 2026
Merged
diegosouzapw merged 2 commits into
diegosouzapw merged 2 commits into
Conversation
tests/_setup/isolateDataDir.ts gave every test process a fresh DATA_DIR but left the plugin directory alone. getDefaultPluginDir() (src/lib/plugins/scanner.ts) reads OMNIROUTE_PLUGINS_DIR, else $HOME/.omniroute/plugins, so every chat-pipeline test scanned, and could load, the developer's real plugins, and plugins-fs-safety installed into and deleted from that real directory. CI runners have a clean HOME, so CI never saw it. - isolateDataDir.ts: default OMNIROUTE_PLUGINS_DIR to $DATA_DIR/plugins unless the caller already set it. A blank or whitespace-only value counts as unset, matching the scanner's own trim; a plain ||= keeps " ", and the scanner then falls back to HOME. - plugins-fs-safety.test.ts: pin OMNIROUTE_PLUGINS_DIR under the file's own temp DATA_DIR before the manager singleton resolves it, so installs, the between-test cleanup (which re-derived the root from HOME), and the three staging-residue assertions (which inspected $TEST_DATA_DIR/plugins, a directory the manager never wrote to) share one root. - isolate-datadir.test.ts: spawn a child that loads the setup and assert getDefaultPluginDir() resolves to $DATA_DIR/plugins for unset, blank, and whitespace-only values, and that an explicit value is kept.
diegosouzapw
merged commit Oct 6, 2026
a46b309
into
diegosouzapw:release/v3.8.52
44 of 51 checks passed
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
tests/_setup/isolateDataDir.tsnow pointsOMNIROUTE_PLUGINS_DIRat$DATA_DIR/pluginsin every test process. The plugin scanner stops reading the developer's real~/.omniroute/pluginsduring local test runs, and the chat pipeline stops loading plugins from it.Why
getDefaultPluginDir()(src/lib/plugins/scanner.ts:46-57) returnsOMNIROUTE_PLUGINS_DIR, else$HOME/.omniroute/plugins. The setup isolatedDATA_DIRand left the plugin dir on theHOMEdefault.tests/unitfiles that usetests/integration/_chatPipelineHarness.ts) scanned the real plugin dir. A request-mutating plugin installed locally could turn them red, and its code ran inside the test processes.tests/unit/plugins-fs-safety.test.tsinstalled plugins into, and deleted them from, that same real directory.HOME, so CI never hit this.Changes
tests/_setup/isolateDataDir.ts: after theDATA_DIRblock, defaultOMNIROUTE_PLUGINS_DIRto$DATA_DIR/plugins. A value the caller already set still wins..trim().||=would keep" ", and the scanner would then fall back toHOME(the red run below shows this).tests/unit/plugins-fs-safety.test.ts: pinsOMNIROUTE_PLUGINS_DIRunder the file's own tempDATA_DIRbefore the manager singleton resolves its install root.HOME.$TEST_DATA_DIR/plugins, a directory the manager never wrote to, so theirexistsSyncguard skipped them every time. They now inspect the real install root.tests/unit/isolate-datadir.test.ts: adds child-process cases, in the same pattern as the existingDATA_DIRcases.getDefaultPluginDir()resolves to$DATA_DIR/pluginswhen the value is unset, blank, or whitespace-only.The resulting layout matches production, where
DATA_DIRdefaults to~/.omnirouteand the plugin dir to~/.omniroute/plugins.Validation (TDD)
Every run used the package.json import chain:
node --import tsx/esm --import ./open-sse/utils/setupPolyfill.ts --import ./tests/_setup/isolateDataDir.ts --test --test-force-exit <files>tests/unit/isolate-datadir.test.ts~/.omniroute/pluginsin place of$DATA_DIR/plugins||=" "case fell back to~/.omniroute/pluginsplugins-fs-safetyandplugins-scanner: 30/30 pass.tests/integration/plugins-lifecycle.test.ts: 17/17 pass.APP_LOG_LEVEL=info: 507/507 pass.OMNIROUTE_PLUGINS_DIRthemselves, and all 28 harness-based unit files.scanner.dir_resolvedline in that run points at a temp directory or at one ofplugins-scanner's fixed fixture values. None points at the real home plugin dir.eslintwithconfig/quality/eslint-suppressions.json, andprettier --check: clean on the three changed files.