本文整理汇总了Golang中testing.TB.Skip方法的典型用法代码示例。如果您正苦于以下问题:Golang TB.Skip方法的具体用法?Golang TB.Skip怎么用?Golang TB.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testing.TB
的用法示例。
在下文中一共展示了TB.Skip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testClient
// testClient returns a *Client connected to a localy running sftp-server
// the *exec.Cmd returned must be defer Wait'd.
func testClient(t testing.TB, readonly bool, delay time.Duration) (*Client, *exec.Cmd) {
if !*testIntegration {
t.Skip("skipping intergration test")
}
cmd := exec.Command(*testSftp, "-e", "-R", "-l", debuglevel) // log to stderr, read only
if !readonly {
cmd = exec.Command(*testSftp, "-e", "-l", debuglevel) // log to stderr
}
cmd.Stderr = os.Stdout
pw, err := cmd.StdinPipe()
if err != nil {
t.Fatal(err)
}
if delay > NO_DELAY {
pw = newDelayedWriter(pw, delay)
}
pr, err := cmd.StdoutPipe()
if err != nil {
t.Fatal(err)
}
if err := cmd.Start(); err != nil {
t.Skipf("could not start sftp-server process: %v", err)
}
sftp, err := NewClientPipe(pr, pw)
if err != nil {
t.Fatal(err)
}
return sftp, cmd
}
示例2: VerifyNoImports
// VerifyNoImports verifies that a package doesn't depend (directly or
// indirectly) on forbidden packages. The forbidden packages are specified as
// either exact matches or prefix matches.
// If GOPATH isn't set, it is an indication that the source is not available and
// the test is skipped.
func VerifyNoImports(
t testing.TB, pkgPath string, cgo bool, forbiddenPkgs, forbiddenPrefixes []string,
) {
// Skip test if source is not available.
if build.Default.GOPATH == "" {
t.Skip("GOPATH isn't set")
}
imports, err := TransitiveImports(pkgPath, true)
if err != nil {
t.Fatal(err)
}
for _, forbidden := range forbiddenPkgs {
if _, ok := imports[forbidden]; ok {
t.Errorf("Package %s includes %s, which is forbidden", pkgPath, forbidden)
}
}
for _, forbiddenPrefix := range forbiddenPrefixes {
for k := range imports {
if strings.HasPrefix(k, forbiddenPrefix) {
t.Errorf("Package %s includes %s, which is forbidden", pkgPath, k)
}
}
}
}
示例3: withTestEnvironment
// withTestEnvironment creates a test environment and calls f with it. After f has
// returned, the temporary directory is removed.
func withTestEnvironment(t testing.TB, f func(*testEnvironment, GlobalOptions)) {
if !RunIntegrationTest {
t.Skip("integration tests disabled")
}
tempdir, err := ioutil.TempDir(TestTempDir, "restic-test-")
OK(t, err)
env := testEnvironment{
base: tempdir,
cache: filepath.Join(tempdir, "cache"),
repo: filepath.Join(tempdir, "repo"),
testdata: filepath.Join(tempdir, "testdata"),
}
OK(t, os.MkdirAll(env.testdata, 0700))
OK(t, os.MkdirAll(env.cache, 0700))
OK(t, os.MkdirAll(env.repo, 0700))
f(&env, configureRestic(t, env.cache, env.repo))
if !TestCleanup {
t.Logf("leaving temporary directory %v used for test", tempdir)
return
}
RemoveAll(t, tempdir)
}
示例4: archiveWithDedup
func archiveWithDedup(t testing.TB) {
repo := SetupRepo()
defer TeardownRepo(repo)
if BenchArchiveDirectory == "" {
t.Skip("benchdir not set, skipping TestArchiverDedup")
}
var cnt struct {
before, after, after2 struct {
packs, dataBlobs, treeBlobs uint
}
}
// archive a few files
sn := SnapshotDir(t, repo, BenchArchiveDirectory, nil)
t.Logf("archived snapshot %v", sn.ID().Str())
// get archive stats
cnt.before.packs = repo.Count(backend.Data)
cnt.before.dataBlobs = repo.Index().Count(pack.Data)
cnt.before.treeBlobs = repo.Index().Count(pack.Tree)
t.Logf("packs %v, data blobs %v, tree blobs %v",
cnt.before.packs, cnt.before.dataBlobs, cnt.before.treeBlobs)
// archive the same files again, without parent snapshot
sn2 := SnapshotDir(t, repo, BenchArchiveDirectory, nil)
t.Logf("archived snapshot %v", sn2.ID().Str())
// get archive stats again
cnt.after.packs = repo.Count(backend.Data)
cnt.after.dataBlobs = repo.Index().Count(pack.Data)
cnt.after.treeBlobs = repo.Index().Count(pack.Tree)
t.Logf("packs %v, data blobs %v, tree blobs %v",
cnt.after.packs, cnt.after.dataBlobs, cnt.after.treeBlobs)
// if there are more data blobs, something is wrong
if cnt.after.dataBlobs > cnt.before.dataBlobs {
t.Fatalf("TestArchiverDedup: too many data blobs in repository: before %d, after %d",
cnt.before.dataBlobs, cnt.after.dataBlobs)
}
// archive the same files again, with a parent snapshot
sn3 := SnapshotDir(t, repo, BenchArchiveDirectory, sn2.ID())
t.Logf("archived snapshot %v, parent %v", sn3.ID().Str(), sn2.ID().Str())
// get archive stats again
cnt.after2.packs = repo.Count(backend.Data)
cnt.after2.dataBlobs = repo.Index().Count(pack.Data)
cnt.after2.treeBlobs = repo.Index().Count(pack.Tree)
t.Logf("packs %v, data blobs %v, tree blobs %v",
cnt.after2.packs, cnt.after2.dataBlobs, cnt.after2.treeBlobs)
// if there are more data blobs, something is wrong
if cnt.after2.dataBlobs > cnt.before.dataBlobs {
t.Fatalf("TestArchiverDedup: too many data blobs in repository: before %d, after %d",
cnt.before.dataBlobs, cnt.after2.dataBlobs)
}
}
示例5: checkTestCacheAvailable
func checkTestCacheAvailable(tb testing.TB, cache *Cache) {
conn, err := cache.Pool.Dial()
if err != nil {
cache.Close()
tb.Skip(err)
}
conn.Close()
}
示例6: skipIfNotUnix
func skipIfNotUnix(tb testing.TB) {
switch runtime.GOOS {
case "android", "nacl", "plan9", "windows":
tb.Skipf("%s does not support unix sockets", runtime.GOOS)
}
if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") {
tb.Skip("iOS does not support unix, unixgram")
}
}
示例7: newScheduler
func newScheduler(t testing.TB) *ecs.Scheduler {
creds := &credentials.EnvProvider{}
if _, err := creds.Retrieve(); err != nil {
t.Skip("Skipping ECS test because AWS_ environment variables are not present.")
}
config := defaults.DefaultConfig.WithCredentials(credentials.NewCredentials(creds))
return ecs.NewScheduler(config)
}
示例8: checkTestCacheAvailable
func checkTestCacheAvailable(tb testing.TB, cache *Cache) {
err := cache.Client.Set(&memcache_impl.Item{
Key: "ping",
Value: []byte("ping"),
})
if err != nil {
tb.Skip(err)
}
}
示例9: NewReplicaSetHarness
func NewReplicaSetHarness(n uint, t testing.TB) *ReplicaSetHarness {
if disableSlowTests {
t.Skip("disabled because it's slow")
}
mgoRS := mgotest.NewReplicaSet(n, t)
return &ReplicaSetHarness{
Harness: newHarnessInternal(mgoRS.Addrs()[n-1], mgoRS, t),
MgoReplicaSet: mgoRS,
}
}
示例10: PutDriver
// PutDriver removes the driver if it is no longer used and updates the reference count.
func PutDriver(t testing.TB) {
if drv == nil {
t.Skip("No driver to put!")
}
drv.refCount--
if drv.refCount == 0 {
cleanup(t, drv)
drv = nil
}
}
示例11: parseAccount
func parseAccount(tb testing.TB) *Account {
acc := &Account{}
if data, err := ioutil.ReadFile("account.txt"); err == nil {
if err := acc.Parse(strings.TrimSpace(string(data))); err == nil {
tb.Logf("Using account %+v", *acc)
return acc
}
}
tb.Skip("Please, place your Pinterest account in account.txt (username: password)")
return nil
}
示例12: testInit
func testInit(dir string, t testing.TB) graphdriver.Driver {
d, err := Init(dir, nil, nil, nil)
if err != nil {
if err == graphdriver.ErrNotSupported {
t.Skip(err)
} else {
t.Fatal(err)
}
}
return d
}
示例13: Open
func (o *postgresOpener) Open(t testing.TB) (*Orm, interface{}) {
u, err := user.Current()
if err != nil {
t.Fatal(err)
}
exec.Command("dropdb", "gotest").Run()
if err := exec.Command("createdb", "gotest").Run(); err != nil {
t.Skip("cannot create gotest postgres database, skipping test")
}
return newOrm(t, fmt.Sprintf("postgres://dbname=gotest user=%v password=%v", u.Username, u.Username), true), nil
}
示例14: newLocalhostServer
func newLocalhostServer(tb testing.TB) *Client {
c, err := net.Dial("tcp", testServer)
if err != nil {
tb.Skip("skipping test; no server running at %s", testServer)
return nil
}
c.Write([]byte("flush_all\r\n"))
c.Close()
client, err := New(testServer)
if err != nil {
tb.Fatal(err)
}
return client
}
示例15: testRun
func testRun(b testing.TB, decode decodeFunc) {
if !fastjpeg.Available() {
b.Skip("Skipping benchmark, djpeg unavailable.")
}
im, _, err := decode(bytes.NewReader(jpegBytes))
if err != nil {
b.Fatal(err)
}
rect := im.Bounds()
w, h := 128, 128
im = resize.Resize(im, rect, w, h)
err = jpeg.Encode(ioutil.Discard, im, nil)
if err != nil {
b.Fatal(err)
}
}