package packaging_test import ( "encoding/json" "os" "testing" ) // The mesh delivers the launcher, so the manifest carries a copy of it (novox/hq 04-ISSUES/142). // // **Two copies of one script is a drift waiting to happen**, and the only reason to accept it is that // a file resource is written atomically — temp file, then rename — while an archive writes in place // with truncate. The running launcher keeps the inode it was started from and the next start picks up // the new one; unpacking an archive over it would truncate the file a running shell is reading. // // So: two copies, and this is the check that they are the same one. func TestTheManifestCarriesTheLauncherExactly(t *testing.T) { onDisk, err := os.ReadFile("nox-mesh-host-launch") if err != nil { t.Fatal(err) } raw, err := os.ReadFile("../module.json") if err != nil { t.Fatal(err) } var manifest struct { Resources []struct { ID string `json:"id"` Content string `json:"content"` } `json:"resources"` } if err := json.Unmarshal(raw, &manifest); err != nil { t.Fatal(err) } for _, r := range manifest.Resources { if r.ID != "launcher" { continue } if r.Content != string(onDisk) { t.Fatal("the launcher the mesh would deliver is not the launcher in this repository. " + "Copy packaging/nox-mesh-host-launch into module.json's `launcher` resource — the " + "machines run what the manifest says, and this file is what gets reviewed") } return } t.Fatal("module.json declares no `launcher` resource, so nothing delivers the launcher and a " + "delivered host version is never started") }