| ... | @@ -186,58 +186,60 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsService.layerTest()))( | ... | @@ -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", () => | 189 | it.effect.skipIf(process.platform === "win32")( |
| 190 | Effect.gen(function* () { | 190 | "inherits PATH when launching the codex probe with a CODEX_HOME override", |
| 191 | const fileSystem = yield* FileSystem.FileSystem; | 191 | () => |
| 192 | const path = yield* Path.Path; | 192 | Effect.gen(function* () { |
| 193 | const binDir = yield* fileSystem.makeTempDirectoryScoped({ | 193 | const fileSystem = yield* FileSystem.FileSystem; |
| 194 | prefix: "t3-test-codex-bin-", | 194 | const path = yield* Path.Path; |
| 195 | }); | 195 | const binDir = yield* fileSystem.makeTempDirectoryScoped({ |
| 196 | const codexPath = path.join(binDir, "codex"); | 196 | prefix: "t3-test-codex-bin-", |
| 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 | }, | | |
| 228 | }); | 197 | }); |
| 229 | | 198 | const codexPath = path.join(binDir, "codex"); |
| 230 | const status = yield* checkCodexProviderStatus().pipe( | 199 | yield* fileSystem.writeFileString( |
| 231 | Effect.provide(serverSettingsLayer), | 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"); | 216 | yield* fileSystem.chmod(codexPath, 0o755); |
| 234 | assert.strictEqual(status.installed, true); | 217 | const customCodexHome = yield* fileSystem.makeTempDirectoryScoped({ |
| 235 | assert.strictEqual(status.status, "ready"); | 218 | prefix: "t3-test-codex-home-", |
| 236 | assert.strictEqual(status.authStatus, "authenticated"); | 219 | }); |
| 237 | } finally { | 220 | const previousPath = process.env.PATH; |
| 238 | process.env.PATH = previousPath; | 221 | process.env.PATH = binDir; |
| 239 | } | 222 | |
| 240 | }), | 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 | it.effect("returns unavailable when codex is missing", () => | 245 | it.effect("returns unavailable when codex is missing", () => |