package builder import ( "strings" "testing" ) // A host built without knowing its system refuses every declaration before applying anything — // safely, totally, and with nothing reporting it. The mesh built one, delivered it, started it, and // it would have refused the first thing it was asked to do (novox/hq 04-ISSUES/161). func TestTheGoToolchainStampsTheArtifactsSystem(t *testing.T) { chain, err := ToolchainFor("go") if err != nil { t.Fatal(err) } if chain.SystemStamp != "main.builtFor" { t.Fatalf("the go toolchain fills %q", chain.SystemStamp) } } func TestALanguageWithNoPinnedSystemStampsNothing(t *testing.T) { // Interpreted output is not pinned to a system, and a manifest declaring one for it is already // refused. Nothing to fill. for _, language := range []string{"typescript", "python"} { chain, err := ToolchainFor(language) if err != nil { t.Fatal(err) } if chain.SystemStamp != "" { t.Fatalf("%s fills %q, and its output is not pinned to a system", language, chain.SystemStamp) } } } func TestTheStampIsTheOneThingTakenFromTheArtifact(t *testing.T) { // The toolchain accepts nothing else from the module — anything it could override it would be // writing a Dockerfile to override. The system is the stated exception, because a compiled // binary is per system and the artifact is what declares one (ADR 0142). chain, err := ToolchainFor("go") if err != nil { t.Fatal(err) } joined := strings.Join(chain.Compile, " ") if strings.Contains(joined, "${") || strings.Contains(joined, "%s") { t.Fatalf("the compile line takes something from the module: %q", joined) } }