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


Golang testing.M类代码示例

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


在下文中一共展示了M类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestMain

func TestMain(m *testing.M) {
	var cleanup func()
	etcdAddr, cleanup = etcdrunner.RunEtcdServer(etcdLogger{log.New(os.Stderr, "", log.Lmicroseconds|log.Lshortfile)})
	exitCode := m.Run()
	cleanup()
	os.Exit(exitCode)
}
开发者ID:technosophos,项目名称:flynn,代码行数:7,代码来源:etcd_backend_test.go

示例2: TestMain

func TestMain(m *testing.M) {
	p, err = New("./test")
	defer os.Remove("./test")
	m.Run()
	p.Close()

}
开发者ID:alankm,项目名称:privileges,代码行数:7,代码来源:database_test.go

示例3: TestMain

func TestMain(m *testing.M) {
	flag.Parse()
	rand.Seed(time.Now().UnixNano())
	// For redis tests we just point at an external server.
	if *flagReddisHost != "" {
		testData = newDataAccess(*flagReddisHost, true)
		if *flagFlushRedis {
			log.Println("FLUSHING REDIS")
			c := testData.getConnection()
			_, err := c.Do("FLUSHDB")
			if err != nil {
				log.Fatal(err)
			}
		}
	} else {
		// To test ledis, start a local instance in a new tmp dir. We will attempt to delete it when we're done.
		addr := "127.0.0.1:9876"
		testPath := filepath.Join(os.TempDir(), "bosun_ledis_test", fmt.Sprint(time.Now().Unix()))
		log.Println(testPath)
		stop, err := StartLedis(testPath, addr)
		if err != nil {
			log.Fatal(err)
		}
		testData = newDataAccess(addr, false)
		cleanups = append(cleanups, func() {
			stop()
			os.RemoveAll(testPath)
		})
	}
	status := m.Run()
	for _, c := range cleanups {
		c()
	}
	os.Exit(status)
}
开发者ID:giganteous,项目名称:bosun,代码行数:35,代码来源:database_test.go

示例4: TestMain

func TestMain(m *testing.M) {
	createTestDB()
	c := m.Run()
	deleteTestDB()

	os.Exit(c)
}
开发者ID:paked,项目名称:steel,代码行数:7,代码来源:user_test.go

示例5: TestMain

func TestMain(m *testing.M) {
	size = numXi(index)
	pk = []byte{1}

	runtime.GOMAXPROCS(runtime.NumCPU())

	id := flag.Int("index", 1, "graph index")
	flag.Parse()
	index = int64(*id)

	graphDir = fmt.Sprintf("%s%d", graphDir, *id)
	//os.RemoveAll(graphDir)

	now := time.Now()
	prover = NewProver(pk, index, name, graphDir)
	fmt.Printf("%d. Graph gen: %fs\n", index, time.Since(now).Seconds())

	now = time.Now()
	commit := prover.Init()
	fmt.Printf("%d. Graph commit: %fs\n", index, time.Since(now).Seconds())

	root := commit.Commit
	verifier = NewVerifier(pk, index, beta, root)

	os.Exit(m.Run())
}
开发者ID:kwonalbert,项目名称:spacemint,代码行数:26,代码来源:pos_test.go

示例6: TestMain

// The TestMain function creates a go command for testing purposes and
// deletes it after the tests have been run.
func TestMain(m *testing.M) {
	flag.Parse()

	if canRun {
		// We give the executable a .exe extension because Windows.
		out, err := exec.Command("go", "build", "-tags", "testgo", "-o", "testgo.exe").CombinedOutput()
		if err != nil {
			fmt.Fprintf(os.Stderr, "building testgo failed: %v\n%s", err, out)
			os.Exit(2)
		}
	}

	// Don't let these environment variables confuse the test.
	os.Unsetenv("GOBIN")
	os.Unsetenv("GOPATH")
	os.Unsetenv("GOROOT")

	r := m.Run()

	if canRun {
		os.Remove("testgo.exe")
	}

	os.Exit(r)
}
开发者ID:josharian,项目名称:go.ssa,代码行数:27,代码来源:go_test.go

