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:
parent
7d8a9b9234
commit
952c8aef3f
1 changed files with 8 additions and 1 deletions
|
@ -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]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue