本文整理汇总了Golang中testing.M.Run方法的典型用法代码示例。如果您正苦于以下问题:Golang M.Run方法的具体用法?Golang M.Run怎么用?Golang M.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testing.M
的用法示例。
在下文中一共展示了M.Run方法的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)
}
示例2: TestMain
func TestMain(m *testing.M) {
p, err = New("./test")
defer os.Remove("./test")
m.Run()
p.Close()
}
示例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)
}
示例4: 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())
}
示例5: 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)
}
示例6: 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())
}
示例7: 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())
}
示例8: TestMain
func TestMain(m *testing.M) {
flag.Parse()
// os.RemoveAll(testPath)
code := m.Run()
os.RemoveAll(testPath)
os.Exit(code)
}
示例9: 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)
}
示例10: TestMain
func TestMain(m *testing.M) {
flag.Parse()
if flag.Lookup("test.short").Value.String() != "false" {
quickCfg.MaxCount = 10
}
os.Exit(m.Run())
}
示例11: TestMain
func TestMain(m *testing.M) {
server = httptest.NewServer(routes.Index{option.Options{}})
client = &http.Client{}
code := m.Run()
server.Close()
os.Exit(code)
}
示例12: TestMain
func TestMain(m *testing.M) {
log.SetLevel(log.DebugLevel)
retCode := m.Run()
os.Exit(retCode)
}
示例13: testForAll
func testForAll(m *testing.M) int {
os.Setenv("AUTH_MODE", "db_auth")
initDatabaseForTest()
clearUp(username)
return m.Run()
}
示例14: 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)
}
示例15: TestMain
func TestMain(m *testing.M) {
createTestDB()
c := m.Run()
deleteTestDB()
os.Exit(c)
}