mesh/delivery merged: source.main moved to novox/mesh-catalog@476a59162f55
mesh/check checking 9109524502f9 on bf94af0a820f
The levels a build module judges hand the tests MESH_BUILD_NODE=1; the tests that run a step in bubblewrap fail on it when bwrap is missing. Issue 1309
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"testing"
|
|
)
|
|
|
|
// bubblewrapAction is what a test that runs a step in bubblewrap does: "" when bubblewrap is there, "fail" where a
|
|
// build module that judges says this is a build node (MESH_BUILD_NODE=1, which mesh-build-go hands the tests), since
|
|
// every build node declares and has it, and "skip" anywhere else (issue 1309).
|
|
func bubblewrapAction(found bool, buildNodeMark string) string {
|
|
switch {
|
|
case found:
|
|
return ""
|
|
case buildNodeMark == "1":
|
|
return "fail"
|
|
}
|
|
return "skip"
|
|
}
|
|
|
|
// needBubblewrap stops a test that runs a step in bubblewrap where there is none.
|
|
func needBubblewrap(t *testing.T) {
|
|
t.Helper()
|
|
_, err := exec.LookPath("bwrap")
|
|
switch bubblewrapAction(err == nil, os.Getenv("MESH_BUILD_NODE")) {
|
|
case "fail":
|
|
t.Fatal("no bubblewrap installed on a build node: every build node declares it, so the proof is not skipped here")
|
|
case "skip":
|
|
t.Skip("NOT RUN: no bubblewrap installed where this check runs; every build node has it (the module declares it)")
|
|
}
|
|
}
|
|
|
|
func TestAMissingBubblewrapFailsOnABuildNodeAndSkipsElsewhere(t *testing.T) {
|
|
for _, c := range []struct {
|
|
name string
|
|
found bool
|
|
mark string
|
|
want string
|
|
}{
|
|
{"there", true, "1", ""},
|
|
{"missing on a desk", false, "", "skip"},
|
|
{"missing on a build node", false, "1", "fail"},
|
|
} {
|
|
if got := bubblewrapAction(c.found, c.mark); got != c.want {
|
|
t.Errorf("%s: %q, want %q", c.name, got, c.want)
|
|
}
|
|
}
|
|
}
|