當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。