mesh/delivery merged: source.main moved to novox/mesh-catalog@da29f77b1081
mesh/check being carried to 94dab6863523 on da29f77b1081 | from 5a4ac4991395
55 lines
1.5 KiB
Go
55 lines
1.5 KiB
Go
package nobinaries
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestFindNamesEachCompiledProgramAndNothingElse(t *testing.T) {
|
|
root := t.TempDir()
|
|
files := map[string][]byte{
|
|
"modules/a/a": []byte("\x7fELF\x02\x01\x01\x00rest"),
|
|
"modules/b/cmd/b/b.exe": []byte("MZ\x90\x00"),
|
|
"modules/c/c": {0xcf, 0xfa, 0xed, 0xfe, 7, 0, 0, 1},
|
|
"modules/d/main.go": []byte("package main\n"),
|
|
"modules/e/short": []byte("\x7f"),
|
|
"modules/f/empty": {},
|
|
"modules/g/Foo.class": {0xca, 0xfe, 0xba, 0xbe, 0, 0, 0, 52}, // Java, not Mach-O
|
|
}
|
|
var names []string
|
|
for f, b := range files {
|
|
p := filepath.Join(root, f)
|
|
if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(p, b, 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
names = append(names, f)
|
|
}
|
|
got, err := Find(root, names)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(got) != 3 {
|
|
t.Fatalf("found %v; wanted modules/a/a, modules/b/cmd/b/b.exe and modules/c/c only", got)
|
|
}
|
|
}
|
|
|
|
// The catalogue's own tree holds no compiled program: a compiled program is build output, so remove it and add it to .gitignore.
|
|
func TestTheCatalogueHoldsNoCompiledProgram(t *testing.T) {
|
|
root := filepath.Join("..", "..")
|
|
files, err := Files(root)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
found, err := Find(root, files)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, f := range found {
|
|
t.Errorf("%s: a compiled program is build output: remove it and add it to .gitignore (issue 1577)", f)
|
|
}
|
|
}
|