package desktop import ( "bytes" "os" "path/filepath" "testing" ) // The desktop modules that carry this package. Each builds alone, so each has its own copy; this // test, itself one of the copied files, holds them to one text wherever the siblings are present. var carriers = []string{"xorg", "lemurs", "i3", "xterm", "adwaita"} func TestEveryDesktopModuleCarriesTheSameCopy(t *testing.T) { mine, err := filepath.Glob("*.go") if err != nil || len(mine) == 0 { t.Fatal("no files of this package found", err) } compared := 0 for _, module := range carriers { dir := filepath.Join("..", "..", "..", module, "internal", "desktop") if _, err := os.Stat(dir); err != nil { continue } theirs, _ := filepath.Glob(filepath.Join(dir, "*.go")) if len(theirs) != len(mine) { t.Errorf("%s carries %d files of this package, this copy %d", module, len(theirs), len(mine)) continue } for _, f := range mine { a, _ := os.ReadFile(f) b, err := os.ReadFile(filepath.Join(dir, f)) if err != nil || !bytes.Equal(a, b) { t.Errorf("%s's copy of %s differs from this one: change every copy together", module, f) } } compared++ } if compared == 0 { t.Log("no sibling copies beside this module") } }