devin tests: the two "without the CLI" images tests take the devin CLI out of reach themselves — they relied on no devin being on PATH, so on a machine with the CLI installed (~/.local/bin on PATH) provider.models took the CLI's path, returned full runtime models and both failed; CI has no CLI and stayed green. They now point PATH at an empty temp dir (removed after) and say so if /usr/local/bin or /opt/homebrew/bin holds the CLI. Test-only, no version bump; HOME=$(mktemp -d) bun test (676 pass, 0 fail) and check.mjs devin pass.

This commit is contained in:
yetone
2026-10-07 01:36:01 +08:00
parent bf01ffc4d9
commit 3884236b21
+16 -3
View File
@@ -3,13 +3,17 @@
// swe-2 was said to take none, models.dev not knowing Devin's own ids, and
// agents dropped its images (面条 on magpie's Discord).
import { afterEach, expect, test } from "bun:test"
import { realpathSync } from "node:fs"
import { existsSync, mkdtempSync, realpathSync, rmSync } from "node:fs"
import { join } from "node:path"
import { homedir, tmpdir } from "node:os"
import { DevinAuthPlugin, _internal } from "./index.mjs"
const real = globalThis.fetch
const path = process.env.PATH
afterEach(() => {
globalThis.fetch = real
if (process.env.PATH !== path) rmSync(process.env.PATH, { recursive: true, force: true })
process.env.PATH = path
_internal.forgetSaid()
})
@@ -19,6 +23,15 @@ const sandboxed = () => {
if (![tmpdir(), realpathSync(tmpdir())].some((t) => homedir().startsWith(t))) throw new Error("run with HOME=$(mktemp -d) bun test")
}
// withoutCli takes the devin CLI out of reach: the plugin finds it on PATH
// (and in ~/.local/bin, which the sandboxed HOME leaves empty), so a machine
// with the CLI installed would otherwise take the CLI's path
const withoutCli = () => {
sandboxed()
process.env.PATH = mkdtempSync(join(tmpdir(), "no-devin-"))
for (const p of ["/usr/local/bin/devin", "/opt/homebrew/bin/devin"]) if (existsSync(p)) throw new Error(p + " is the devin CLI: these tests need a machine without it there")
}
// configs is a GetCliModelConfigsResponse naming each id, with
// supports_images set where it is true (proto3 leaves a false one out)
const configs = (said) => {
@@ -62,7 +75,7 @@ test("a family takes images when every variant Devin named says so, a variant as
})
test("an account's list without the CLI takes what Devin says of images now", async () => {
sandboxed()
withoutCli()
const asked = []
globalThis.fetch = async (url, init) => {
asked.push({ url: String(url), headers: init.headers, body: new Uint8Array(init.body) })
@@ -89,7 +102,7 @@ test("an account's list without the CLI takes what Devin says of images now", as
})
test("when Devin can't be asked, the list takes the snapshot's word", async () => {
sandboxed()
withoutCli()
globalThis.fetch = async () => new Response("", { status: 503 })
const given = { "swe-2": { id: "swe-2", capabilities: { attachment: false, input: { text: true, image: false } } } }
const got = await (await DevinAuthPlugin()).provider.models({ models: given }, { auth: { type: "api", key: "devin-key" } })