Repository navigation
test(core): add config and watcher test services - #39157
Merged
Merged
Conversation
This was referenced Jul 27, 2026
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
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.
What
First-class test services for
ConfigandWatcher, replacing 25 ad-hocConfig.Service.ofstubs and 3 hand-rolledWatcherPubSub stubs across core and simulation. Third slice of the config source reload series (#38983, #39131); the upcoming command/agent/plugin source-reload PRs consume these fixtures directly.Every interface addition to Config (like
changes()in #39131) previously broke every stub site — including ones outside core that local greps missed and CI caught late. Now there is exactly one implementation to update.How
Follows the First-Class App Test Stubs pattern (
TestInterface extends Interface, one object backing both the real andTesttags viaLayer.effectContext,testLayernaming):packages/core/src/config.ts—Config.TestaddssetEntries(entries)andemitChange(update);Config.testLayer(initial?)provides bothConfig.ServiceandConfig.Testfrom one Ref + PubSub instance.packages/core/src/filesystem/watcher.ts—Watcher.Testaddsemit(update)and read-onlysubscriptions()(the subscribe-call log tests already asserted by hand);Watcher.testLayerprovides both tags.packages/simulationstubs Config today).Conversion notes:
test/config/config.test.ts— itstestLayerhelper now defaults toWatcher.testLayer(previously tests without an explicit watcher silently used the native watcher) and merges the watcher layer by reference soWatcher.Testresolves to the same memoized instance inside theAppNodeBuildergraph.test/config/reload.test.tsandtest/config/policy.test.ts— mutablelet entriesclosures becomeConfig.Test.setEntries, removing the shared-mutable-variable pattern.test/tool-read.test.ts— same conversion; the module-levellet configEntries+beforeEachreset is gone, each test gets a fresh Ref and sets entries explicitly. Layer memoization shares the one Config instance with the nestedImage.nodebuild.test/config/provider.test.ts/policy.test.ts—addPluginhelpers now takeConfig.Entry[]instead of a hand-built service.Scope
Npm, Credential, and WellKnown stubs (5 files, one-off shapes) are deliberately not converted; they migrate opportunistically when a PR touches them.
Testing
Config > backs Config.Service and Config.Test with one shared test implementation,Watcher.testLayer > records subscriptions and broadcasts emitted updates through the service.PluginSupervisor config > reloads an auto-discovered plugin when its file changes) is pre-existing on clean base.bun typecheckclean in core and simulation; repo-wide pre-push typecheck passed.