返回 DeepSeek-Reasonix
skip_test.go
根目录 / internal / fileref / skip_test.go
1 package fileref
2
3 import (
4 "path/filepath"
5 "testing"
6 )
7
8 func TestSkipEntryHidesBuildOutputDirectories(t *testing.T) {
9 for _, name := range []string{"target", "build", "dist", "__pycache__", ".venv", "node_modules"} {
10 if !SkipEntry(name, name, true) {
11 t.Errorf("%q is a build output and must stay out of file pickers", name)
12 }
13 }
14 }
15
16 func TestSkipEntryKeepsSourceDirectories(t *testing.T) {
17 for _, name := range []string{"src", "internal", "docs", "targets", "buildkite"} {
18 if SkipEntry(name, name, true) {
19 t.Errorf("%q is not a build output and must remain browsable", name)
20 }
21 }
22 }
23
24 func TestSkipEntryIgnoresBuildNamesOnFiles(t *testing.T) {
25 if SkipEntry("cmd/build", "build", false) {
26 t.Error("a file named build is source, not a build directory")
27 }
28 }
29
30 func TestSearchSkipsGeneratedClassFiles(t *testing.T) {
31 root := t.TempDir()
32 writeFile(t, filepath.Join(root, "src", "main", "java", "App.java"))
33 writeFile(t, filepath.Join(root, "target", "classes", "App.class"))
34
35 got := resultPaths(Search(root, "app", 50))
36 for _, path := range got {
37 if path == "target/classes/App.class" {
38 t.Fatalf("generated output leaked into @ results: %v", got)
39 }
40 }
41 if len(got) == 0 {
42 t.Fatalf("the source file should still match: %v", got)
43 }
44 }
45
45 lines GO