当前位置: 首页>>代码示例>>Golang>>正文


Golang TB.Skip方法代码示例

本文整理汇总了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
}
开发者ID:marete,项目名称:restic,代码行数:33,代码来源:client_integration_test.go

示例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)
			}
		}
	}
}
开发者ID:knz,项目名称:cockroach,代码行数:31,代码来源:build.go

示例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)
}
开发者ID:marete,项目名称:restic,代码行数:30,代码来源:integration_helpers_test.go

示例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)
	}
}
开发者ID:fawick,项目名称:restic,代码行数:59,代码来源:archiver_test.go

示例5: checkTestCacheAvailable

func checkTestCacheAvailable(tb testing.TB, cache *Cache) {
	conn, err := cache.Pool.Dial()
	if err != nil {
		cache.Close()
		tb.Skip(err)
	}
	conn.Close()
}
开发者ID:cautio,项目名称:imageserver,代码行数:8,代码来源:redis_test.go

示例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")
	}
}
开发者ID:insionng,项目名称:vodka,代码行数:9,代码来源:client_test.go

示例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)
}
开发者ID:ejholmes,项目名称:12factor,代码行数:9,代码来源:ecs_test.go

示例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)
	}
}
开发者ID:cautio,项目名称:imageserver,代码行数:9,代码来源:memcache_test.go

示例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,
	}
}
开发者ID:Vungle,项目名称:dvara,代码行数:10,代码来源:common_test.go

示例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
	}
}
开发者ID:Cybertinus,项目名称:docker,代码行数:11,代码来源:graphtest_unix.go

示例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
}
开发者ID:rainycape,项目名称:gondola,代码行数:11,代码来源:pinterest_test.go

示例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
}
开发者ID:DCdrone,项目名称:docker,代码行数:11,代码来源:aufs_test.go

示例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
}
开发者ID:rainycape,项目名称:gondola,代码行数:11,代码来源:drivers_test.go

示例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
}
开发者ID:brunoqc,项目名称:memcache,代码行数:14,代码来源:memcache_test.go

示例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)
	}
}
开发者ID:stevearm,项目名称:camlistore,代码行数:16,代码来源:benchfastjpeg_test.go


注:本文中的testing.TB.Skip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。