novox/hq 04-ISSUES/161. The mesh compiled the host, published it, delivered it, and the launcher started it — and it would have refused the first declaration it was asked to apply, because it asks which system it was built for before applying anything and the answer was empty. The Makefile links that in. The mesh's toolchain deliberately takes nothing from the module, so it linked in nothing. The system is the stated exception, and ADR 0142 says why: the target is a property of the artifact rather than of the recipe, because a compiled binary is per system and a toolchain accepting it from the module would be accepting a build instruction. So the toolchain names the variable it fills and the artifact supplies the value. Named in the toolchain rather than inferred, and empty for a language whose output is not pinned to a system — which is every interpreted one, and a manifest declaring a system for those is already refused.
50 lines
1.6 KiB
Go
50 lines
1.6 KiB
Go
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)
|
|
}
|
|
}
|