1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Display only the name of the requirement…

… relative to the integration-cli package

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester 2016-12-26 19:20:27 +01:00
parent 7d8a9b9234
commit 952c8aef3f
No known key found for this signature in database
GPG key ID: 083CC6FD6EB699A3

View file

@ -2,8 +2,10 @@ package requirement
import ( import (
"fmt" "fmt"
"path"
"reflect" "reflect"
"runtime" "runtime"
"strings"
) )
type skipT interface { type skipT interface {
@ -20,7 +22,12 @@ func Is(s skipT, requirements ...Test) {
isValid := r() isValid := r()
if !isValid { if !isValid {
requirementFunc := runtime.FuncForPC(reflect.ValueOf(r).Pointer()).Name() requirementFunc := runtime.FuncForPC(reflect.ValueOf(r).Pointer()).Name()
s.Skip(fmt.Sprintf("unmatched requirement %s", requirementFunc)) s.Skip(fmt.Sprintf("unmatched requirement %s", extractRequirement(requirementFunc)))
} }
} }
} }
func extractRequirement(requirementFunc string) string {
requirement := path.Base(requirementFunc)
return strings.SplitN(requirement, ".", 2)[1]
}