mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 21:20:09 +00:00
All files in cmd/analyze/ are macOS-only but several were missing the //go:build darwin constraint. On Linux (e.g. CodeQL CI), Go compiled these files without the types defined in main.go (which had the tag), causing undefined symbol errors for dirEntry, fileEntry, scanResult, cacheEntry, historyEntry and model. - Add //go:build darwin to heap.go, cache.go, scanner.go, cleanable.go, delete.go, format.go, constants.go and all *_test.go files Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
//go:build darwin
|
|
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func writeFileWithSize(t *testing.T, path string, size int) {
|
|
t.Helper()
|
|
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
|
t.Fatalf("mkdir %s: %v", path, err)
|
|
}
|
|
content := make([]byte, size)
|
|
if err := os.WriteFile(path, content, 0o644); err != nil {
|
|
t.Fatalf("write %s: %v", path, err)
|
|
}
|
|
}
|
|
|
|
func TestGetDirectoryLogicalSizeWithExclude(t *testing.T) {
|
|
base := t.TempDir()
|
|
homeFile := filepath.Join(base, "fileA")
|
|
libFile := filepath.Join(base, "Library", "fileB")
|
|
projectLibFile := filepath.Join(base, "Projects", "Library", "fileC")
|
|
|
|
writeFileWithSize(t, homeFile, 100)
|
|
writeFileWithSize(t, libFile, 200)
|
|
writeFileWithSize(t, projectLibFile, 300)
|
|
|
|
total, err := getDirectoryLogicalSizeWithExclude(base, "")
|
|
if err != nil {
|
|
t.Fatalf("getDirectoryLogicalSizeWithExclude (no exclude) error: %v", err)
|
|
}
|
|
if total != 600 {
|
|
t.Fatalf("expected total 600 bytes, got %d", total)
|
|
}
|
|
|
|
excluding, err := getDirectoryLogicalSizeWithExclude(base, filepath.Join(base, "Library"))
|
|
if err != nil {
|
|
t.Fatalf("getDirectoryLogicalSizeWithExclude (exclude Library) error: %v", err)
|
|
}
|
|
if excluding != 400 {
|
|
t.Fatalf("expected 400 bytes when excluding top-level Library, got %d", excluding)
|
|
}
|
|
}
|