GeezerVison is showing github.com — test(opencode): retry Windows CLI cleanup · soequelle/opencode@9b01f15
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/opencode/test/lib/cli-process.ts +8-4Lines changed: 8 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 20 | 20 | import { test, type TestOptions } from "bun:test" | 21 | 21 | import { FSUtil } from "@opencode-ai/core/fs-util" | 22 | 22 | import { AppProcess } from "@opencode-ai/core/process" | 23 | | -import { Deferred, Duration, Effect, Layer, Queue, Scope, Stream } from "effect" | | 23 | +import { Deferred, Duration, Effect, Layer, Queue, Schedule, Scope, Stream } from "effect" | 24 | 24 | import { FetchHttpClient, HttpClient } from "effect/unstable/http" | 25 | 25 | import { ChildProcess } from "effect/unstable/process" | 26 | 26 | import path from "node:path" | @@ -192,9 +192,13 @@ export function withCliFixture<A, E>( | 192 | 192 | const fs = yield* FSUtil.Service | 193 | 193 | const appProc = yield* AppProcess.Service | 194 | 194 |
| 195 | | - // FileSystem.makeTempDirectoryScoped handles both creation and scope-tied | 196 | | - // cleanup — replaces the old mkdir + addFinalizer pair. | 197 | | - const home = yield* fs.makeTempDirectoryScoped({ prefix: "oc-cli-" }) | | 195 | + const home = yield* fs.makeTempDirectory({ prefix: "oc-cli-" }) | | 196 | + yield* Effect.addFinalizer(() => | | 197 | + fs.remove(home, { recursive: true }).pipe( | | 198 | + Effect.retry(Schedule.spaced("50 millis").pipe(Schedule.both(Schedule.recurs(20)))), | | 199 | + Effect.ignore, | | 200 | + ), | | 201 | + ) | 198 | 202 |
| 199 | 203 | const configJson = JSON.stringify(testProviderConfig(llm.url)) | 200 | 204 | const env = isolatedEnv(home, configJson) | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/test/server/httpapi-sdk.test.ts +7-2Lines changed: 7 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -22,7 +22,7 @@ import { TestLLMServer } from "../lib/llm-server" | 22 | 22 | import path from "path" | 23 | 23 | import { resetDatabase } from "../fixture/db" | 24 | 24 | import { disposeAllInstances, TestInstance, tmpdirScoped } from "../fixture/fixture" | 25 | | -import { awaitWithTimeout, testEffect } from "../lib/effect" | | 25 | +import { awaitWithTimeout, pollWithTimeout, testEffect } from "../lib/effect" | 26 | 26 | import { testProviderConfig } from "../lib/test-provider" | 27 | 27 | import { ProviderV2 } from "@opencode-ai/core/provider" | 28 | 28 | import { ModelV2 } from "@opencode-ai/core/model" | @@ -389,7 +389,12 @@ describe("HttpApi SDK", () => { | 389 | 389 | workspaceID, | 390 | 390 | onRequest: (value) => (request = value), | 391 | 391 | }) | 392 | | - const found = yield* call(() => sdk.v2.fs.find({ query: "hello", type: "file" })) | | 392 | + const found = yield* pollWithTimeout( | | 393 | + call(() => sdk.v2.fs.find({ query: "hello", type: "file" })).pipe( | | 394 | + Effect.map((result) => (result.data?.data.length ? result : undefined)), | | 395 | + ), | | 396 | + "SDK file search index was not ready", | | 397 | + ) | 393 | 398 | const url = new URL(request!.url) | 394 | 399 |
| 395 | 400 | expect(found.response.status).toBe(200) | |
|