oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package gotoolchain
2
3import (
4 "os"
5 "os/exec"
6 "path/filepath"
7 "strings"
8 "testing"
9)
10
11// TestEnvironmentKeepsMakeOnLocalToolchain: production 2026-11-22, a
12// project Makefile began `export GOTOOLCHAIN := go1.26.5`. A Makefile
13// assignment beats the environment, so its go commands asked for that
14// release, which the offline checks cannot fetch (GOSUMDB=off refuses a
15// toolchain download). The shared environment carries GOTOOLCHAIN=local
16// as a make command-line variable (MAKEFLAGS), which beats the Makefile,
17// for every launch that uses it and for nested makes.
18func TestEnvironmentKeepsMakeOnLocalToolchain(t *testing.T) {
19 makeBin, err := exec.LookPath("make")
20 if err != nil {
21 t.Skip("make is not installed")
22 }
23 dir := t.TempDir()
24 makefile := "export GOTOOLCHAIN := go1.26.5\nGOTOOLCHAIN = go1.26.6\nall:\n\t@echo \"recipe=$$GOTOOLCHAIN\"; sh -c 'echo child=$$GOTOOLCHAIN'\nnested:\n\t@$(MAKE) --no-print-directory all\n"
25 if err := os.WriteFile(filepath.Join(dir, "Makefile"), []byte(makefile), 0o600); err != nil {
26 t.Fatal(err)
27 }
28 for _, p := range []string{"", "claude", "codex", "pi"} {
29 env := Environment(p)
30 if env["GOTOOLCHAIN"] != "local" {
31 t.Fatalf("%q: GOTOOLCHAIN %q", p, env["GOTOOLCHAIN"])
32 }
33 for _, target := range []string{"all", "nested"} {
34 cmd := exec.Command(makeBin, "-s", target)
35 cmd.Dir = dir
36 cmd.Env = []string{"PATH=" + os.Getenv("PATH")}
37 for k, v := range env {
38 if k != "PATH" {
39 cmd.Env = append(cmd.Env, k+"="+v)
40 }
41 }
42 out, err := cmd.CombinedOutput()
43 if err != nil || strings.TrimSpace(string(out)) != "recipe=local\nchild=local" {
44 t.Fatalf("provider %q, make %s: %q %v", p, target, out, err)
45 }
46 }
47 }
48}
49