-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run code coverage tests and upload to codecov
Signed-off-by: Adrian Reber <areber@redhat.com>
- Loading branch information
1 parent
130a18c
commit 83407fb
Showing
8 changed files
with
158 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
test/test | ||
test/test.coverage | ||
test/piggie/piggie | ||
test/phaul | ||
test/phaul/phaul | ||
test/phaul/phaul.coverage | ||
image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// +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 | ||
// main. | ||
default: | ||
args = append(args, arg) | ||
} | ||
} | ||
|
||
signal.Reset() | ||
os.Args = args | ||
main() // "run" to | ||
|
||
// 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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package main_test | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestMain(t *testing.T) { | ||
// Do nothing. We just need dummy to make `ginkgo` happy. Without that, | ||
// `ginkgo` would try to execute the _coverage_test.go _despite_ the | ||
t.Parallel() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// +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 | ||
// main. | ||
default: | ||
args = append(args, arg) | ||
} | ||
} | ||
|
||
signal.Reset() | ||
os.Args = args | ||
main() // "run" it | ||
|
||
// 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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package main_test | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestMain(t *testing.T) { | ||
// Do nothing. We just need dummy to make `ginkgo` happy. Without that, | ||
// `ginkgo` would try to execute the _coverage_test.go _despite_ the | ||
t.Parallel() | ||
} |