本文整理汇总了Golang中go/skia/org/infra/go/common.Init函数的典型用法代码示例。如果您正苦于以下问题:Golang Init函数的具体用法?Golang Init怎么用?Golang Init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
defer common.LogPanic()
common.Init()
if flag.NArg() != 2 {
log.Fatal("Usage: imagediff [--out filename] imagepath1.png imagepath2.png\n")
}
a, err := diff.OpenImage(flag.Arg(0))
if err != nil {
log.Fatal(err)
}
b, err := diff.OpenImage(flag.Arg(1))
if err != nil {
log.Fatal(err)
}
metrics, d := diff.Diff(a, b)
fmt.Printf("Dimensions are different: %v\n", metrics.DimDiffer)
fmt.Printf("Number of pixels different: %v\n", metrics.NumDiffPixels)
fmt.Printf("Pixel diff percent: %v\n", metrics.PixelDiffPercent)
if *out == "" {
return
} else {
fmt.Println("Writing image diff.")
}
f, err := os.Create(*out)
if err != nil {
log.Fatal(err)
}
if err := png.Encode(f, d); err != nil {
log.Fatal(err)
}
}
开发者ID:saltmueller,项目名称:skia-buildbot,代码行数:31,代码来源:main.go
示例2: main
func main() {
defer common.LogPanic()
common.Init()
if logDirFlag := flag.Lookup("log_dir"); logDirFlag != nil {
logDir = logDirFlag.Value.String()
}
if *dryRun {
exec.SetRunForTesting(func(command *exec.Command) error {
glog.Infof("dry_run: %s", exec.DebugString(command))
return nil
})
}
if *local {
frontend.InitForTesting("http://localhost:8000/")
} else {
frontend.MustInit()
}
workerHealthTick := time.Tick(*workerHealthCheckInterval)
pollTick := time.Tick(*pollInterval)
// Run immediately, since pollTick will not fire until after pollInterval.
pollAndExecOnce()
for {
select {
case <-workerHealthTick:
doWorkerHealthCheck()
case <-pollTick:
pollAndExecOnce()
}
}
}
开发者ID:Tiger66639,项目名称:skia-buildbot,代码行数:33,代码来源:main.go
示例3: main
func main() {
defer common.LogPanic()
common.Init()
args := flag.Args()
if len(args) != 2 {
flag.Usage()
os.Exit(1)
}
bucket, prefix := args[0], args[1]
v, err := skiaversion.GetVersion()
if err != nil {
glog.Fatal(err)
}
glog.Infof("Version %s, built at %s", v.Commit, v.Date)
if *nsqdAddress == "" {
glog.Fatal("Missing address of nsqd server.")
}
globalEventBus, err := geventbus.NewNSQEventBus(*nsqdAddress)
if err != nil {
glog.Fatalf("Unable to connect to NSQ server: %s", err)
}
eventBus := eventbus.New(globalEventBus)
eventBus.SubscribeAsync(event.StorageEvent(bucket, prefix), func(evData interface{}) {
data := evData.(*event.GoogleStorageEventData)
glog.Infof("Google Storage notification from bucket\n %s: %s : %s", data.Updated, data.Bucket, data.Name)
})
select {}
}
开发者ID:saltmueller,项目名称:skia-buildbot,代码行数:33,代码来源:main.go
示例4: main
func main() {
common.Init()
v, err := skiaversion.GetVersion()
if err != nil {
glog.Fatal(err)
}
glog.Infof("Version %s, built at %s", v.Commit, v.Date)
if *nsqdAddress == "" {
glog.Fatal("Missing address of nsqd server.")
}
globalEventBus, err := geventbus.NewNSQEventBus(*nsqdAddress)
if err != nil {
glog.Fatalf("Unable to connect to NSQ server: %s", err)
}
eventBus := eventbus.New(globalEventBus)
// Send events every so often.
for _ = range time.Tick(2 * time.Second) {
evData := &event.GoogleStorageEventData{
Bucket: "test-bucket",
Name: "test-name",
Updated: time.Now().String(),
}
eventBus.Publish(event.GLOBAL_GOOGLE_STORAGE, evData)
glog.Infof("Sent Event: %#v ", evData)
}
}
开发者ID:kleopatra999,项目名称:skia-buildbot,代码行数:31,代码来源:main.go
示例5: main
func main() {
flag.Usage = printUsage
common.Init()
args := flag.Args()
if len(args) == 0 {
printUsage()
os.Exit(1)
}
store := filetilestore.NewFileTileStore(*tileDir, *dataset, 0)
switch args[0] {
case VALIDATE:
if !validator.ValidateDataset(store, *verbose, *echoHashes) {
glog.Fatal("FAILED Validation.")
}
case DUMP_COMMITS:
checkArgs(args, DUMP_COMMITS, 1)
nCommits := parseInt(args[1])
dumpCommits(store, nCommits)
case MD5:
checkArgs(args, MD5, 2)
hash := args[1]
nCommits := parseInt(args[2])
md5Commits(store, hash, nCommits)
case JSON:
checkArgs(args, JSON, 3)
nCommits := parseInt(args[1])
nTraces := parseInt(args[2])
fname := args[3]
dumpTileToJSON(store, nCommits, nTraces, fname)
default:
glog.Fatalf("Unknow command: %s", args[0])
}
}
开发者ID:kleopatra999,项目名称:skia-buildbot,代码行数:35,代码来源:main.go
示例6: main
func main() {
// Set up flags.
dbConf := database.ConfigFromFlags(buildbot.PROD_DB_HOST, buildbot.PROD_DB_PORT, database.USER_ROOT, buildbot.PROD_DB_NAME, buildbot.MigrationSteps())
// Global init to initialize glog and parse arguments.
common.Init()
if err := dbConf.PromptForPassword(); err != nil {
glog.Fatal(err)
}
vdb, err := dbConf.NewVersionedDB()
if err != nil {
glog.Fatal(err)
}
// Get the current database version
maxDBVersion := vdb.MaxDBVersion()
glog.Infof("Latest database version: %d", maxDBVersion)
dbVersion, err := vdb.DBVersion()
if err != nil {
glog.Fatalf("Unable to retrieve database version. Error: %s", err)
}
glog.Infof("Current database version: %d", dbVersion)
if dbVersion < maxDBVersion {
glog.Infof("Migrating to version: %d", maxDBVersion)
err = vdb.Migrate(maxDBVersion)
if err != nil {
glog.Fatalf("Unable to retrieve database version. Error: %s", err)
}
}
glog.Infoln("Database migration finished.")
}
开发者ID:kleopatra999,项目名称:skia-buildbot,代码行数:35,代码来源:main.go
示例7: main
func main() {
defer common.LogPanic()
common.Init()
args := flag.Args()
if len(args) != 3 {
glog.Errorf("Expected arguments: branch target buildID")
glog.Errorf("i.e.: git_master-skia razor-userdebug 1772442")
os.Exit(1)
}
// Set the arguments necessary to lookup the git hash.
branch := args[0]
target := args[1]
buildID := args[2]
glog.Infof("Branch, target, buildID: %s, %s, %s", branch, target, buildID)
// Set up the oauth client.
var client *http.Client
var err error
// In this case we don't want a backoff transport since the Apiary backend
// seems to fail a lot, so we basically want to fall back to polling if a
// call fails.
transport := &http.Transport{
Dial: util.DialTimeout,
}
if *local {
// Use a local client secret file to load data.
client, err = auth.InstalledAppClient(OAUTH_CACHE_FILEPATH, CLIENT_SECRET_FILEPATH,
transport,
androidbuildinternal.AndroidbuildInternalScope,
storage.CloudPlatformScope)
if err != nil {
glog.Fatalf("Unable to create installed app oauth client:%s", err)
}
} else {
// Use compute engine service account.
client = auth.GCEServiceAccountClient(transport)
}
f, err := androidbuild.New("/tmp/android-gold-ingest", client)
if err != nil {
glog.Fatalf("Failed to construct client: %s", err)
}
for {
r, err := f.Get(branch, target, buildID)
if err != nil {
glog.Errorf("Failed to get requested info: %s", err)
time.Sleep(1 * time.Minute)
continue
}
if r != nil {
glog.Infof("Successfully found: %#v", *r)
}
time.Sleep(1 * time.Minute)
}
}
开发者ID:Tiger66639,项目名称:skia-buildbot,代码行数:60,代码来源:main.go
示例8: main
func main() {
rand.Seed(time.Now().Unix())
// Grab the first argument off of os.Args, the command, before we call flag.Parse.
if len(os.Args) < 2 {
Usage()
return
}
cmd := os.Args[1]
os.Args = append([]string{os.Args[0]}, os.Args[2:]...)
// Now parge the flags.
common.Init()
// Set up a connection to the server.
conn, err := grpc.Dial(*address, grpc.WithInsecure())
if err != nil {
glog.Fatalf("did not connect: %v", err)
}
defer util.Close(conn)
client := traceservice.NewTraceServiceClient(conn)
switch cmd {
case "ls":
list(client)
case "ping":
ping(client)
case "count":
count(client)
case "sample":
sample(client)
default:
fmt.Printf("Unknown command: %s\n", cmd)
Usage()
}
}
开发者ID:saltmueller,项目名称:skia-buildbot,代码行数:35,代码来源:main.go
示例9: main
func main() {
common.Init()
args := flag.Args()
if err := RunApp(ADBFromFlags(), *app, args); err != nil {
glog.Fatal(err)
}
}
开发者ID:keinvo,项目名称:skia,代码行数:7,代码来源:android_run_app.go
示例10: main
func main() {
defer common.LogPanic()
common.Init()
if *emailTokenPath == "" {
glog.Error("Must specify --email_token_path")
return
}
defer glog.Flush()
for _, shiftType := range allShiftTypes {
res, err := http.Get(shiftType.nextSheriffEndpoint)
if err != nil {
glog.Fatalf("Could not HTTP Get: %s", err)
}
defer util.Close(res.Body)
var jsonType map[string]interface{}
if err := json.NewDecoder(res.Body).Decode(&jsonType); err != nil {
glog.Fatalf("Could not unmarshal JSON: %s", err)
}
sheriffEmail, _ := jsonType["username"].(string)
if sheriffEmail == NO_SHERIFF {
glog.Infof("Skipping emailing %s because %s was specified", shiftType.shiftName, NO_SHERIFF)
continue
}
sheriffUsername := strings.Split(string(sheriffEmail), "@")[0]
emailTemplateParsed := template.Must(template.New("sheriff_email").Parse(EMAIL_TEMPLATE))
emailBytes := new(bytes.Buffer)
if err := emailTemplateParsed.Execute(emailBytes, struct {
SheriffName string
SheriffType string
SheriffSchedules string
SheriffDoc string
ScheduleStart string
ScheduleEnd string
}{
SheriffName: sheriffUsername,
SheriffType: shiftType.shiftName,
SheriffSchedules: shiftType.schedulesLink,
SheriffDoc: shiftType.documentationLink,
ScheduleStart: jsonType["schedule_start"].(string),
ScheduleEnd: jsonType["schedule_end"].(string),
}); err != nil {
glog.Errorf("Failed to execute template: %s", err)
return
}
emailSubject := fmt.Sprintf("%s is the next %s", sheriffUsername, shiftType.shiftName)
if err := sendEmail([]string{sheriffEmail, EXTRA_RECIPIENT}, emailSubject, emailBytes.String()); err != nil {
glog.Fatalf("Error sending email to sheriff: %s", err)
}
}
}
开发者ID:saltmueller,项目名称:skia-buildbot,代码行数:57,代码来源:main.go
示例11: main
func main() {
common.Init()
out, err := util.SSH(*cmd, util.Slaves, *timeout)
if err != nil {
glog.Fatal(err)
}
if *printOutput {
for k, v := range out {
fmt.Printf("\n=====%s=====\n%s\n", k, v)
}
}
}
开发者ID:kleopatra999,项目名称:skia-buildbot,代码行数:12,代码来源:main.go
示例12: main
func main() {
defer common.LogPanic()
// Set up flags.
dbConf := db.DBConfigFromFlags()
// Global init to initialize glog and parse arguments.
common.Init()
if *promptPassword {
if err := dbConf.PromptForPassword(); err != nil {
glog.Fatal(err)
}
}
if !*local {
if err := dbConf.GetPasswordFromMetadata(); err != nil {
glog.Fatal(err)
}
}
vdb, err := dbConf.NewVersionedDB()
if err != nil {
glog.Fatal(err)
}
if *targetVersion < 0 {
// Get the current database version
maxDBVersion := vdb.MaxDBVersion()
glog.Infof("Latest database version: %d", maxDBVersion)
dbVersion, err := vdb.DBVersion()
if err != nil {
glog.Fatalf("Unable to retrieve database version. Error: %s", err)
}
glog.Infof("Current database version: %d", dbVersion)
if dbVersion < maxDBVersion {
glog.Infof("Migrating to version: %d", maxDBVersion)
err = vdb.Migrate(maxDBVersion)
if err != nil {
glog.Fatalf("Unable to retrieve database version. Error: %s", err)
}
}
} else {
glog.Infof("Migrating to version: %d", *targetVersion)
err = vdb.Migrate(*targetVersion)
if err != nil {
glog.Fatalf("Unable to retrieve database version. Error: %s", err)
}
}
glog.Infoln("Database migration finished.")
}
开发者ID:saltmueller,项目名称:skia-buildbot,代码行数:50,代码来源:main.go
示例13: main
func main() {
common.Init()
grpclog.Init()
// Load the 0,-1 tile.
tilestore := filetilestore.NewFileTileStore(*tilestore, *dataset, time.Hour)
tile, err := tilestore.Get(0, -1)
if err != nil {
glog.Fatalf("Failed to load tile: %s", err)
}
// Trim to the last 50 commits.
begin := 0
end := tile.LastCommitIndex()
if end >= 49 {
begin = end - 49
}
glog.Infof("Loaded Tile")
tile, err = tile.Trim(begin, end)
// Set up a connection to the server.
conn, err := grpc.Dial(*address, grpc.WithInsecure())
if err != nil {
glog.Fatalf("did not connect: %v", err)
}
defer util.Close(conn)
// Build a TraceService client.
builder := ptypes.PerfTraceBuilder
if *gold {
builder = types.GoldenTraceBuilder
}
ts, err := db.NewTraceServiceDB(conn, builder)
if err != nil {
log.Fatalf("Failed to create db.DB: %s", err)
}
glog.Infof("Opened tracedb")
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
glog.Fatalf("Failed to open profiling file: %s", err)
}
if err := pprof.StartCPUProfile(f); err != nil {
glog.Fatalf("Failed to start profiling: %s", err)
}
defer pprof.StopCPUProfile()
_main(tile, ts)
} else {
_main(tile, ts)
}
}
开发者ID:1394,项目名称:skia-buildbot,代码行数:50,代码来源:main.go
示例14: main
func main() {
defer common.LogPanic()
common.Init()
frontend.MustInit()
// Send start email.
emailsArr := util.ParseEmails(*emails)
emailsArr = append(emailsArr, util.CtAdmins...)
if len(emailsArr) == 0 {
glog.Error("At least one email address must be specified")
return
}
skutil.LogErr(frontend.UpdateWebappTaskSetStarted(&admin_tasks.RecreateWebpageArchivesUpdateVars{}, *gaeTaskID))
skutil.LogErr(util.SendTaskStartEmail(emailsArr, "Capture archives", util.GetMasterLogLink(*runID), ""))
// Ensure webapp is updated and completion email is sent even if task fails.
defer updateWebappTask()
defer sendEmail(emailsArr)
// Cleanup tmp files after the run.
defer util.CleanTmpDir()
// Finish with glog flush and how long the task took.
defer util.TimeTrack(time.Now(), "Capture archives on Workers")
defer glog.Flush()
if *pagesetType == "" {
glog.Error("Must specify --pageset_type")
return
}
if *chromiumBuild == "" {
glog.Error("Must specify --chromium_build")
return
}
cmd := []string{
fmt.Sprintf("cd %s;", util.CtTreeDir),
"git pull;",
"make all;",
// The main command that runs capture_archives on all workers.
fmt.Sprintf("DISPLAY=:0 capture_archives --worker_num=%s --log_dir=%s --log_id=%s --pageset_type=%s --chromium_build=%s;", util.WORKER_NUM_KEYWORD, util.GLogDir, *runID, *pagesetType, *chromiumBuild),
}
_, err := util.SSH(strings.Join(cmd, " "), util.Slaves, util.CAPTURE_ARCHIVES_TIMEOUT)
if err != nil {
glog.Errorf("Error while running cmd %s: %s", cmd, err)
return
}
*taskCompletedSuccessfully = true
}
开发者ID:Tiger66639,项目名称:skia-buildbot,代码行数:47,代码来源:main.go
示例15: main
func main() {
defer common.LogPanic()
common.Init()
var err error
var wg sync.WaitGroup
// Make a channel to deliver work.
targetCh := make(chan Target)
// Record the latency measurements in millis for each request.
latencySamples := make([]float64, 0)
latencies := make(chan float64)
go func() {
for m := range latencies {
latencySamples = append(latencySamples, m)
}
}()
err = startWorkers(targetCh, latencies, &wg)
if err != nil {
log.Fatalf("Failure starting workers: %v\n", err)
}
b0 := time.Now()
// Pump requests out to all the workers to do.
for i := 0; i < *numFetches; i++ {
t := targets[rand.Int()%len(targets)]
targetCh <- t
}
close(targetCh)
// Wait for all HTTP requests to complete.
wg.Wait()
b1 := time.Now()
fmt.Print("\n")
fmt.Printf("Total time of run: %v\n", b1.Sub(b0))
fmt.Printf("Average QPS: %.2f\n", float64(*numFetches)/b1.Sub(b0).Seconds())
fmt.Println(NewSimpleStats(latencySamples, "Latency").String())
}
开发者ID:saltmueller,项目名称:skia-buildbot,代码行数:45,代码来源:main.go
示例16: main
func main() {
if len(os.Args) < 2 {
fmt.Println("Usage: query_issues <query> [OPTIONS]")
return
}
query := os.Args[1]
os.Args = append([]string{os.Args[0]}, os.Args[2:]...)
common.Init()
client, err := auth.NewDefaultJWTServiceAccountClient("https://www.googleapis.com/auth/userinfo.email")
if err != nil {
glog.Fatalf("Unable to create installed app oauth client:%s", err)
}
tracker := issues.NewMonorailIssueTracker(client)
iss, err := tracker.FromQuery(query)
if err != nil {
fmt.Printf("Failed to retrieve issues: %s\n", err)
return
}
fmt.Printf("Found: %d\n", len(iss))
for _, issue := range iss {
fmt.Printf("%20d %10s %s\n", issue.ID, issue.State, issue.Title)
}
}
开发者ID:saltmueller,项目名称:skia-buildbot,代码行数:23,代码来源:main.go
示例17: main
func main() {
defer common.LogPanic()
common.Init()
fileInfos, err := ioutil.ReadDir(".")
if err != nil {
glog.Fatalf("Unable to read directory.")
}
// Get the directory
for _, info := range fileInfos {
if info.IsDir() {
continue
}
fileName := info.Name()
outFileName := fileutil.TwoLevelRadixPath(fileName)
if fileName == outFileName {
glog.Infof("Excluding %s -> %s", fileName, outFileName)
continue
}
if !fileutil.FileExists(outFileName) {
// Create the path if it doesn't exist.
targetDir, _ := filepath.Split(outFileName)
if err = os.MkdirAll(targetDir, 0700); err != nil {
glog.Errorf("Unable to run create path: %s", targetDir)
}
if err := os.Rename(fileName, outFileName); err != nil {
glog.Errorf("Unable to run mv %s %s", fileName, outFileName)
}
}
}
}
开发者ID:saltmueller,项目名称:skia-buildbot,代码行数:37,代码来源:radix_dir.go
示例18: main
func main() {
defer common.LogPanic()
common.Init()
defer util.TimeTrack(time.Now(), "Creating Pagesets")
defer glog.Flush()
// Create the task file so that the master knows this worker is still busy.
skutil.LogErr(util.CreateTaskFile(util.ACTIVITY_CREATING_PAGESETS))
defer util.DeleteTaskFile(util.ACTIVITY_CREATING_PAGESETS)
// Delete and remake the local pagesets directory.
pathToPagesets := filepath.Join(util.PagesetsDir, *pagesetType)
skutil.RemoveAll(pathToPagesets)
skutil.MkdirAll(pathToPagesets, 0700)
// Get info about the specified pageset type.
pagesetTypeInfo := util.PagesetTypeToInfo[*pagesetType]
csvSource := pagesetTypeInfo.CSVSource
numPages := pagesetTypeInfo.NumPages
userAgent := pagesetTypeInfo.UserAgent
// Download the CSV file from Google Storage to a tmp location.
gs, err := util.NewGsUtil(nil)
if err != nil {
glog.Error(err)
return
}
respBody, err := gs.GetRemoteFileContents(csvSource)
if err != nil {
glog.Error(err)
return
}
defer skutil.Close(respBody)
csvFile := filepath.Join(os.TempDir(), filepath.Base(csvSource))
out, err := os.Create(csvFile)
if err != nil {
glog.Errorf("Unable to create file %s: %s", csvFile, err)
return
}
defer skutil.Close(out)
defer skutil.Remove(csvFile)
if _, err = io.Copy(out, respBody); err != nil {
glog.Error(err)
return
}
// Figure out which pagesets this worker should generate.
numPagesPerSlave := numPages / util.NUM_WORKERS
startNum := (*workerNum-1)*numPagesPerSlave + 1
endNum := *workerNum * numPagesPerSlave
// Construct path to the create_page_set.py python script.
_, currentFile, _, _ := runtime.Caller(0)
createPageSetScript := filepath.Join(
filepath.Dir((filepath.Dir(filepath.Dir(filepath.Dir(currentFile))))),
"py", "create_page_set.py")
// Execute the create_page_set.py python script.
timeoutSecs := util.PagesetTypeToInfo[*pagesetType].CreatePagesetsTimeoutSecs
for currNum := startNum; currNum <= endNum; currNum++ {
args := []string{
createPageSetScript,
"-s", strconv.Itoa(currNum),
"-e", strconv.Itoa(currNum),
"-c", csvFile,
"-p", *pagesetType,
"-u", userAgent,
"-o", pathToPagesets,
}
if err := util.ExecuteCmd("python", args, []string{}, time.Duration(timeoutSecs)*time.Second, nil, nil); err != nil {
glog.Error(err)
return
}
}
// Write timestamp to the pagesets dir.
skutil.LogErr(util.CreateTimestampFile(pathToPagesets))
// Upload pagesets dir to Google Storage.
if err := gs.UploadWorkerArtifacts(util.PAGESETS_DIR_NAME, *pagesetType, *workerNum); err != nil {
glog.Error(err)
return
}
}
开发者ID:Tiger66639,项目名称:skia-buildbot,代码行数:82,代码来源:main.go
示例19: Init
func Init() {
common.Init()
initRest()
}
开发者ID:saltmueller,项目名称:skia-buildbot,代码行数:4,代码来源:master_common.go
示例20: main
// Find and run tests.
func main() {
defer common.LogPanic()
common.Init()
defer timer.New("Finished").Stop()
_, filename, _, _ := runtime.Caller(0)
rootDir := path.Dir(filename)
// If we are running full tests make sure we have the latest
// pdfium_test installed.
if !*short {
glog.Info("Installing pdfium_test if necessary.")
pdfiumInstall := path.Join(rootDir, "pdfium", "install_pdfium.sh")
if err := exec.Command(pdfiumInstall).Run(); err != nil {
glog.Fatalf("Failed to install pdfium_test: %v", err)
}
glog.Info("Latest pdfium_test installed successfully.")
}
// Gather all of the tests to run.
glog.Info("Searching for tests.")
tests := []*test{}
// Search for Python tests in the repo.
if err := filepath.Walk(rootDir, func(p string, info os.FileInfo, err error) error {
basename := path.Base(p)
// Skip some directories.
if info.IsDir() {
for _, skip := range NO_CRAWL_DIR_NAMES {
if basename == skip {
return filepath.SkipDir
}
}
for _, skip := range NO_CRAWL_REL_PATHS {
if p == path.Join(rootDir, skip) {
return filepath.SkipDir
}
}
}
if strings.HasSuffix(basename, "_test.py") {
tests = append(tests, pythonTest(p))
}
return nil
}); err != nil {
glog.Fatal(err)
}
// Go tests.
for goDir, extraLog := range GO_TEST_DIRS_AND_VERBOSITY {
tests = append(tests, goTest(goDir, extraLog))
}
// Other tests.
tests = append(tests, cmdTest([]string{"go", "vet", "./..."}, ".", "go vet"))
tests = append(tests, cmdTest([]string{"errcheck", "go.skia.org/infra/..."}, ".", "errcheck"))
tests = append(tests, polylintTests()...)
goimportsCmd := []string{"goimports", "-l", "."}
tests = append(tests, &test{
Name: "goimports",
Cmd: strings.Join(goimportsCmd, " "),
run: func() (error, string) {
command := exec.Command(goimportsCmd[0], goimportsCmd[1:]...)
output, err := command.Output()
outStr := strings.Trim(string(output), "\n")
if err != nil {
if _, err2 := exec.LookPath(goimportsCmd[0]); err2 != nil {
return fmt.Errorf(ERR_NEED_INSTALL, goimportsCmd[0], err), outStr
}
return err, outStr
}
diffFiles := strings.Split(outStr, "\n")
if len(diffFiles) > 0 && !(len(diffFiles) == 1 && diffFiles[0] == "") {
return fmt.Errorf("goimports found diffs in the following files:\n - %s", strings.Join(diffFiles, ",\n - ")), outStr
}
return nil, ""
},
})
// Run the tests.
glog.Infof("Found %d tests.", len(tests))
var mutex sync.Mutex
errors := map[string]error{}
var wg sync.WaitGroup
for _, t := range tests {
wg.Add(1)
go func(t *test) {
defer wg.Done()
if err := t.Run(); err != nil {
mutex.Lock()
errors[t.Name] = err
mutex.Unlock()
}
}(t)
}
wg.Wait()
if len(errors) > 0 {
//.........这里部分代码省略.........
开发者ID:1394,项目名称:skia-buildbot,代码行数:101,代码来源:run_unittests.go
注:本文中的go/skia/org/infra/go/common.Init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论