本文整理汇总了Golang中internal/testenv.Builder函数的典型用法代码示例。如果您正苦于以下问题:Golang Builder函数的具体用法?Golang Builder怎么用?Golang Builder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Builder函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestWriterBig
func TestWriterBig(t *testing.T) {
for i, fn := range filenames {
testFileLevelDict(t, fn, DefaultCompression, "")
testFileLevelDict(t, fn, NoCompression, "")
for level := BestSpeed; level <= BestCompression; level++ {
testFileLevelDict(t, fn, level, "")
if level >= 1 && testing.Short() && testenv.Builder() == "" {
break
}
}
if i == 0 && testing.Short() && testenv.Builder() == "" {
break
}
}
}
示例2: TestGZIPFilesHaveZeroMTimes
// Per golang.org/issue/14937, check that every .gz file
// in the tree has a zero mtime.
func TestGZIPFilesHaveZeroMTimes(t *testing.T) {
if testing.Short() && testenv.Builder() == "" {
t.Skip("skipping in short mode")
}
var files []string
err := filepath.Walk(runtime.GOROOT(), func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() && strings.HasSuffix(path, ".gz") {
files = append(files, path)
}
return nil
})
if err != nil {
if os.IsNotExist(err) {
t.Skipf("skipping: GOROOT directory not found: %s", runtime.GOROOT())
}
t.Fatal("error collecting list of .gz files in GOROOT: ", err)
}
if len(files) == 0 {
t.Fatal("expected to find some .gz files under GOROOT")
}
for _, path := range files {
checkZeroMTime(t, path)
}
}
示例3: TestWriterDict
func TestWriterDict(t *testing.T) {
const dictionary = "0123456789."
for i, fn := range filenames {
testFileLevelDict(t, fn, DefaultCompression, dictionary)
testFileLevelDict(t, fn, NoCompression, dictionary)
for level := BestSpeed; level <= BestCompression; level++ {
testFileLevelDict(t, fn, level, dictionary)
if level >= 1 && testing.Short() && testenv.Builder() == "" {
break
}
}
if i == 0 && testing.Short() && testenv.Builder() == "" {
break
}
}
}
示例4: TestLookupGmailNS
func TestLookupGmailNS(t *testing.T) {
if testenv.Builder() == "" {
testenv.MustHaveExternalNetwork(t)
}
if !supportsIPv4 || !*testIPv4 {
t.Skip("IPv4 is required")
}
for _, tt := range lookupGmailNSTests {
nss, err := LookupNS(tt.name)
if err != nil {
testenv.SkipFlakyNet(t)
t.Fatal(err)
}
if len(nss) == 0 {
t.Error("got no record")
}
for _, ns := range nss {
if !strings.HasSuffix(ns.Host, tt.host) {
t.Errorf("got %v; want a record containing %s", ns, tt.host)
}
}
}
}
示例5: TestLookupGoogleSRV
func TestLookupGoogleSRV(t *testing.T) {
if testenv.Builder() == "" {
testenv.MustHaveExternalNetwork(t)
}
if !supportsIPv4 || !*testIPv4 {
t.Skip("IPv4 is required")
}
for _, tt := range lookupGoogleSRVTests {
cname, srvs, err := LookupSRV(tt.service, tt.proto, tt.name)
if err != nil {
testenv.SkipFlakyNet(t)
t.Fatal(err)
}
if len(srvs) == 0 {
t.Error("got no record")
}
if !strings.HasSuffix(cname, tt.cname) {
t.Errorf("got %s; want %s", cname, tt.cname)
}
for _, srv := range srvs {
if !strings.HasSuffix(srv.Target, tt.target) {
t.Errorf("got %v; want a record containing %s", srv, tt.target)
}
}
}
}
示例6: TestOver65kFiles
func TestOver65kFiles(t *testing.T) {
if testing.Short() && testenv.Builder() == "" {
t.Skip("skipping in short mode")
}
buf := new(bytes.Buffer)
w := NewWriter(buf)
const nFiles = (1 << 16) + 42
for i := 0; i < nFiles; i++ {
_, err := w.CreateHeader(&FileHeader{
Name: fmt.Sprintf("%d.dat", i),
Method: Store, // avoid Issue 6136 and Issue 6138
})
if err != nil {
t.Fatalf("creating file %d: %v", i, err)
}
}
if err := w.Close(); err != nil {
t.Fatalf("Writer.Close: %v", err)
}
s := buf.String()
zr, err := NewReader(strings.NewReader(s), int64(len(s)))
if err != nil {
t.Fatalf("NewReader: %v", err)
}
if got := len(zr.File); got != nFiles {
t.Fatalf("File contains %d files, want %d", got, nFiles)
}
for i := 0; i < nFiles; i++ {
want := fmt.Sprintf("%d.dat", i)
if zr.File[i].Name != want {
t.Fatalf("File(%d) = %q, want %q", i, zr.File[i].Name, want)
}
}
}
示例7: bench
func bench(b *testing.B, size int, algo func(Interface), name string) {
if stringspkg.HasSuffix(testenv.Builder(), "-race") && size > 1e4 {
b.Skip("skipping slow benchmark on race builder")
}
b.StopTimer()
data := make(intPairs, size)
x := ^uint32(0)
for i := 0; i < b.N; i++ {
for n := size - 3; n <= size+3; n++ {
for i := 0; i < len(data); i++ {
x += x
x ^= 1
if int32(x) < 0 {
x ^= 0x88888eef
}
data[i].a = int(x % uint32(n/5))
}
data.initB()
b.StartTimer()
algo(data)
b.StopTimer()
if !IsSorted(data) {
b.Errorf("%s did not sort %d ints", name, n)
}
if name == "Stable" && !data.inOrder() {
b.Errorf("%s unstable on %d ints", name, n)
}
}
}
}
示例8: TestDialerDualStack
func TestDialerDualStack(t *testing.T) {
// This test is known to be flaky. Don't frighten regular
// users about it; only fail on the build dashboard.
if testenv.Builder() == "" {
testenv.SkipFlaky(t, 13324)
}
if !supportsIPv4 || !supportsIPv6 {
t.Skip("both IPv4 and IPv6 are required")
}
closedPortDelay, expectClosedPortDelay := dialClosedPort()
if closedPortDelay > expectClosedPortDelay {
t.Errorf("got %v; want <= %v", closedPortDelay, expectClosedPortDelay)
}
origTestHookLookupIP := testHookLookupIP
defer func() { testHookLookupIP = origTestHookLookupIP }()
testHookLookupIP = lookupLocalhost
handler := func(dss *dualStackServer, ln Listener) {
for {
c, err := ln.Accept()
if err != nil {
return
}
c.Close()
}
}
var timeout = 150*time.Millisecond + closedPortDelay
for _, dualstack := range []bool{false, true} {
dss, err := newDualStackServer()
if err != nil {
t.Fatal(err)
}
defer dss.teardown()
if err := dss.buildup(handler); err != nil {
t.Fatal(err)
}
d := &Dialer{DualStack: dualstack, Timeout: timeout}
for range dss.lns {
c, err := d.Dial("tcp", JoinHostPort("localhost", dss.port))
if err != nil {
t.Error(err)
continue
}
switch addr := c.LocalAddr().(*TCPAddr); {
case addr.IP.To4() != nil:
dss.teardownNetwork("tcp4")
case addr.IP.To16() != nil && addr.IP.To4() == nil:
dss.teardownNetwork("tcp6")
}
c.Close()
}
}
}
示例9: TestStdFixed
func TestStdFixed(t *testing.T) {
testenv.MustHaveGoBuild(t)
if testing.Short() && testenv.Builder() == "" {
t.Skip("skipping in short mode")
}
testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "fixedbugs"),
"bug248.go", "bug302.go", "bug369.go", // complex test instructions - ignore
"issue6889.go", // gc-specific test
"issue7746.go", // large constants - consumes too much memory
"issue11362.go", // canonical import path check
)
}
示例10: TestDeflateInflateString
func TestDeflateInflateString(t *testing.T) {
if testing.Short() && testenv.Builder() == "" {
t.Skip("skipping in short mode")
}
for _, test := range deflateInflateStringTests {
gold, err := ioutil.ReadFile(test.filename)
if err != nil {
t.Error(err)
}
testToFromWithLimit(t, gold, test.label, test.limit)
if testing.Short() {
break
}
}
}
示例11: TestStdFixed
func TestStdFixed(t *testing.T) {
testenv.MustHaveGoBuild(t)
if testing.Short() && testenv.Builder() == "" {
t.Skip("skipping in short mode")
}
testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "fixedbugs"),
"bug248.go", "bug302.go", "bug369.go", // complex test instructions - ignore
"issue6889.go", // gc-specific test
"issue7746.go", // large constants - consumes too much memory
"issue11362.go", // canonical import path check
"issue15002.go", // uses Mmap; testTestDir should consult build tags
"issue16369.go", // go/types handles this correctly - not an issue
)
}
示例12: TestWriter
func TestWriter(t *testing.T) {
for _, filename := range filenames {
for _, order := range [...]Order{LSB, MSB} {
// The test data "2.71828 etcetera" is ASCII text requiring at least 6 bits.
for litWidth := 6; litWidth <= 8; litWidth++ {
if filename == "../testdata/gettysburg.txt" && litWidth == 6 {
continue
}
testFile(t, filename, order, litWidth)
}
}
if testing.Short() && testenv.Builder() == "" {
break
}
}
}
示例13: TestImportStdLib
func TestImportStdLib(t *testing.T) {
skipSpecialPlatforms(t)
// This package only handles gc export data.
if runtime.Compiler != "gc" {
t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
return
}
dt := maxTime
if testing.Short() && testenv.Builder() == "" {
dt = 10 * time.Millisecond
}
nimports := testDir(t, "", time.Now().Add(dt)) // installed packages
t.Logf("tested %d imports", nimports)
}
示例14: TestLookupDotsWithRemoteSource
func TestLookupDotsWithRemoteSource(t *testing.T) {
if testing.Short() && testenv.Builder() == "" || !*testExternal {
t.Skip("avoid external network")
}
if !supportsIPv4 || !*testIPv4 {
t.Skip("IPv4 is required")
}
if fixup := forceGoDNS(); fixup != nil {
testDots(t, "go")
fixup()
}
if fixup := forceCgoDNS(); fixup != nil {
testDots(t, "cgo")
fixup()
}
}
示例15: TestLookupIANACNAME
func TestLookupIANACNAME(t *testing.T) {
if testing.Short() && testenv.Builder() == "" || !*testExternal {
t.Skip("avoid external network")
}
if !supportsIPv4 || !*testIPv4 {
t.Skip("IPv4 is required")
}
for _, tt := range lookupIANACNAMETests {
cname, err := LookupCNAME(tt.name)
if err != nil {
t.Fatal(err)
}
if !strings.HasSuffix(cname, tt.cname) {
t.Errorf("got %s; want a record containing %s", cname, tt.cname)
}
}
}