2 Star 7 Fork 7

Bomy / docker

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
requirement.go 874 Bytes
一键复制 编辑 原始数据 按行查看 历史
Daniel Nephin 提交于 2018-02-05 16:05 . Add canonical import comment
package requirement // import "github.com/docker/docker/integration-cli/requirement"
import (
"fmt"
"path"
"reflect"
"runtime"
"strings"
)
// SkipT is the interface required to skip tests
type SkipT interface {
Skip(reason string)
}
// Test represent a function that can be used as a requirement validation.
type Test func() bool
// Is checks if the environment satisfies the requirements
// for the test to run or skips the tests.
func Is(s SkipT, requirements ...Test) {
for _, r := range requirements {
isValid := r()
if !isValid {
requirementFunc := runtime.FuncForPC(reflect.ValueOf(r).Pointer()).Name()
s.Skip(fmt.Sprintf("unmatched requirement %s", extractRequirement(requirementFunc)))
}
}
}
func extractRequirement(requirementFunc string) string {
requirement := path.Base(requirementFunc)
return strings.SplitN(requirement, ".", 2)[1]
}
1
https://gitee.com/Bomy/docker.git
git@gitee.com:Bomy/docker.git
Bomy
docker
docker
d912e9460e28

搜索帮助