From 3884236b214f330e6cae5f5dd53ef5545e3b677c Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 7 Oct 2026 01:36:01 +0800 Subject: [PATCH] =?UTF-8?q?devin=20tests:=20the=20two=20"without=20the=20C?= =?UTF-8?q?LI"=20images=20tests=20take=20the=20devin=20CLI=20out=20of=20re?= =?UTF-8?q?ach=20themselves=20=E2=80=94=20they=20relied=20on=20no=20devin?= =?UTF-8?q?=20being=20on=20PATH,=20so=20on=20a=20machine=20with=20the=20CL?= =?UTF-8?q?I=20installed=20(~/.local/bin=20on=20PATH)=20provider.models=20?= =?UTF-8?q?took=20the=20CLI's=20path,=20returned=20full=20runtime=20models?= =?UTF-8?q?=20and=20both=20failed;=20CI=20has=20no=20CLI=20and=20stayed=20?= =?UTF-8?q?green.=20They=20now=20point=20PATH=20at=20an=20empty=20temp=20d?= =?UTF-8?q?ir=20(removed=20after)=20and=20say=20so=20if=20/usr/local/bin?= =?UTF-8?q?=20or=20/opt/homebrew/bin=20holds=20the=20CLI.=20Test-only,=20n?= =?UTF-8?q?o=20version=20bump;=20HOME=3D$(mktemp=20-d)=20bun=20test=20(676?= =?UTF-8?q?=20pass,=200=20fail)=20and=20check.mjs=20devin=20pass.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/devin/images.test.mjs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/devin/images.test.mjs b/packages/devin/images.test.mjs index 2645bec..7bcd970 100644 --- a/packages/devin/images.test.mjs +++ b/packages/devin/images.test.mjs @@ -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" } })