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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
package testrunner_test
import (
"testing"
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/ginkgo/testrunner"
"github.com/onsi/ginkgo/ginkgo/testsuite"
. "github.com/onsi/gomega"
)
func strAddr(s string) interface{} {
return &s
}
func boolAddr(s bool) interface{} {
return &s
}
func intAddr(s int) interface{} {
return &s
}
var _ = Describe("TestRunner", func() {
It("should pass through go opts", func() {
//var opts map[string]interface{}
opts := map[string]interface{}{
"asmflags": strAddr("a"),
"pkgdir": strAddr("b"),
"gcflags": strAddr("c"),
"covermode": strAddr(""),
"coverpkg": strAddr(""),
"cover": boolAddr(false),
"blockprofilerate": intAddr(100),
"vet": strAddr("off"),
"mod": strAddr("vendor"),
}
tr := testrunner.New(testsuite.TestSuite{}, 1, false, 0, opts, []string{})
args := tr.BuildArgs(".")
// Remove the "-i" argument; This is discarded in Golang 1.10+.
if args[2] == "-i" {
args = append(args[0:2], args[3:]...)
}
Ω(args).Should(Equal([]string{
"test",
"-c",
"-o",
".",
"",
"-blockprofilerate=100",
"-asmflags=a",
"-pkgdir=b",
"-gcflags=c",
"-vet=off",
"-mod=vendor",
}))
})
})
func TestTestRunner(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Test Runner Suite")
}
|