• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

maxatome / go-testdeep / 21543807886

31 Jan 2026 11:29AM UTC coverage: 26.962% (-73.0%) from 99.921%
21543807886

Pull #287

github

maxatome
chore: gocovmerge not needed anymore

Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
Pull Request #287: Some features before the release

25 of 57 new or added lines in 6 files covered. (43.86%)

7342 existing lines in 95 files now uncovered.

2796 of 10370 relevant lines covered (26.96%)

28.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/internal/trace/stack.go
1
// Copyright (c) 2021, Maxime Soulé
2
// All rights reserved.
3
//
4
// This source code is licensed under the BSD-style license found in the
5
// LICENSE file in the root directory of this source tree.
6

7
package trace
8

9
import (
10
        "fmt"
11
        "io"
12
        "strings"
13
)
14

15
// Level is a level when retrieving a stack trace.
16
type Level struct {
17
        Package  string
18
        Func     string
19
        FileLine string
20
}
21

22
// Stack is a simple stack trace.
23
type Stack []Level
24

25
// Match returns true if the ith level of s matches pkg (if not empty)
26
// and any function in anyFunc.
27
//
28
// If anyFunc is empty, only the package is tested.
29
//
30
// If a function in anyFunc ends with "*", only the prefix is checked.
UNCOV
31
func (s Stack) Match(i int, pkg string, anyFunc ...string) bool {
×
UNCOV
32
        if i < 0 {
×
UNCOV
33
                i = len(s) + i
×
UNCOV
34
        }
×
UNCOV
35
        if i < 0 || i >= len(s) {
×
UNCOV
36
                return false
×
UNCOV
37
        }
×
38

UNCOV
39
        level := s[i]
×
UNCOV
40

×
UNCOV
41
        if pkg != "" && level.Package != pkg {
×
UNCOV
42
                return false
×
UNCOV
43
        }
×
44

UNCOV
45
        if len(anyFunc) == 0 {
×
UNCOV
46
                return true
×
UNCOV
47
        }
×
48

UNCOV
49
        for _, fn := range anyFunc {
×
UNCOV
50
                if strings.HasSuffix(fn, "*") {
×
UNCOV
51
                        if strings.HasPrefix(level.Func, fn[:len(fn)-1]) {
×
UNCOV
52
                                return true
×
UNCOV
53
                        }
×
UNCOV
54
                } else if level.Func == fn {
×
UNCOV
55
                        return true
×
UNCOV
56
                }
×
57
        }
UNCOV
58
        return false
×
59
}
60

61
// IsRelevant returns true if the stack contains more than one level,
62
// or if the single level has a path with at least one directory.
UNCOV
63
func (s Stack) IsRelevant() bool {
×
UNCOV
64
        return len(s) > 1 || (len(s) > 0 && strings.ContainsAny(s[0].FileLine, `/\`))
×
UNCOV
65
}
×
66

67
// Dump writes the stack to w.
UNCOV
68
func (s Stack) Dump(w io.Writer) {
×
UNCOV
69
        fnMaxLen := 0
×
UNCOV
70
        for _, level := range s {
×
UNCOV
71
                if len(level.Func) > fnMaxLen {
×
UNCOV
72
                        fnMaxLen = len(level.Func)
×
UNCOV
73
                }
×
74
        }
UNCOV
75
        fnMaxLen += 2
×
UNCOV
76

×
UNCOV
77
        nl := ""
×
UNCOV
78
        for _, level := range s {
×
UNCOV
79
                fmt.Fprintf(w, "%s\t%-*s %s", nl, fnMaxLen, level.Func+"()", level.FileLine) //nolint: errcheck
×
UNCOV
80
                nl = "\n"
×
UNCOV
81
        }
×
82
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc