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


Golang TB.Skipf方法代码示例

本文整理汇总了Golang中testing.TB.Skipf方法的典型用法代码示例。如果您正苦于以下问题:Golang TB.Skipf方法的具体用法?Golang TB.Skipf怎么用?Golang TB.Skipf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在testing.TB的用法示例。


在下文中一共展示了TB.Skipf方法的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: 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

示例3: checkKafkaAvailability

func checkKafkaAvailability(t testing.TB) {
	if !kafkaAvailable {
		if kafkaRequired {
			t.Fatalf("Kafka broker is not available on %s. Set KAFKA_PEERS to connect to Kafka on a different location.", kafkaBrokers[0])
		} else {
			t.Skipf("Kafka broker is not available on %s. Set KAFKA_PEERS to connect to Kafka on a different location.", kafkaBrokers[0])
		}
	}
}
开发者ID:pombredanne,项目名称:gollum-1,代码行数:9,代码来源:functional_test.go

示例4: readFile

func readFile(b testing.TB, filename string) []byte {
	src, err := ioutil.ReadFile(filename)
	if err != nil {
		b.Skipf("skipping benchmark: %v", err)
	}
	if len(src) == 0 {
		b.Fatalf("%s has zero length", filename)
	}
	return src
}
开发者ID:jarpy,项目名称:beats,代码行数:10,代码来源:snappy_test.go

示例5: readFile

func readFile(t testing.TB, filename string) []byte {
	t.Logf("opening file %s", filename)
	p := filepath.Join("testdata", filepath.FromSlash(filename))
	data, err := ioutil.ReadFile(p)
	if err != nil {
		if os.IsNotExist(err) {
			t.Skipf("missing file %s", p)
		}
		t.Fatal(err)
	}
	return data
}
开发者ID:kelixin,项目名称:geoipmap,代码行数:12,代码来源:geoip_test.go

示例6: checkKafkaVersion

func checkKafkaVersion(t testing.TB, requiredVersion string) {
	kafkaVersion := os.Getenv("KAFKA_VERSION")
	if kafkaVersion == "" {
		t.Logf("No KAFKA_VERSION set. This test requires Kafka version %s or higher. Continuing...", requiredVersion)
	} else {
		available := parseKafkaVersion(kafkaVersion)
		required := parseKafkaVersion(requiredVersion)
		if !available.satisfies(required) {
			t.Skipf("Kafka version %s is required for this test; you have %s. Skipping...", requiredVersion, kafkaVersion)
		}
	}
}
开发者ID:pombredanne,项目名称:gollum-1,代码行数:12,代码来源:functional_test.go

示例7: skipNotImplemented

func skipNotImplemented(t testing.TB, err error, goos ...string) error {
	for _, os := range goos {
		if runtime.GOOS == os {
			if err == nil {
				t.Fatal("expected ErrNotImplemented")
			} else if IsNotImplemented(err) {
				t.Skipf("Skipping test on %s", runtime.GOOS)
			}

			break
		}
	}

	return err
}
开发者ID:elastic,项目名称:gosigar,代码行数:15,代码来源:sigar_interface_test.go

示例8: requiresImage

func requiresImage(t testing.TB, img string) {
	cli, err := docker.NewDefaultClient(time.Second * 3)
	if err != nil {
		t.Fatal(err)
	}
	_, err = cli.InspectImage(img)
	if err == docker.ErrNotFound {
		if strings.HasPrefix(img, "yhat/integration") {
			t.Skipf("Integration tests require you to build image '%s' beforehand. Use integration/build-test-images.sh to generate the images.", img)
		} else {
			t.Skipf("test requires docker image %s, skipping for now", img)
		}
	}
	if err != nil {
		t.Fatal(err)
	}
}
开发者ID:yhat,项目名称:workload-simulator,代码行数:17,代码来源:deploy_test.go

示例9: newDriver

func newDriver(t testing.TB, name string, options []string) *Driver {
	root, err := ioutil.TempDir("", "docker-graphtest-")
	if err != nil {
		t.Fatal(err)
	}

	if err := os.MkdirAll(root, 0755); err != nil {
		t.Fatal(err)
	}

	d, err := graphdriver.GetDriver(name, root, options, nil, nil)
	if err != nil {
		t.Logf("graphdriver: %v\n", err)
		if err == graphdriver.ErrNotSupported || err == graphdriver.ErrPrerequisites || err == graphdriver.ErrIncompatibleFS {
			t.Skipf("Driver %s not supported", name)
		}
		t.Fatal(err)
	}
	return &Driver{d, root, 1}
}
开发者ID:Cybertinus,项目名称:docker,代码行数:20,代码来源:graphtest_unix.go

