Skip to content

Make the test suite compile for Windows, and vet every release GOOS (#925) - #941

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/925
Oct 15, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/925

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #925.

The bug

GOOS=windows go vet ./... failed on main:

vet: pkg/taskproto/wrapper_test.go:629:33: undefined: syscall.Stat_t
vet: pkg/service/remote_test.go:41:42: unknown field Setpgid in struct literal of type syscall.SysProcAttr

(plus syscall.Kill, and a second Stat_t at :775). The production code builds for Windows, but go build never type-checks _test.go files, and CI vets linux only. So nothing noticed while windows/amd64 shipped.

The fixes, one per test's intent

  • pkg/taskproto. TestGenerateWrapper_OutputOnlyDirExistsBeforeDockerRun and TestGenerateWrapper_StagedFileOwnedByInvokingUID_RealFilesystem exist to prove Unix uid ownership (and sticky-bit semantics) after running the generated Linux wrapper under bash. Neither concept exists on Windows. I moved both tests verbatim into wrapper_unix_test.go under //go:build !windows. It is a pure move: the sorted lines of old vs new differ only in the new file's header and imports, and there are 32 tests before and after. The rest of wrapper_test.go, including its portable text assertions, still compiles and runs everywhere.
  • pkg/service. Every test in remote_test.go that uses fakeSSHExec already skips at runtime on Windows ("uses a POSIX shell"). Others in the file (TestSSHExecArgs, TestHTTPProbe, …) are portable. So the intent is "the file compiles everywhere; the POSIX-shell tests skip", and constraining the whole file would have dropped the portable ones. The process-group calls moved into procgroup_posix_test.go (!windows), with Windows stubs in procgroup_windows_test.go. fakeSSHExec itself now skips on Windows, so that guard belongs to the fixture and no longer depends on each caller remembering it.

The gate

scripts/release-goos-vet.sh runs go vet ./... once per GOOS that .goreleaser.yaml builds. Today that is darwin, linux and windows. It runs from make check-goos (step 2b of make check) and from a Release GOOS vet gate CI step, which is the same script in both places.

  • Discovered, not listed. It parses the builds: section's goos: lists in block and flow form, quoted or not. It ignores ignore: entries' scalar - goos: windows, and goos: keys outside builds:.
  • Fails on empty discovery, and also fails when any build has no goos list, because GoReleaser would apply its default set, which the script won't guess. That rules out a silently partial set.
  • The awk is a hand-rolled parser, so TestReleaseGOOSDiscoveryAgreesWithYAML (in release_builds_test.go, runs in go test -short) compares the script's --list output with a real gopkg.in/yaml.v3 decode (already a direct dependency). The test os.ReadFiles both the script and the config, so go test's cache invalidates when either changes.

Evidence

  • Gate watched failing: I restored main's remote_test.go, which compiles on the host (go vet ./pkg/service passed). make check-goos then failed with vet: pkg/service/remote_test.go:41:42: unknown field Setpgid … / FAIL GOOS=windows, exit 2. With the fix restored: ✅ go vet clean for every release GOOS: darwin,linux,windows.
  • Agreement test watched failing: adding - "freebsd" to .goreleaser.yaml made it fail (discovers GOOS [darwin linux windows], but .goreleaser.yaml decodes to [darwin freebsd linux windows]). That exposed a real gap: quoted list items were not parsed. I fixed it, and the test then passed with freebsd discovered. Config restored.
  • Parser fixtures (flow form, compact block list, comments, quotes, ignore:, a non-builds goos:, a build with no goos, an empty goos: [], a config with no builds) give identical results under BSD awk, mawk (the awk on Ubuntu runners) and gawk. The last three fail with a message.
  • The moved taskproto tests pass on darwin. The full pkg/service suite (not -short, so the process-group fixture really runs) passes.
  • make check: everything passes except the known TestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker, which needs a Docker daemon. make check-nested: all 9 nested modules clean.

Caveats

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 6827ee8 into main Oct 15, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/925 branch October 15, 2026 21:33
scttfrdmn added a commit that referenced this pull request Oct 16, 2026
scttfrdmn added a commit that referenced this pull request Oct 16, 2026
scttfrdmn added a commit that referenced this pull request Oct 16, 2026
* CI: run unit tests on windows-latest (#971)

* Windows CI: LF checkout

* Windows CI: fix Windows test failures and real Windows bugs, skip Linux-only tests (#971)

Fixes #997 (plugin local paths), #998 (pipeline S3 key matching), #999
(snapshot raw-image Cleanup). Skips pkg/security (#1000) and
pkg/pluginruntime (#1001); Linux-only tests skip on Windows (#1002).

* Windows CI: skip the Linux MPI user-data execution tests (#1002)

* Windows CI: audit.log mode assertion is POSIX-only (#1002)

* Windows CI: run pkg/service and pkg/taskproto now that #941 made their tests compile (#971)

* Windows CI: fix spored status clock skew, make or skip Linux-only tests (#971)

cmd/spored (real bug): buildStatusReport read uptime BEFORE the CPU/network
samples and "now" after them, so boot and billed time were late by the
sampling time — seconds on Windows, where each sample is a PowerShell
process (47s after launch reported 52s billed). And on the checkpoint path
(always on Windows, which publishes no compute clock) compute included the
status process's own run time, so it read "2s as of the last checkpoint"
with no checkpoint written. Clock readings now follow the samples, and an
unadopted clock reports exactly the checkpoint. The tests bound times by a
before/after window instead of assuming the report is instant; verified to
fail against the old code with a simulated 2.5s sampling delay.

pkg/agent: the /sys/class/net fixture used kernel-style names with ':',
which Windows rejects; the parser never reads them, so use '-'.

lambda/pipeline-orchestrator (part of the root module, no go.mod) and
pkg/taskproto: tests that execute Linux user-data / wrapper / flush hook
under bash are skipped on Windows (#1002).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two test files don't compile for GOOS=windows (syscall.Stat_t, SysProcAttr.Setpgid); no gate vets non-default GOOS

1 participant