Add the Go build module's fixture repositories, and correct the copied build recipe (issues 1290, 1291, 1486, 1487), part 14 of 20

This commit is contained in:
2026-10-20 20:57:30 +00:00
parent 9436ef8777
commit c27f978bc4
32 changed files with 204 additions and 1 deletions
@@ -15,7 +15,7 @@
// rather than from the linker: two builds of one commit produce the same bytes.
//
// **And of one build source at two commits** (novox/hq ADR 0267 rule 6, issue 363): a module
// built from its repository's root is compiled with the clone's `.git` in view, and Go stamps the commit,
// from its repository's root is compiled with the clone's `.git` in view, and Go stamps the commit,
// its time and whether the tree was modified into the binary unless told not to — so a merge that
// changed only a README made a new digest of an unchanged program.
Compile: []string{
@@ -0,0 +1,3 @@
package broken
func One() int { return "one" }
@@ -0,0 +1,5 @@
package broken
import "testing"
func TestOne(t *testing.T) { One() }
@@ -0,0 +1,3 @@
module fixture/broken
go 1.25.0
@@ -0,0 +1,9 @@
// Command prog is what the build step of issue 1487 builds in its integration test.
package main
import "fmt"
// builtFor is stamped by the linker.
var builtFor string
func main() { fmt.Println("prog built for", builtFor) }
@@ -0,0 +1,3 @@
module fixture/build
go 1.25.0
@@ -0,0 +1,17 @@
{
"module": "fixture-build",
"version": "1",
"build": {
"artifacts": [
{
"name": "tools",
"kind": "bundle",
"language": "go",
"system": "arch",
"from": "cmd/prog",
"binary": "prog-bin",
"loads": ["prog-bin"]
}
]
}
}
@@ -0,0 +1,4 @@
package a
// A is what a's tests check.
func A() int { return 1 }
@@ -0,0 +1,15 @@
package a
import (
"os"
"testing"
"fixture/digest/b"
)
func TestAReadsBAndItsTestdata(t *testing.T) {
raw, err := os.ReadFile("testdata/x.txt")
if err != nil || A()+b.B() != 3 || len(raw) == 0 {
t.Fatal("a")
}
}
@@ -0,0 +1,4 @@
package b
// B is reached by a's tests.
func B() int { return 2 }
@@ -0,0 +1,6 @@
package c
import _ "embed"
//go:embed note.txt
var Note string
@@ -0,0 +1,9 @@
package c
import "testing"
func TestCHasANote(t *testing.T) {
if Note == "" {
t.Fatal("c")
}
}
@@ -0,0 +1 @@
note
@@ -0,0 +1,4 @@
package d
// D is reached by no test.
func D() int { return 4 }
@@ -0,0 +1,3 @@
module fixture/digest
go 1.25.0
@@ -0,0 +1,3 @@
package empty
func Nothing() {}
@@ -0,0 +1,3 @@
module fixture/empty
go 1.25.0
@@ -0,0 +1,3 @@
package bad
func Three() int { return 3 }
@@ -0,0 +1,9 @@
package bad
import "testing"
func TestThreeIsFour(t *testing.T) {
if Three() != 4 {
t.Fatalf("Three() = %d, want 4", Three())
}
}
@@ -0,0 +1,3 @@
module fixture/failing
go 1.25.0
@@ -0,0 +1,3 @@
package good
func Two() int { return 2 }
@@ -0,0 +1,9 @@
package good
import "testing"
func TestTwo(t *testing.T) {
if Two() != 2 {
t.Fatal("two")
}
}
@@ -0,0 +1,3 @@
module fixture/slow
go 1.25.0
@@ -0,0 +1,3 @@
package slow
func Zero() int { return 0 }
@@ -0,0 +1,16 @@
package slow
import (
"testing"
"time"
)
func TestTakesAWhile(t *testing.T) {
time.Sleep(60 * time.Millisecond)
}
func TestQuick(t *testing.T) {
if Zero() != 0 {
t.Fatal("zero")
}
}
@@ -0,0 +1,3 @@
module fixture/store
go 1.25.0
@@ -0,0 +1,4 @@
package store
// Name is what the integration test below finds a store and a bus for.
const Name = "store"
@@ -0,0 +1,37 @@
//go:build integration
package store
import (
"bufio"
"net"
"net/url"
"os"
"path/filepath"
"strings"
"testing"
"time"
)
// The fixture of issue 1486: the store and the bus a run gives its tests are there, reached as a test reaches them.
func TestTheStoreAndTheBusAreThere(t *testing.T) {
u, err := url.Parse(os.Getenv("MESH_TEST_POSTGRES"))
if err != nil || u.Query().Get("host") == "" {
t.Fatalf("MESH_TEST_POSTGRES = %q", os.Getenv("MESH_TEST_POSTGRES"))
}
pg, err := net.DialTimeout("unix", filepath.Join(u.Query().Get("host"), ".s.PGSQL.5432"), 5*time.Second)
if err != nil {
t.Fatalf("the store's socket: %v", err)
}
pg.Close()
bus, err := net.DialTimeout("tcp", strings.TrimPrefix(os.Getenv("MESH_TEST_NATS"), "nats://"), 5*time.Second)
if err != nil {
t.Fatalf("the bus: %v", err)
}
defer bus.Close()
line, err := bufio.NewReader(bus).ReadString('\n')
if err != nil || !strings.HasPrefix(line, "INFO ") || !strings.Contains(line, `"jetstream":true`) {
t.Fatalf("the bus said %q (%v), want an INFO line with JetStream on", line, err)
}
}
@@ -0,0 +1,3 @@
module fixture/tagged
go 1.25.0
@@ -0,0 +1,3 @@
package tagged
func One() int { return 1 }
@@ -0,0 +1,11 @@
//go:build integration
package tagged
import "testing"
func TestNeedsAStore(t *testing.T) {
if One() != 1 {
t.Fatal("one")
}
}