(t *testing.T)
| 22 | ) |
| 23 | |
| 24 | func TestProcess(t *testing.T) { |
| 25 | t.Parallel() |
| 26 | d, err := os.Getwd() |
| 27 | if err != nil { |
| 28 | t.Fatal(err) |
| 29 | } |
| 30 | data := []struct { |
| 31 | name string |
| 32 | palette *Palette |
| 33 | simil stack.Similarity |
| 34 | path pathFormat |
| 35 | filter *regexp.Regexp |
| 36 | match *regexp.Regexp |
| 37 | want string |
| 38 | }{ |
| 39 | { |
| 40 | name: "BasePath", |
| 41 | palette: testPalette, |
| 42 | simil: stack.AnyPointer, |
| 43 | path: basePath, |
| 44 | want: "GOTRACEBACK=all\npanic: simple\n\nC1: runningA\n Emain Fmain.go:74 GmainR()A\n", |
| 45 | }, |
| 46 | { |
| 47 | name: "FullPath", |
| 48 | palette: testPalette, |
| 49 | simil: stack.AnyValue, |
| 50 | path: fullPath, |
| 51 | // "/" is used even on Windows. |
| 52 | want: fmt.Sprintf("GOTRACEBACK=all\npanic: simple\n\nC1: runningA\n Emain F%s:74 GmainR()A\n", strings.Replace(filepath.Join(filepath.Dir(d), "cmd", "panic", "main.go"), "\\", "/", -1)), |
| 53 | }, |
| 54 | { |
| 55 | name: "NoColor", |
| 56 | palette: &Palette{}, |
| 57 | simil: stack.AnyValue, |
| 58 | path: basePath, |
| 59 | want: "GOTRACEBACK=all\npanic: simple\n\n1: running\n main main.go:74 main()\n", |
| 60 | }, |
| 61 | { |
| 62 | name: "Match", |
| 63 | palette: testPalette, |
| 64 | simil: stack.AnyValue, |
| 65 | path: basePath, |
| 66 | match: regexp.MustCompile(`notpresent`), |
| 67 | want: "GOTRACEBACK=all\npanic: simple\n\n", |
| 68 | }, |
| 69 | { |
| 70 | name: "Filter", |
| 71 | palette: testPalette, |
| 72 | simil: stack.AnyValue, |
| 73 | path: basePath, |
| 74 | filter: regexp.MustCompile(`notpresent`), |
| 75 | want: "GOTRACEBACK=all\npanic: simple\n\nC1: runningA\n Emain Fmain.go:74 GmainR()A\n", |
| 76 | }, |
| 77 | } |
| 78 | for i, line := range data { |
| 79 | line := line |
| 80 | t.Run(fmt.Sprintf("%d-%s", i, line.name), func(t *testing.T) { |
| 81 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…