示例7: TestMain

func TestMain(m *testing.M) {
	log.SetDebug(true)
	if err := os.Setenv("ABOT_DEBUG", "true"); err != nil {
		log.Fatal(err)
	}
	os.Exit(m.Run())
}
开发者ID:itsabot,项目名称:abot,代码行数:7,代码来源:timeparse_test.go

示例8: TestMain

func TestMain(m *testing.M) {
	// Reset this so it panics instead of exiting on Fatal messages
	logging.SetBackend(&fakeLogBackend{})
	server = httptest.NewServer(http.HandlerFunc(handler))
	defer server.Close()
	os.Exit(m.Run())
}
开发者ID:thought-machine,项目名称:please,代码行数:7,代码来源:update_test.go

示例9: TestMain

func TestMain(m *testing.M) {
	flag.Parse()
	//	os.RemoveAll(testPath)
	code := m.Run()
	os.RemoveAll(testPath)
	os.Exit(code)
}
开发者ID:cauequeiroz,项目名称:_sandbox,代码行数:7,代码来源:storage_test.go

示例10: TestMain

func TestMain(m *testing.M) {
	flag.Parse() // Do not remove this comment, import into google3 depends on it
	tabletserver.Init()

	exitCode := func() int {
		hdl, err := vttest.LaunchMySQL("vttest", schema, testing.Verbose())
		if err != nil {
			fmt.Fprintf(os.Stderr, "could not launch mysql: %v\n", err)
			return 1
		}
		defer hdl.TearDown()
		connParams, err = hdl.MySQLConnParams()
		if err != nil {
			fmt.Fprintf(os.Stderr, "could not fetch mysql params: %v\n", err)
			return 1
		}
		err = framework.StartDefaultServer(connParams)
		if err != nil {
			fmt.Fprintf(os.Stderr, "%v", err)
			return 1
		}
		defer framework.StopDefaultServer()

		err = initTableACL()
		if err != nil {
			fmt.Fprintf(os.Stderr, "%v", err)
			return 1
		}

		return m.Run()
	}()
	os.Exit(exitCode)
}
开发者ID:yab,项目名称:vitess,代码行数:33,代码来源:main_test.go

示例11: TestMain

func TestMain(m *testing.M) {
	flag.Parse()
	if flag.Lookup("test.short").Value.String() != "false" {
		quickCfg.MaxCount = 10
	}
	os.Exit(m.Run())
}
开发者ID:escribano,项目名称:syncthing,代码行数:7,代码来源:protocol_test.go

示例12: TestMain

func TestMain(m *testing.M) {
	server = httptest.NewServer(routes.Index{option.Options{}})
	client = &http.Client{}
	code := m.Run()
	server.Close()
	os.Exit(code)
}
开发者ID:go-microservices,项目名称:policies,代码行数:7,代码来源:index_test.go

示例13: TestMain

func TestMain(m *testing.M) {
	log.SetLevel(log.DebugLevel)

	retCode := m.Run()

	os.Exit(retCode)
}
开发者ID:ello,项目名称:streams,代码行数:7,代码来源:roshi_test.go

示例14: testForAll

func testForAll(m *testing.M) int {
	os.Setenv("AUTH_MODE", "db_auth")
	initDatabaseForTest()
	clearUp(username)

	return m.Run()
}
开发者ID:vmware,项目名称:harbor,代码行数:7,代码来源:dao_test.go

示例15: TestMain

func TestMain(m *testing.M) {
	var logLevel log.LogLevel

	logLevel = 0
	// logLevel = 1
	// logLevel = 3

	log.SetLoggers(logLevel, os.Stdout, os.Stderr)

	if err := testsInit(); err != nil {
		logger.Errorln(err)
		os.Exit(1)
	}

	exitCode := m.Run()

	if os.Getenv("TEST_IN_CIRCLE") != "true" {
		if err := testsTearDown(); err != nil {
			logger.Errorln(err)
			log.Flush()
			os.Exit(1)
		}
	}

	os.Exit(exitCode)
}
开发者ID:alexandrev,项目名称:eris-cli,代码行数:26,代码来源:migrate_dirs_test.go


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