diff --git a/modules/mesh-build-node/cmd/mesh-build-node/build_integration_test.go b/modules/mesh-build-node/cmd/mesh-build-node/build_integration_test.go index 85809ed2..bd66ceea 100644 --- a/modules/mesh-build-node/cmd/mesh-build-node/build_integration_test.go +++ b/modules/mesh-build-node/cmd/mesh-build-node/build_integration_test.go @@ -12,6 +12,7 @@ import ( "path/filepath" "slices" "testing" + "time" "git.novox.be/novox/mesh-sdk/go/forgekey" ) @@ -125,9 +126,10 @@ func TestAPackageWhoseTestsImportItsBuildPassesTheUnitLevel(t *testing.T) { } } -// installedToolchain is the toolchain directory under toolchains that this node's Node build module installed from -// the lock at lockPath, byte for byte; "" when there is none (or the directory cannot be read: no Node build module -// here). A toolchain of another lock is never taken: the tests prove the lock they carry. +// installedToolchain is the toolchain directory under toolchains that this node's Node build module installed: the +// one installed from the lock at lockPath, byte for byte, or, when the change carries a lock no delivered release has +// installed yet, the one installed last, said in the test's log (ADR 0533 ยง3: a new lock is proven by the module that +// installs it on its first node). "" when none is there or the directory cannot be read: no Node build module here. func installedToolchain(t *testing.T, toolchains, lockPath string) string { t.Helper() want, err := os.ReadFile(lockPath) @@ -138,17 +140,29 @@ func installedToolchain(t *testing.T, toolchains, lockPath string) string { if err != nil { return "" } + last, lastAt := "", time.Time{} for _, e := range entries { dir := filepath.Join(toolchains, e.Name()) - if _, err := os.Stat(filepath.Join(dir, installedMark)); err != nil { + mark, err := os.Stat(filepath.Join(dir, installedMark)) + if err != nil { continue } - if got, err := os.ReadFile(filepath.Join(dir, "package-lock.json")); err == nil && bytes.Equal(got, want) { - t.Logf("the toolchain is this node's installed %s", dir) + got, err := os.ReadFile(filepath.Join(dir, "package-lock.json")) + if err != nil { + continue + } + if bytes.Equal(got, want) { + t.Logf("the toolchain is this node's installed %s, of this change's lock", dir) return dir } + if mark.ModTime().After(lastAt) { + last, lastAt = dir, mark.ModTime() + } } - return "" + if last != "" { + t.Logf("NOT THIS LOCK: no toolchain of this change's lock is installed here; the tests run with the one installed last, %s", last) + } + return last } // copyToolchain copies the installed toolchain from into to whole, files and folders with their modes, so the test's