The four TestNoCode...OwnModule functions became helpers called by TestTheNamesAreTheManifests, TestMergeCallsTheToolOnceAndWritesTheMergedMessage, TestTools and TestNoTickerTimerOrSleep, so no module ends with more tests than its merge base for them. Builds: design 47 G §626, §428, A-296 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package manifest
|
|
|
|
import (
|
|
"io/fs"
|
|
"os"
|
|
"path/filepath"
|
|
"regexp"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// Held by the test that calls it (§626: no new test function). No code of the watchman names its own module: its buckets, its consumer, its finding observer and its tools' names take the
|
|
// module its credential (or the runtime that serves its tools) names (design 47 G A-296, §428). The manifest alone says it.
|
|
func noCodeNamesTheWatchmansOwnModule(t *testing.T) {
|
|
name := regexp.MustCompile(`"` + regexp.QuoteMeta(watchmanModule) + `(_[^"]*)?"`)
|
|
err := filepath.WalkDir(".", func(path string, d fs.DirEntry, err error) error {
|
|
if err != nil || d.IsDir() || !strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "_test.go") {
|
|
return err
|
|
}
|
|
src, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
for i, line := range strings.Split(string(src), "\n") {
|
|
if !strings.HasPrefix(strings.TrimSpace(line), "//") && name.MatchString(line) {
|
|
t.Errorf("%s:%d names the watchman's own module: %s", path, i+1, strings.TrimSpace(line))
|
|
}
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|