示例10: downloadBenchmarkFiles

func downloadBenchmarkFiles(b testing.TB, basename string) (errRet error) {
	bDir := filepath.FromSlash(*benchdataDir)
	filename := filepath.Join(bDir, basename)
	if stat, err := os.Stat(filename); err == nil && stat.Size() != 0 {
		return nil
	}

	if !*download {
		b.Skipf("test data not found; skipping %s without the -download flag", testOrBenchmark(b))
	}
	// Download the official snappy C++ implementation reference test data
	// files for benchmarking.
	if err := os.MkdirAll(bDir, 0777); err != nil && !os.IsExist(err) {
		return fmt.Errorf("failed to create %s: %s", bDir, err)
	}

	f, err := os.Create(filename)
	if err != nil {
		return fmt.Errorf("failed to create %s: %s", filename, err)
	}
	defer f.Close()
	defer func() {
		if errRet != nil {
			os.Remove(filename)
		}
	}()
	url := benchURL + basename
	resp, err := http.Get(url)
	if err != nil {
		return fmt.Errorf("failed to download %s: %s", url, err)
	}
	defer resp.Body.Close()
	if s := resp.StatusCode; s != http.StatusOK {
		return fmt.Errorf("downloading %s: HTTP status code %d (%s)", url, s, http.StatusText(s))
	}
	_, err = io.Copy(f, resp.Body)
	if err != nil {
		return fmt.Errorf("failed to download %s to %s: %s", url, filename, err)
	}
	return nil
}
开发者ID:Richardphp,项目名称:noms,代码行数:41,代码来源:snappy_test.go

示例11: Open

func (o *mysqlOpener) Open(t testing.TB) (*Orm, interface{}) {
	// Check if MySQL is running
	conn, err := net.Dial("tcp", "localhost:3306")
	if err != nil {
		t.Skipf("MySQL is not running, skipping test (%v)", err)
	}
	conn.Close()
	creds := os.Getenv("GONDOLA_ORM_MYSQL_CREDENTIALS")
	if creds == "" {
		creds = "gotest:gotest"
	}
	orm := newOrm(t, "mysql://"+creds+"@/", true)
	db := orm.SqlDB()
	if _, err := db.Exec("DROP DATABASE IF EXISTS gotest"); err != nil {
		t.Skipf("cannot connect to mysql database, skipping test: %s", err)
	}
	if _, err := db.Exec("CREATE DATABASE gotest"); err != nil {
		t.Fatal(err)
	}
	if err := orm.Close(); err != nil {
		t.Fatal(err)
	}
	return newOrm(t, "mysql://"+creds+"@/gotest", true), nil
}
开发者ID:rainycape,项目名称:gondola,代码行数:24,代码来源:drivers_test.go

示例12: 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) (*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)
	}
	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)
	}

	if err := sftp.sendInit(); err != nil {
		defer cmd.Wait()
		t.Fatal(err)
	}
	if err := sftp.recvVersion(); err != nil {
		defer cmd.Wait()
		t.Fatal(err)
	}
	return sftp, cmd
}
开发者ID:philc,项目名称:gumshoedb,代码行数:38,代码来源:client_integration_test.go

示例13: skipWindows

func skipWindows(t testing.TB) {
	if runtime.GOOS == "windows" {
		t.Skipf("Skipping test on %s", runtime.GOOS)
	}
}
开发者ID:andrewkroh,项目名称:gosigar,代码行数:5,代码来源:sigar_interface_test.go

示例14: requiresCommand

func requiresCommand(t testing.TB, cmd string) {
	if _, err := exec.LookPath(cmd); err != nil {
		t.Skipf("required executable %s not found", cmd)
	}
}
开发者ID:yhat,项目名称:workload-simulator,代码行数:5,代码来源:deploy_test.go

示例15: testCheckAvailable

func testCheckAvailable(tb testing.TB) {
	_, err := exec.LookPath(testExecutable)
	if err != nil {
		tb.Skipf("GraphicsMagick is not available: %s", err)
	}
}
开发者ID:pierrre,项目名称:imageserver,代码行数:6,代码来源:graphicsmagick_test.go


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