/usr/share/gocode/src/github.com/smartystreets/goconvey/convey/parsing.go is in golang-github-smartystreets-goconvey-dev 1.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | package convey
import (
"github.com/smartystreets/goconvey/execution"
"github.com/smartystreets/goconvey/gotest"
)
func discover(items []interface{}) *execution.Registration {
ensureEnough(items)
name := parseName(items)
test := parseGoTest(items)
action := parseAction(items, test)
return execution.NewRegistration(name, action, test)
}
func ensureEnough(items []interface{}) {
if len(items) < 2 {
panic(parseError)
}
}
func parseName(items []interface{}) string {
if name, parsed := items[0].(string); parsed {
return name
}
panic(parseError)
}
func parseGoTest(items []interface{}) gotest.T {
if test, parsed := items[1].(gotest.T); parsed {
return test
}
return nil
}
func parseAction(items []interface{}, test gotest.T) *execution.Action {
var index = 1
if test != nil {
index = 2
}
if action, parsed := items[index].(func()); parsed {
return execution.NewAction(action)
}
if items[index] == nil {
return execution.NewSkippedAction(skipReport)
}
panic(parseError)
}
const parseError = "You must provide a name (string), then a *testing.T (if in outermost scope), and then an action (func())."
|