pluginrt tests: TestBrokenFileIsKept is red on Windows at main bc470c6b - the test builds a directory named plugins.yml, and the Windows job compiles this suite only
internal/pluginrt — the runtime behind Plugins › Built-in (3ccbe6bc, 2026-10-13; every start now calls pluginrt.Settle/Refresh from internal/cli/main.go) — is deterministically red on Windows at main bc470c6b: go test ./internal/pluginrt/ fails in TestBrokenFileIsKept. The Windows CI job compiles this suite only (go test -run '^$' ./..., the "Compile tests" step of .github/workflows/test.yml) and the package is not among the named Windows checks, so nothing shows it. It is the first Windows red found in the plugin runtime, and any later one in the package hides behind it. The people paying for it are the Windows triage runs the project makes (#1827, "This stays open for your next Windows run") and anyone running this package on Windows; LESSONS.md already names the rule: "Windows CI only compiles the tests, so a Windows-only red shows nowhere", and "A red gets its own issue, with its output."
Not a product bug: a plugins.yml that is not a file is handled (Load errors, the page shows Broken, every switch is left alone). This is the test only.
Reproduce
At 9916a946 on Windows 11, Go 1.26.8, sandboxed home (XDG_CONFIG_HOME/TEMP under a temp folder; no change to the repo):
go test -tags nogui -count=1 -v ./internal/pluginrt/
=== RUN TestBrokenFileIsKept
config_test.go:110: open C:\...\001\magpie\plugins.yml: is a directory
--- FAIL: TestBrokenFileIsKept (0.04s)
...
FAIL github.com/yetone/magpie/internal/pluginrt 2.524s
Expected: all of the package passes, as it does on macOS/Linux. Actual: TestBrokenFileIsKept is red, deterministically, on every run.
internal/pluginrt is byte-identical at 9916a946 and at today's main bc470c6b (git diff 9916a946 bc470c6b -- internal/pluginrt is empty; the red was rerun green only with the fix below).
Cause
config_test.go:105 builds the config folder with
os.MkdirAll(strings.TrimSuffix(Path(), "/plugins.yml"), 0o700)
Path() is filepath.Join(appdir.Config(), "plugins.yml"). On Windows it ends in \plugins.yml, the "/plugins.yml" suffix never matches, so MkdirAll is handed the whole file path and creates a directory named plugins.yml where the folder should be (which is also why the message says "is a directory"). The next line's os.WriteFile(Path(), broken, 0o600) then fails. The test's only intent is to make sure the config folder is there.
Fix
filepath.Dir(Path()), the folder it meant. Branch fix/pluginrt-windows-broken-test-pv7m2k on JasonBuildAI/magpie (commit 2ec23a86, one commit on bc470c6b, +2/−1):
import (
"context"
"os"
+ "path/filepath"
"reflect"
@@
func TestBrokenFileIsKept(t *testing.T) {
home(t)
- if err := os.MkdirAll(strings.TrimSuffix(Path(), "/plugins.yml"), 0o700); err != nil {
+ if err := os.MkdirAll(filepath.Dir(Path()), 0o700); err != nil {
t.Fatal(err)
}
Raw after, same box, with the fix:
=== RUN TestBrokenFileIsKept
--- PASS: TestBrokenFileIsKept (0.01s)
...
PASS
ok github.com/yetone/magpie/internal/pluginrt 2.885s
At the rebased head 2ec23a86 (parent bc470c6b), fresh runs are green too: ok github.com/yetone/magpie/internal/pluginrt 0.852s. The 2.885s run above was taken with the fix on the byte-identical parent 9916a946 — git diff 9916a946 bc470c6b -- internal/pluginrt prints nothing.
Sibling check
strings.TrimSuffix(Path(), "/...") appears nowhere else; internal/access/limit_test.go trims a bare file name ("caller-keys.json"), which matches on Windows too, so it needs no change.
Also run on that box: every other test of the plugin runtime passes on Windows — this is its only red — and internal/gui's builtins tests (TestBuiltinClientsLoaded, TestBuiltinsTranslated) pass there as well.
What was run
gofmt -l internal/pluginrt— clean.go vet ./internal/pluginrt/(Windows),GOOS=linux go vet -tags nogui ./internal/pluginrt/,GOOS=darwin go vet ./internal/pluginrt/— clean.go test -tags nogui -count=1 ./internal/pluginrt/— red before, green after (outputs above).- Not tried: a real macOS or Linux box (Windows-only work; the change is
filepath.Dir, which is right on every OS). - Repo-wide at
2ec23a86on Windows:gofmt -l .clean;go vet ./...and the Windows CI compile step,go test -run '^$' ./..., both exit 0. The full tagged suite was not run end to end on this box.
AI disclosure: this change was drafted with AI assistance at my request, under my direction and review; I set the constraint that the evidence be a raw before/after run on the machine it fails on, and I reviewed the diff and this report before posting. The Windows runs above were made in this session on this machine.
Two corrections and additions after a separate review run (separate checkout and separate caches on this machine; AI-assisted, as the report above discloses).
Provenance. The body said the 2.885s "after" run was "at the rebased head"; it was actually taken with the fix on this branch's pre-rebase parent 9916a946. internal/pluginrt is byte-identical at 9916a946 and bc470c6b (git diff 9916a946 bc470c6b -- internal/pluginrt prints nothing), and fresh runs at the rebased head 2ec23a86 are green — ok github.com/yetone/magpie/internal/pluginrt 0.852s. "Red at main, green with the fix" holds at today's main as written; the run times differ because the runs are of identical code on different trees. The body now says "with the fix" and carries the rebased-head run.
Independent reproduction at today's main (go1.26.8 windows/amd64): at bc470c6b without the fix —
=== RUN TestBrokenFileIsKept
config_test.go:110: open ...\magpie\plugins.yml: is a directory
--- FAIL: TestBrokenFileIsKept (0.01s)
FAIL github.com/yetone/magpie/internal/pluginrt 0.900s (exit 1)
at 2ec23a86 —
--- PASS: TestBrokenFileIsKept (0.01s)
ok github.com/yetone/magpie/internal/pluginrt 1.381s (exit 0)
Every other test of the package passes on both trees.
Repo-wide at 2ec23a86 (Windows): gofmt -l . clean; go vet ./... exit 0; the step the Windows job runs to compile this suite, go test -run '^$' ./..., exits 0 for every package.
Not proposed here: adding internal/pluginrt to the named Windows checks. That belongs with the #1827 Windows-step work, not this two-line fix; the issue is only that the package's manual Windows signal is red today.
Fixed in 9c330f468, thanks @JasonBuildAI. The test now makes the folder with filepath.Dir(Path()).
On a Windows x64 box with a cross-compiled pluginrt test binary:
- old code: FAIL,
open ...\magpie\plugins.yml: is a directory; - new code: the whole package passes.
I ran it inside a copy of the source tree, since TestPluginsImportOnlyCore walks it. No other filesystem path in the repo is cut with a "/" suffix. This change is test-only, so I'm closing the issue.