justrun1983 saw TestPluginModelListThroughAccountProxy fail on main with "fake-not the list: http://models.invalid:80/list" among the models. The plugin tests run the bun on PATH (testenv.Bun), and Bun 1.3 names the default port in a proxy's request line: GET http://models.invalid:80/list, which Go reads as r.URL.Host "models.invalid:80", so the test's proxy answered 400 and the fake plugin took the error text as a model. Bun 1.4 sends GET http://models.invalid/list. It wasn't the offline environment: the test already clears every *_PROXY variable and reaches nothing real. magpie itself never runs plugins on a Bun older than plugin.BunVersion (1.4.2, the one it downloads and the floor CheckBun keeps), and CI pins 1.4.2, so an older bun on a developer's PATH tests something no user runs. On Bun 1.3.0 internal/plugin's TestPluginSOCKSProxy ("vendor vendor.invalid:80"), TestPluginProxy (the proxy saw http://vendor.invalid:80/...) and TestPluginHTTP2TakesTheProxy (Bun 1.3's node:http2 answers status 0, and the host quits) failed the same way. testenv.Bun now runs `bun --version` once (it already ran it to warm the binary) and skips with a message naming the bun when it is older than testenv.MinBun. testenv can't import internal/plugin (whose own tests use it), so MinBun is a copy, and TestMinBunIsBunVersion fails when it and plugin.BunVersion differ; BunVersion's comment names it and test.yml's bun-version. Run (bun 1.3.0 from npm's @oven/bun-darwin-aarch64 first on PATH, temp HOME): - before: gateway TestPluginModelListThroughAccountProxy FAIL with the reporter's exact text; plugin TestPluginSOCKSProxy, TestPluginProxy, TestPluginHTTP2TakesTheProxy FAIL. - after: all skipped, packages ok. A probe of the request line a proxy receives: 1.3.0 sends http://models.invalid:80/list, 1.4.2 and 1.4.3 http://models.invalid/list. TestBunOlderThanMinSkips (fake bun printing 1.3.0, 1.4.1, 0.9.9, 1.4.2, 1.4.3-canary, 1.10.0, 2.0.0, nothing) goes red with the skip removed by hand. With bun 1.4.2: go test -tags nogui ./internal/testenv, ./internal/plugin, ./internal/gateway pass; gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet -tags nogui on testenv and plugin pass. Not run: the full ./... suite, nor the fake-bun test on Windows (it skips there: the fake is a shell script).
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package testenv
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
"testing"
|
|
)
|
|
|
|
// A bun on PATH older than the oldest magpie runs plugins on skips the
|
|
// test that asked for it, rather than failing it on Bun's own
|
|
// differences (#1600: Bun 1.3 put :80 in a proxy's request line); MinBun
|
|
// itself and newer ones, a canary among them, run it.
|
|
func TestBunOlderThanMinSkips(t *testing.T) {
|
|
if runtime.GOOS == "windows" {
|
|
t.Skip("the fake bun is a shell script")
|
|
}
|
|
for _, c := range []struct {
|
|
version string
|
|
skips bool
|
|
}{
|
|
{"1.3.0", true},
|
|
{"1.4.1", true},
|
|
{"0.9.9", true},
|
|
{MinBun, false},
|
|
{"1.4.3-canary.20261010.1", false},
|
|
{"1.10.0", false},
|
|
{"2.0.0", false},
|
|
{"", false}, // said no version: unknown, so it runs
|
|
} {
|
|
dir := t.TempDir()
|
|
if err := os.WriteFile(filepath.Join(dir, "bun"), []byte("#!/bin/sh\necho '"+c.version+"'\n"), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Setenv("PATH", dir)
|
|
var got string
|
|
if !t.Run(c.version, func(t *testing.T) { got = Bun(t) }) {
|
|
t.Fatalf("bun %q failed the test", c.version)
|
|
}
|
|
if skipped := got == ""; skipped != c.skips {
|
|
t.Errorf("bun %q: skipped %v, want %v", c.version, skipped, c.skips)
|
|
}
|
|
}
|
|
}
|