Run validation in the selected module

This commit is contained in:
2026-10-10 02:43:23 +00:00
parent 02896b6e12
commit 8350cbf9c9
17 changed files with 577 additions and 55 deletions

View File

@@ -432,6 +432,21 @@ func TestBuildCancellationReturnsCompletedArtifacts(t *testing.T) {
func TestCheckBuildsAfterValidationAndKeepsOutputOutsideWorktree(t *testing.T) {
repository := newPublishFixture(t)
realGo, err := exec.LookPath("go")
if err != nil {
t.Fatal(err)
}
goShimDir := t.TempDir()
goLog := filepath.Join(goShimDir, "go-commands")
goShim := filepath.Join(goShimDir, "go")
shimSource := "#!/bin/sh\nset -eu\nprintf '%s\\n' \"$*\" >> \"$RELEASEKIT_REAL_GO_LOG\"\nexec \"$RELEASEKIT_REAL_GO\" \"$@\"\n"
if err := os.WriteFile(goShim, []byte(shimSource), 0o700); err != nil {
t.Fatal(err)
}
t.Setenv("RELEASEKIT_REAL_GO", realGo)
t.Setenv("RELEASEKIT_REAL_GO_LOG", goLog)
t.Setenv("GOENV", "off")
t.Setenv("PATH", goShimDir+string(os.PathListSeparator)+os.Getenv("PATH"))
writeFile(t, repository.work, "guide.md", "# Guide\n[section](#guide)\n")
gitRun(t, repository.work, "add", "guide.md")
gitRun(t, repository.work, "commit", "-m", "add Markdown guide")
@@ -465,6 +480,26 @@ func main() { if len(os.Args) == 2 && os.Args[1] == "version" { fmt.Printf("fixt
if validations != 1 || candidate.Commit != gitText(t, repository.work, "rev-parse", "HEAD") {
t.Fatalf("candidate = %#v, validation calls = %d", candidate, validations)
}
goCommands, err := os.ReadFile(goLog)
if err != nil {
t.Fatal(err)
}
var discoveries, suites, builds, versions int
for _, command := range strings.Split(strings.TrimSpace(string(goCommands)), "\n") {
switch {
case strings.HasPrefix(command, "env "):
discoveries++
case strings.HasPrefix(command, "test "):
suites++
case strings.HasPrefix(command, "build "):
builds++
case command == "version":
versions++
}
}
if discoveries != 2 || suites != 1 || builds != 1 || versions != 1 {
t.Fatalf("Go commands = %q; discovery=%d suite=%d build=%d version=%d, want 2, 1, 1, 1", goCommands, discoveries, suites, builds, versions)
}
if got := gitText(t, repository.work, "status", "--porcelain"); got != "" {
t.Fatalf("candidate build dirtied worktree: %s", got)
}