Permalink
Browse files

add -flags to add extra flags for go test

close #78
  • Loading branch information...
1 parent a63d65f commit 61ac1a6b48f7f76ff3d14e00d3192e7dd0b9db91 @mattn committed Dec 16, 2016
Showing with 24 additions and 11 deletions.
  1. +24 −11 goveralls.go
View
@@ -22,25 +22,36 @@ import (
"strings"
"time"
- "golang.org/x/tools/cover"
-
"github.com/pborman/uuid"
+ "golang.org/x/tools/cover"
)
/*
https://coveralls.io/docs/api_reference
*/
+type Flags []string
+
+func (a *Flags) String() string {
+ return strings.Join(*a, ",")
+}
+
+func (a *Flags) Set(value string) error {
+ *a = append(*a, value)
+ return nil
+}
+
var (
- pkg = flag.String("package", "", "Go package")
- verbose = flag.Bool("v", false, "Pass '-v' argument to 'go test'")
- coverprof = flag.String("coverprofile", "", "If supplied, use a go cover profile")
- covermode = flag.String("covermode", "count", "sent as covermode argument to go test")
- repotoken = flag.String("repotoken", os.Getenv("COVERALLS_TOKEN"), "Repository Token on coveralls")
- endpoint = flag.String("endpoint", "https://coveralls.io", "Hostname to submit Coveralls data to")
- service = flag.String("service", "travis-ci", "The CI service or other environment in which the test suite was run. ")
- shallow = flag.Bool("shallow", false, "Shallow coveralls internal server errors")
- ignore = flag.String("ignore", "", "Comma separated files to ignore")
+ extraFlags Flags
+ pkg = flag.String("package", "", "Go package")
+ verbose = flag.Bool("v", false, "Pass '-v' argument to 'go test'")
+ coverprof = flag.String("coverprofile", "", "If supplied, use a go cover profile")
+ covermode = flag.String("covermode", "count", "sent as covermode argument to go test")
+ repotoken = flag.String("repotoken", os.Getenv("COVERALLS_TOKEN"), "Repository Token on coveralls")
+ endpoint = flag.String("endpoint", "https://coveralls.io", "Hostname to submit Coveralls data to")
+ service = flag.String("service", "travis-ci", "The CI service or other environment in which the test suite was run. ")
+ shallow = flag.Bool("shallow", false, "Shallow coveralls internal server errors")
+ ignore = flag.String("ignore", "", "Comma separated files to ignore")
)
// usage supplants package flag's Usage variable
@@ -122,6 +133,7 @@ func getCoverage() ([]*SourceFile, error) {
if *verbose {
args = append(args, "-v")
}
+ args = append(args, extraFlags...)
args = append(args, line)
cmd.Args = args
b, err := cmd.CombinedOutput()
@@ -177,6 +189,7 @@ func process() error {
// Parse Flags
//
flag.Usage = usage
+ flag.Var(&extraFlags, "flags", "extra flags to the tests")
flag.Parse()
if len(flag.Args()) > 0 {
flag.Usage()

0 comments on commit 61ac1a6

Please sign in to comment.