GeezerVison is showing github.com — test: migrate plugin config fixtures · BlueBlock/opencode@d9d43d8
File treeExpand file treeCollapse file tree Open diff view settings packages/opencode/test/config
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/opencode/test/config/config.test.ts +46-69Lines changed: 46 additions & 69 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -925,49 +925,35 @@ test("installs dependencies in writable OPENCODE_CONFIG_DIR", async () => { | 925 | 925 | // core Npm.Service (via EffectFlock). Those behaviors are tested in the core | 926 | 926 | // package's npm tests, not here. | 927 | 927 |
| 928 | | -test("resolves scoped npm plugins in config", async () => { | 929 | | - await using tmp = await tmpdir({ | 930 | | - init: async (dir) => { | 931 | | - const pluginDir = path.join(dir, "node_modules", "@scope", "plugin") | 932 | | - await fs.mkdir(pluginDir, { recursive: true }) | 933 | | - | 934 | | - await Filesystem.write( | 935 | | - path.join(dir, "package.json"), | 936 | | - JSON.stringify({ name: "config-fixture", version: "1.0.0", type: "module" }, null, 2), | 937 | | - ) | 938 | | - | 939 | | - await Filesystem.write( | 940 | | - path.join(pluginDir, "package.json"), | 941 | | - JSON.stringify( | 942 | | - { | 943 | | - name: "@scope/plugin", | 944 | | - version: "1.0.0", | 945 | | - type: "module", | 946 | | - main: "./index.js", | 947 | | - }, | 948 | | - null, | 949 | | - 2, | 950 | | - ), | 951 | | - ) | 952 | | - | 953 | | - await Filesystem.write(path.join(pluginDir, "index.js"), "export default {}\n") | 954 | | - | 955 | | - await Filesystem.write( | 956 | | - path.join(dir, "opencode.json"), | 957 | | - JSON.stringify({ $schema: "https://opencode.ai/config.json", plugin: ["@scope/plugin"] }, null, 2), | 958 | | - ) | 959 | | - }, | 960 | | - }) | | 928 | +it.instance("resolves scoped npm plugins in config", () => | | 929 | + Effect.gen(function* () { | | 930 | + const test = yield* TestInstance | | 931 | + const pluginDir = path.join(test.directory, "node_modules", "@scope", "plugin") | | 932 | + yield* mkdirEffect(pluginDir) | | 933 | + yield* writeTextEffect( | | 934 | + path.join(test.directory, "package.json"), | | 935 | + JSON.stringify({ name: "config-fixture", version: "1.0.0", type: "module" }, null, 2), | | 936 | + ) | | 937 | + yield* writeTextEffect( | | 938 | + path.join(pluginDir, "package.json"), | | 939 | + JSON.stringify( | | 940 | + { | | 941 | + name: "@scope/plugin", | | 942 | + version: "1.0.0", | | 943 | + type: "module", | | 944 | + main: "./index.js", | | 945 | + }, | | 946 | + null, | | 947 | + 2, | | 948 | + ), | | 949 | + ) | | 950 | + yield* writeTextEffect(path.join(pluginDir, "index.js"), "export default {}\n") | | 951 | + yield* writeConfigEffect(test.directory, { plugin: ["@scope/plugin"] }) | 961 | 952 |
| 962 | | - await provideTestInstance({ | 963 | | - directory: tmp.path, | 964 | | - fn: async (ctx) => { | 965 | | - const config = await load(ctx) | 966 | | - const pluginEntries = config.plugin ?? [] | 967 | | - expect(pluginEntries).toContain("@scope/plugin") | 968 | | - }, | 969 | | - }) | 970 | | -}) | | 953 | + const config = yield* Config.Service.use((svc) => svc.get()) | | 954 | + expect(config.plugin ?? []).toContain("@scope/plugin") | | 955 | + }), | | 956 | +) | 971 | 957 |
| 972 | 958 | test("merges plugin arrays from global and local configs", async () => { | 973 | 959 | await using tmp = await tmpdir({ | @@ -1015,37 +1001,28 @@ test("merges plugin arrays from global and local configs", async () => { | 1015 | 1001 | }) | 1016 | 1002 | }) | 1017 | 1003 |
| 1018 | | -test("does not error when only custom agent is a subagent", async () => { | 1019 | | - await using tmp = await tmpdir({ | 1020 | | - init: async (dir) => { | 1021 | | - const opencodeDir = path.join(dir, ".opencode") | 1022 | | - await fs.mkdir(opencodeDir, { recursive: true }) | 1023 | | - const agentDir = path.join(opencodeDir, "agent") | 1024 | | - await fs.mkdir(agentDir, { recursive: true }) | 1025 | | - | 1026 | | - await Filesystem.write( | 1027 | | - path.join(agentDir, "helper.md"), | 1028 | | - `--- | | 1004 | +it.instance("does not error when only custom agent is a subagent", () => | | 1005 | + Effect.gen(function* () { | | 1006 | + const test = yield* TestInstance | | 1007 | + yield* mkdirEffect(path.join(test.directory, ".opencode", "agent")) | | 1008 | + yield* writeTextEffect( | | 1009 | + path.join(test.directory, ".opencode", "agent", "helper.md"), | | 1010 | + `--- | 1029 | 1011 | model: test/model | 1030 | 1012 | mode: subagent | 1031 | 1013 | --- | 1032 | 1014 | Helper subagent prompt`, | 1033 | | - ) | 1034 | | - }, | 1035 | | - }) | 1036 | | - await withTestInstance({ | 1037 | | - directory: tmp.path, | 1038 | | - fn: async (ctx) => { | 1039 | | - const config = await load(ctx) | 1040 | | - expect(config.agent?.["helper"]).toMatchObject({ | 1041 | | - name: "helper", | 1042 | | - model: "test/model", | 1043 | | - mode: "subagent", | 1044 | | - prompt: "Helper subagent prompt", | 1045 | | - }) | 1046 | | - }, | 1047 | | - }) | 1048 | | -}) | | 1015 | + ) | | 1016 | + | | 1017 | + const config = yield* Config.Service.use((svc) => svc.get()) | | 1018 | + expect(config.agent?.["helper"]).toMatchObject({ | | 1019 | + name: "helper", | | 1020 | + model: "test/model", | | 1021 | + mode: "subagent", | | 1022 | + prompt: "Helper subagent prompt", | | 1023 | + }) | | 1024 | + }), | | 1025 | +) | 1049 | 1026 |
| 1050 | 1027 | test("merges instructions arrays from global and local configs", async () => { | 1051 | 1028 | await using tmp = await tmpdir({ | |
Collapse file Copy file name to clipboardExpand all lines: perf/test-suite.md +1Lines changed: 1 addition & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -79,6 +79,7 @@ Repeated setup work, long sleeps/timeouts, serial integration tests, filesystem/ | 79 | 79 | | Legacy tools and permission-order config cases can use Effect-aware instance fixtures | Migrated legacy `tools` migration and permission order cases to `it.instance` | 1.87s | 1.87s | keep | Neutral timing; removes more manual temp-instance plumbing from legacy config migration coverage. | | 80 | 80 | | Remaining simple config load cases can use Effect-aware instance fixtures | Migrated default config load and legacy TUI-key cases to `it.instance` | 7.78s | 6.39s | keep | Single baseline before edit; after median from three sequential reruns (5.76, 6.39, 6.53). Keep as cleanup with cautious timing. | | 81 | 81 | | Managed settings config cases can use Effect-aware instance fixtures | Migrated managed override and missing-managed-file cases to `it.instance` | 2.40s | 1.76s | keep | Single baseline before edit; after median from three sequential reruns (1.75, 1.76, 1.80). | | | 82 | +| Local plugin and subagent config fixtures can use Effect-aware instance fixtures | Migrated scoped npm plugin and custom subagent markdown cases to `it.instance` | 2.37s | 1.67s | keep | Single baseline before edit; after median from three sequential reruns (1.66, 1.67, 1.67). | | 82 | 83 |
| 83 | 84 | ## Profiling Results | 84 | 85 |
| |
|