| ... | ... | @@ -186,58 +186,60 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsService.layerTest()))( |
| 186 | 186 | ), |
| 187 | 187 | ); |
| 188 | 188 | |
| 189 | | it.effect("inherits PATH when launching the codex probe with a CODEX_HOME override", () => |
| 190 | | Effect.gen(function* () { |
| 191 | | const fileSystem = yield* FileSystem.FileSystem; |
| 192 | | const path = yield* Path.Path; |
| 193 | | const binDir = yield* fileSystem.makeTempDirectoryScoped({ |
| 194 | | prefix: "t3-test-codex-bin-", |
| 195 | | }); |
| 196 | | const codexPath = path.join(binDir, "codex"); |
| 197 | | yield* fileSystem.writeFileString( |
| 198 | | codexPath, |
| 199 | | [ |
| 200 | | "#!/bin/sh", |
| 201 | | 'if [ "$1" = "--version" ]; then', |
| 202 | | ' echo "codex-cli 1.0.0"', |
| 203 | | " exit 0", |
| 204 | | "fi", |
| 205 | | 'if [ "$1" = "login" ] && [ "$2" = "status" ]; then', |
| 206 | | ' echo "Logged in using ChatGPT"', |
| 207 | | " exit 0", |
| 208 | | "fi", |
| 209 | | 'echo "unexpected args: $*" >&2', |
| 210 | | "exit 1", |
| 211 | | "", |
| 212 | | ].join("\n"), |
| 213 | | ); |
| 214 | | yield* fileSystem.chmod(codexPath, 0o755); |
| 215 | | const customCodexHome = yield* fileSystem.makeTempDirectoryScoped({ |
| 216 | | prefix: "t3-test-codex-home-", |
| 217 | | }); |
| 218 | | const previousPath = process.env.PATH; |
| 219 | | process.env.PATH = binDir; |
| 220 | | |
| 221 | | try { |
| 222 | | const serverSettingsLayer = ServerSettingsService.layerTest({ |
| 223 | | providers: { |
| 224 | | codex: { |
| 225 | | homePath: customCodexHome, |
| 226 | | }, |
| 227 | | }, |
| 189 | it.effect.skipIf(process.platform === "win32")( |
| 190 | "inherits PATH when launching the codex probe with a CODEX_HOME override", |
| 191 | () => |
| 192 | Effect.gen(function* () { |
| 193 | const fileSystem = yield* FileSystem.FileSystem; |
| 194 | const path = yield* Path.Path; |
| 195 | const binDir = yield* fileSystem.makeTempDirectoryScoped({ |
| 196 | prefix: "t3-test-codex-bin-", |
| 228 | 197 | }); |
| 229 | | |
| 230 | | const status = yield* checkCodexProviderStatus().pipe( |
| 231 | | Effect.provide(serverSettingsLayer), |
| 198 | const codexPath = path.join(binDir, "codex"); |
| 199 | yield* fileSystem.writeFileString( |
| 200 | codexPath, |
| 201 | [ |
| 202 | "#!/bin/sh", |
| 203 | 'if [ "$1" = "--version" ]; then', |
| 204 | ' echo "codex-cli 1.0.0"', |
| 205 | " exit 0", |
| 206 | "fi", |
| 207 | 'if [ "$1" = "login" ] && [ "$2" = "status" ]; then', |
| 208 | ' echo "Logged in using ChatGPT"', |
| 209 | " exit 0", |
| 210 | "fi", |
| 211 | 'echo "unexpected args: $*" >&2', |
| 212 | "exit 1", |
| 213 | "", |
| 214 | ].join("\n"), |
| 232 | 215 | ); |
| 233 | | assert.strictEqual(status.provider, "codex"); |
| 234 | | assert.strictEqual(status.installed, true); |
| 235 | | assert.strictEqual(status.status, "ready"); |
| 236 | | assert.strictEqual(status.authStatus, "authenticated"); |
| 237 | | } finally { |
| 238 | | process.env.PATH = previousPath; |
| 239 | | } |
| 240 | | }), |
| 216 | yield* fileSystem.chmod(codexPath, 0o755); |
| 217 | const customCodexHome = yield* fileSystem.makeTempDirectoryScoped({ |
| 218 | prefix: "t3-test-codex-home-", |
| 219 | }); |
| 220 | const previousPath = process.env.PATH; |
| 221 | process.env.PATH = binDir; |
| 222 | |
| 223 | try { |
| 224 | const serverSettingsLayer = ServerSettingsService.layerTest({ |
| 225 | providers: { |
| 226 | codex: { |
| 227 | homePath: customCodexHome, |
| 228 | }, |
| 229 | }, |
| 230 | }); |
| 231 | |
| 232 | const status = yield* checkCodexProviderStatus().pipe( |
| 233 | Effect.provide(serverSettingsLayer), |
| 234 | ); |
| 235 | assert.strictEqual(status.provider, "codex"); |
| 236 | assert.strictEqual(status.installed, true); |
| 237 | assert.strictEqual(status.status, "ready"); |
| 238 | assert.strictEqual(status.authStatus, "authenticated"); |
| 239 | } finally { |
| 240 | process.env.PATH = previousPath; |
| 241 | } |
| 242 | }), |
| 241 | 243 | ); |
| 242 | 244 | |
| 243 | 245 | it.effect("returns unavailable when codex is missing", () => |