Files
wehub-resource-sync a06f331eb8
install-script / powershell-syntax (push) Waiting to run
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
install-script / install (macos-14) (push) Waiting to run
install-script / install (ubuntu-latest) (push) Waiting to run
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:33:42 +08:00

66 lines
1.7 KiB
Go

package indexer
import "testing"
func TestIsTestFile(t *testing.T) {
cases := []struct {
path string
want bool
}{
{"internal/indexer/indexer_test.go", true},
{"cmd/gortex/main.go", false},
{"src/components/Button.test.tsx", true},
{"src/components/Button.spec.ts", true},
{"src/components/Button.tsx", false},
{"tests/test_user.py", true},
{"app/test_helpers.py", true},
{"app/helpers.py", false},
{"lib/user_test.dart", true},
{"lib/user.dart", false},
{"spec/user_spec.rb", true},
{"app/user.rb", false},
{"src/UserTest.java", true},
{"src/User.java", false},
{"src/UserTests.kt", true},
{"src/User.kt", false},
{"X/Y/__tests__/Z.ts", true},
{"X/Y/__tests__/Z.js", true},
{"X/test/foo.go", true}, // dir marker overrides extension miss
{"src/UserTests.cs", true},
{"src/UserTests.swift", true},
{"src/UserTest.php", true},
}
for _, c := range cases {
if got := IsTestFile(c.path); got != c.want {
t.Errorf("IsTestFile(%q) = %v, want %v", c.path, got, c.want)
}
}
}
func TestIsTestSymbol(t *testing.T) {
cases := []struct {
name, lang string
want bool
}{
{"TestFoo", "go", true},
{"BenchmarkFoo", "go", true},
{"FuzzFoo", "go", true},
{"ExampleFoo", "go", true},
{"Test", "go", false}, // bare prefix doesn't match
{"Testing", "go", false},
{"Helper", "go", false},
{"test_foo", "python", true},
{"TestFoo", "python", true},
{"helper", "python", false},
{"test_foo", "ruby", true},
{"helper", "ruby", false},
{"foo", "rust", false},
{"testFoo", "java", false}, // annotation-driven
}
for _, c := range cases {
if got := IsTestSymbol(c.name, c.lang); got != c.want {
t.Errorf("IsTestSymbol(%q,%q) = %v, want %v", c.name, c.lang, got, c.want)
}
}
}