github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/cmd/teamcity-trigger/main_test.go (about) 1 // Copyright 2016 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package main 12 13 import ( 14 "fmt" 15 "sort" 16 "strings" 17 "testing" 18 ) 19 20 func TestRunTC(t *testing.T) { 21 count := 0 22 runTC(func(buildID string, opts map[string]string) { 23 count++ 24 if pkg, ok := opts["env.PKG"]; ok { 25 if strings.Contains(pkg, "/vendor/") { 26 t.Errorf("unexpected package %s", pkg) 27 } 28 } else { 29 t.Errorf("parameters did not include package: %+v", opts) 30 } 31 }) 32 if count == 0 { 33 t.Fatal("no builds were created") 34 } 35 } 36 37 func Example_runTC() { 38 // Shows sample output for two packages, one of which runs with reduced 39 // parallelism. 40 runTC(func(buildID string, opts map[string]string) { 41 pkg := opts["env.PKG"] 42 if !strings.HasSuffix(pkg, "pkg/sql/logictest") && !strings.HasSuffix(pkg, "pkg/storage") { 43 return 44 } 45 var keys []string 46 for k := range opts { 47 if k != "env.PKG" { 48 keys = append(keys, k) 49 } 50 } 51 sort.Strings(keys) 52 fmt.Println(pkg) 53 for _, k := range keys { 54 fmt.Printf(" %-16s %s\n", k+":", opts[k]) 55 } 56 fmt.Println() 57 }) 58 59 // Output: 60 // github.com/cockroachdb/cockroach/pkg/sql/logictest 61 // env.GOFLAGS: -parallel=2 62 // env.STRESSFLAGS: -p 2 63 // 64 // github.com/cockroachdb/cockroach/pkg/sql/logictest 65 // env.GOFLAGS: -race -parallel=1 66 // env.STRESSFLAGS: -p 1 67 // 68 // github.com/cockroachdb/cockroach/pkg/storage 69 // env.GOFLAGS: -parallel=4 70 // env.STRESSFLAGS: -p 4 71 // 72 // github.com/cockroachdb/cockroach/pkg/storage 73 // env.GOFLAGS: -race -parallel=2 74 // env.STRESSFLAGS: -p 2 75 }