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