Make great documentation goal 1.2, and plan the README's reorganisation and the nested-template gaps #33

Open
lilleman wants to merge 966 commits from worktree-todo-relative-dates-exact-counts into main
Showing only changes of commit 376ab29457 - Show all commits
+9 -3
View File
@@ -17,15 +17,17 @@ func TestPackageImports(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
module, found := "", false module := ""
for _, line := range strings.Split(string(mod), "\n") { for _, line := range strings.Split(string(mod), "\n") {
if module, found = strings.CutPrefix(strings.TrimSpace(line), "module "); found { if f := strings.Fields(line); len(f) > 1 && f[0] == "module" {
module = strings.Trim(f[1], `"`)
break break
} }
} }
if !found { if module == "" {
t.Fatal("go.mod names no module") t.Fatal("go.mod names no module")
} }
checked := 0
allowed := map[string][]string{ allowed := map[string][]string{
".": {"internal/drawstate"}, ".": {"internal/drawstate"},
"cmd/fejkdata": {"."}, "cmd/fejkdata": {"."},
@@ -58,6 +60,7 @@ func TestPackageImports(t *testing.T) {
if imp != module && !strings.HasPrefix(imp, module+"/") { if imp != module && !strings.HasPrefix(imp, module+"/") {
continue continue
} }
checked++
rel := strings.TrimPrefix(strings.TrimPrefix(imp, module), "/") rel := strings.TrimPrefix(strings.TrimPrefix(imp, module), "/")
if rel == "" { if rel == "" {
rel = "." rel = "."
@@ -71,6 +74,9 @@ func TestPackageImports(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if checked == 0 {
t.Fatalf("no package imports a package of module %s, which go.mod names", module)
}
for dir := range allowed { for dir := range allowed {
if !seen[dir] { if !seen[dir] {
t.Errorf("listed package %s does not exist", dir) t.Errorf("listed package %s does not exist", dir)