Wrap testing.MainStart to work around upcoming signature change.
Go1.18 is changing the signature of testing.MainStart. To ensure compatibility, we wrap MainStart and different implementations for versions before/after Go1.18. PiperOrigin-RevId: 401362668
This commit is contained in:
parent
dd74503b8e
commit
d93c3c2eff
|
@ -5,7 +5,11 @@ package(licenses = ["notice"])
|
||||||
go_library(
|
go_library(
|
||||||
name = "lib",
|
name = "lib",
|
||||||
testonly = 1,
|
testonly = 1,
|
||||||
srcs = ["lib.go"],
|
srcs = [
|
||||||
|
"go_test_dependency_go118.go",
|
||||||
|
"go_test_dependency_not_go118.go",
|
||||||
|
"lib.go",
|
||||||
|
],
|
||||||
visibility = ["//test/runtimes/runner:__pkg__"],
|
visibility = ["//test/runtimes/runner:__pkg__"],
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/log",
|
"//pkg/log",
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
// Copyright 2021 The gVisor Authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build go1.18 && go1.1
|
||||||
|
// +build go1.18,go1.1
|
||||||
|
|
||||||
|
package lib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// mainStart wraps testing.MainStart for Go release == 1.18.
|
||||||
|
func mainStart(tests []testing.InternalTest) *testing.M {
|
||||||
|
return testing.MainStart(testDeps{}, tests, nil, nil, nil)
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright 2021 The gVisor Authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !go1.18 && go1.1
|
||||||
|
// +build !go1.18,go1.1
|
||||||
|
|
||||||
|
package lib
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
// mainStart wraps testing.MainStart for Go release < 1.18.
|
||||||
|
func mainStart(tests []testing.InternalTest) *testing.M {
|
||||||
|
return testing.MainStart(testDeps{}, tests, nil, nil)
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -63,8 +64,7 @@ func RunTests(lang, image, excludeFile string, batchSize int, timeout time.Durat
|
||||||
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
|
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
m := mainStart(tests)
|
||||||
m := testing.MainStart(testDeps{}, tests, nil, nil)
|
|
||||||
return m.Run()
|
return m.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,3 +197,21 @@ func (f testDeps) ImportPath() string { return "" }
|
||||||
func (f testDeps) StartTestLog(io.Writer) {}
|
func (f testDeps) StartTestLog(io.Writer) {}
|
||||||
func (f testDeps) StopTestLog() error { return nil }
|
func (f testDeps) StopTestLog() error { return nil }
|
||||||
func (f testDeps) SetPanicOnExit0(bool) {}
|
func (f testDeps) SetPanicOnExit0(bool) {}
|
||||||
|
func (f testDeps) CoordinateFuzzing(time.Duration, int64, time.Duration, int64, int, []corpusEntry, []reflect.Type, string, string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (f testDeps) RunFuzzWorker(func(corpusEntry) error) error { return nil }
|
||||||
|
func (f testDeps) ReadCorpus(string, []reflect.Type) ([]corpusEntry, error) { return nil, nil }
|
||||||
|
func (f testDeps) CheckCorpus([]interface{}, []reflect.Type) error { return nil }
|
||||||
|
func (f testDeps) ResetCoverage() {}
|
||||||
|
func (f testDeps) SnapshotCoverage() {}
|
||||||
|
|
||||||
|
// Copied from testing/fuzz.go.
|
||||||
|
type corpusEntry = struct {
|
||||||
|
Parent string
|
||||||
|
Name string
|
||||||
|
Data []byte
|
||||||
|
Values []interface{}
|
||||||
|
Generation int
|
||||||
|
IsSeed bool
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue