MCPcopy Create free account
hub / github.com/bracesdev/errtrace / TestExpandPatterns

Function TestExpandPatterns

cmd/errtrace/main_test.go:576–714  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

574}
575
576func TestExpandPatterns(t *testing.T) {
577 dir := t.TempDir()
578
579 // Temporary directories on macOS are symlinked to /private/var/folders/...
580 dir, err := filepath.EvalSymlinks(dir)
581 if err != nil {
582 t.Fatal(err)
583 }
584
585 files := map[string]string{
586 "go.mod": "module example.com/foo\n",
587 "top.go": "package foo\n",
588 "top_test.go": "package foo\n",
589 "sub/sub.go": "package sub\n",
590 "sub/sub_test.go": "package sub\n",
591 "sub/sub_ext_test.go": "package sub_test\n",
592 "testdata/ignored_by_default.go": "package testdata\n",
593 "tagged.go": "//go:build mytag\npackage foo\n",
594 "tagged_test.go": "//go:build mytag\npackage foo\n",
595 }
596
597 for name, src := range files {
598 dst := filepath.Join(dir, name)
599 if err := os.MkdirAll(filepath.Dir(dst), 0o700); err != nil {
600 t.Fatal(err)
601 }
602
603 if err := os.WriteFile(dst, []byte(src), 0o600); err != nil {
604 t.Fatal(err)
605 }
606 }
607
608 tests := []struct {
609 name string
610 args []string
611 want []string
612 }{
613 {
614 name: "stdin",
615 args: []string{"-"},
616 want: []string{"-"},
617 },
618 {
619 name: "all",
620 args: []string{"./..."},
621 want: []string{
622 "top.go",
623 "top_test.go",
624 "sub/sub.go",
625 "sub/sub_test.go",
626 "sub/sub_ext_test.go",
627 "tagged.go",
628 "tagged_test.go",
629 },
630 },
631 {
632 name: "relative subpackage",
633 args: []string{"./sub"},

Callers

nothing calls this directly

Calls 4

DiffFunction · 0.92
chdirFunction · 0.85
expandPatternsFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected