-
Notifications
You must be signed in to change notification settings - Fork 48
/
vgrep_coverage_test.go
41 lines (35 loc) · 900 Bytes
/
vgrep_coverage_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// +build coverage
package main
import (
"os"
"os/signal"
"strings"
"testing"
)
// NOTE: do not use this in production. Binaries built with this file are
// merely useful to collect coverage data.
func TestCoverageMain(_ *testing.T) {
var (
args []string
)
for _, arg := range os.Args {
switch {
case strings.HasPrefix(arg, "COVERAGE"):
// Dummy argument to enable global flags.
case strings.HasPrefix(arg, "-test"):
// Make sure we don't pass `go test` specific flags to
// Podman.
default:
args = append(args, arg)
}
}
signal.Reset()
os.Args = args
main() // "run" Podman
// Make sure that std{err,out} write to /dev/null so we prevent the
// testing backend to print "PASS" along with the coverage. We really
// want the coverage to be set via the `-test.coverprofile=$path` flag.
null, _ := os.Open(os.DevNull)
os.Stdout = null
os.Stderr = null
}