diff --git a/checks/paths/main.go b/checks/paths/main.go
index 122b7aa2..8c4c9b3d 100644
--- a/checks/paths/main.go
+++ b/checks/paths/main.go
@@ -251,7 +251,8 @@ func main() {
}
var grown []string
if baseDir == "" {
- fmt.Println("NOT COMPARED: no base branch's lists were given, so additions to them were not judged")
+ fmt.Fprintln(os.Stderr, "NOT COMPARED: no base branch's lists were given (-base
), so additions to them were not judged; that is a failure, not a pass (issue 1295)")
+ os.Exit(2)
} else {
baseShared, _, err1 := list(filepath.Join(baseDir, "shared"))
baseKnown, _, err2 := list(filepath.Join(baseDir, "known"))
diff --git a/checks/trunk/trunk.go b/checks/trunk/trunk.go
index e3bc86f3..1c4b0da4 100644
--- a/checks/trunk/trunk.go
+++ b/checks/trunk/trunk.go
@@ -3,14 +3,14 @@
//
// The checker fetches the change's own repository at its base commit beside the change, as it fetches a sibling, and says where
// in MESH_CHECK_BESIDE; the copy is under the repository's name (the same convention the other repositories' tests use). With
-// MESH_CHECK_BESIDE unset, or set without the catalogue's copy in it, the comparison is skipped and the test says NOT COMPARED
-// WITH THE TRUNK, naming why: the checker that runs before R4g's delivery places siblings but not the change's own repository,
-// so R4g's own check cannot hold the copy (issue 1295 notes that a missing copy becomes a failure once that checker is gone). A trunk that holds no such file had
+// MESH_CHECK_BESIDE unset, or set without the catalogue's copy in it, the test fails saying NOT COMPARED WITH THE TRUNK and
+// why: the checker places the change's own repository since R4g (issue 1295), so a missing copy is a fault, never a pass. A trunk that holds no such file had
// none: the list's first copy, which nothing was added to.
package trunk
import (
"errors"
+ "fmt"
"os"
"path/filepath"
"testing"
@@ -23,13 +23,11 @@ const Repository = "mesh-catalog"
const BesideEnv = "MESH_CHECK_BESIDE"
// Copy is the trunk's copy of the file at rel (a path from the catalogue's root), written to a file of the test's own: its path,
-// and whether the trunk holds one (false: its first copy). It skips the test, saying so, when no copy of the catalogue is beside.
+// and whether the trunk holds one (false: its first copy). It fails the test when no copy of the catalogue is beside.
func Copy(t testing.TB, rel string) (string, bool) {
t.Helper()
- raw, found, skip, err := Read(rel)
+ raw, found, err := Read(rel)
switch {
- case skip != "":
- t.Skip(skip)
case err != nil:
t.Fatal(err)
case !found:
@@ -43,27 +41,25 @@ func Copy(t testing.TB, rel string) (string, bool) {
return path, true
}
-// Read is the trunk's copy of rel and whether the trunk holds one. skip is the words to skip the comparison with, when no trunk is
-// named; err is a trunk named and not there, or unreadable.
-func Read(rel string) (content []byte, found bool, skip string, err error) {
+// Read is the trunk's copy of rel and whether the trunk holds one. err is a trunk not beside the check (MESH_CHECK_BESIDE unset,
+// or without the catalogue's directory), or a copy unreadable: a comparison that cannot be made is never a pass.
+func Read(rel string) (content []byte, found bool, err error) {
beside := os.Getenv(BesideEnv)
if beside == "" {
- return nil, false, "NOT COMPARED WITH THE TRUNK: " + BesideEnv + " is not set, so the trunk's copy of " + rel +
- " is not beside this run; the checker places it", nil
+ return nil, false, fmt.Errorf("NOT COMPARED WITH THE TRUNK: %s is not set, so the trunk's copy of %s is not beside this run; the checker places the change's own repository there (issue 1295)", BesideEnv, rel)
}
dir := filepath.Join(beside, Repository)
if _, err := os.Stat(dir); errors.Is(err, os.ErrNotExist) {
- return nil, false, "NOT COMPARED WITH THE TRUNK: " + Repository + " is not beside this check in " + BesideEnv + "=" + beside +
- ", so " + rel + " is not judged against the trunk's copy (the checker before R4g places no copy of the change's own repository)", nil
+ return nil, false, fmt.Errorf("NOT COMPARED WITH THE TRUNK: %s is not beside this check in %s=%s, so %s is not judged against the trunk's copy; the checker places the change's own repository there at its trunk (issue 1295)", Repository, BesideEnv, beside, rel)
} else if err != nil {
- return nil, false, "", err
+ return nil, false, err
}
raw, err := os.ReadFile(filepath.Join(dir, rel))
if errors.Is(err, os.ErrNotExist) {
- return nil, false, "", nil
+ return nil, false, nil
}
if err != nil {
- return nil, false, "", err
+ return nil, false, err
}
- return raw, true, "", nil
+ return raw, true, nil
}
diff --git a/checks/trunk/trunk_test.go b/checks/trunk/trunk_test.go
index d8283f4d..aa0ace00 100644
--- a/checks/trunk/trunk_test.go
+++ b/checks/trunk/trunk_test.go
@@ -17,27 +17,27 @@ func TestTheCloneBesideTheCheckIsTheTrunk(t *testing.T) {
t.Fatal(err)
}
t.Setenv(BesideEnv, beside)
- raw, found, skip, err := Read("checks/x/known")
- if err != nil || skip != "" || !found || string(raw) != "a\nb\n" {
- t.Fatalf("read %q found %v skip %q err %v", raw, found, skip, err)
+ raw, found, err := Read("checks/x/known")
+ if err != nil || !found || string(raw) != "a\nb\n" {
+ t.Fatalf("read %q found %v err %v", raw, found, err)
}
- if _, found, skip, err := Read("checks/x/absent"); err != nil || skip != "" || found {
- t.Fatalf("a file the trunk does not hold: found %v skip %q err %v; wanted its first copy", found, skip, err)
+ if _, found, err := Read("checks/x/absent"); err != nil || found {
+ t.Fatalf("a file the trunk does not hold: found %v err %v; wanted its first copy", found, err)
}
}
-func TestWithNothingBesideTheComparisonIsSkippedAndSaidNotMade(t *testing.T) {
+func TestWithNothingBesideTheComparisonFailsAndSaysNotMade(t *testing.T) {
t.Setenv(BesideEnv, "")
- _, found, skip, err := Read("checks/x/known")
- if found || err != nil || len(skip) < 12 || skip[:12] != "NOT COMPARED" {
- t.Fatalf("found %v, skip %q, err %v; wanted NOT COMPARED", found, skip, err)
+ _, found, err := Read("checks/x/known")
+ if found || err == nil || !strings.Contains(err.Error(), "NOT COMPARED") {
+ t.Fatalf("found %v, err %v; wanted a failure saying NOT COMPARED", found, err)
}
}
-func TestACloneBesideWithoutTheCatalogueIsSkippedAndSaidNotMade(t *testing.T) {
- t.Setenv(BesideEnv, t.TempDir()) // the siblings are there, the catalogue's own base is not (the checker before R4g)
- _, found, skip, err := Read("checks/x/known")
- if found || err != nil || len(skip) < 12 || skip[:12] != "NOT COMPARED" || !strings.Contains(skip, "not beside") {
- t.Fatalf("found %v, skip %q, err %v; wanted NOT COMPARED naming the missing copy", found, skip, err)
+func TestACloneBesideWithoutTheCatalogueFailsAndSaysNotMade(t *testing.T) {
+ t.Setenv(BesideEnv, t.TempDir()) // the siblings are there, the catalogue's own base is not
+ _, found, err := Read("checks/x/known")
+ if found || err == nil || !strings.Contains(err.Error(), "NOT COMPARED") || !strings.Contains(err.Error(), "not beside") {
+ t.Fatalf("found %v, err %v; wanted a failure naming the missing copy", found, err)
}
}