go/packages: skip tests that link binaries in short mode

These tests together account for about 1s of running time on my
workstation. I expect that they are even slower on platforms that
require external linking, and likely more memory-intensive than most
of the other tests.

For golang/go#46764

Change-Id: Ic9607ac71bcfd617581c58cfffe3775e23cd3422
Reviewed-on: https://go-review.googlesource.com/c/tools/+/332351
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Bryan C. Mills 2021-07-01 16:21:39 -04:00
parent 8e32e9f144
commit e33c0f2934
3 changed files with 75 additions and 70 deletions

View File

@ -27,7 +27,7 @@ const (
)
func TestOverlayChangesPackageName(t *testing.T) {
testAllOrModules(t, testOverlayChangesPackageName)
testAllOrModulesParallel(t, testOverlayChangesPackageName)
}
func testOverlayChangesPackageName(t *testing.T, exporter packagestest.Exporter) {
log.SetFlags(log.Lshortfile)
@ -57,7 +57,7 @@ func testOverlayChangesPackageName(t *testing.T, exporter packagestest.Exporter)
log.SetFlags(0)
}
func TestOverlayChangesBothPackageNames(t *testing.T) {
testAllOrModules(t, testOverlayChangesBothPackageNames)
testAllOrModulesParallel(t, testOverlayChangesBothPackageNames)
}
func testOverlayChangesBothPackageNames(t *testing.T, exporter packagestest.Exporter) {
log.SetFlags(log.Lshortfile)
@ -106,7 +106,7 @@ func testOverlayChangesBothPackageNames(t *testing.T, exporter packagestest.Expo
log.SetFlags(0)
}
func TestOverlayChangesTestPackageName(t *testing.T) {
testAllOrModules(t, testOverlayChangesTestPackageName)
testAllOrModulesParallel(t, testOverlayChangesTestPackageName)
}
func testOverlayChangesTestPackageName(t *testing.T, exporter packagestest.Exporter) {
testenv.NeedsGo1Point(t, 16)
@ -163,7 +163,7 @@ func checkPkg(t *testing.T, p *packages.Package, id, name string, syntax int) bo
}
func TestOverlayXTests(t *testing.T) {
testAllOrModules(t, testOverlayXTests)
testAllOrModulesParallel(t, testOverlayXTests)
}
// This test checks the behavior of go/packages.Load with an overlaid
@ -247,7 +247,7 @@ func TestHello(t *testing.T) {
}
}
func TestOverlay(t *testing.T) { testAllOrModules(t, testOverlay) }
func TestOverlay(t *testing.T) { testAllOrModulesParallel(t, testOverlay) }
func testOverlay(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -315,7 +315,7 @@ func testOverlay(t *testing.T, exporter packagestest.Exporter) {
}
}
func TestOverlayDeps(t *testing.T) { testAllOrModules(t, testOverlayDeps) }
func TestOverlayDeps(t *testing.T) { testAllOrModulesParallel(t, testOverlayDeps) }
func testOverlayDeps(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -364,7 +364,7 @@ func testOverlayDeps(t *testing.T, exporter packagestest.Exporter) {
}
func TestNewPackagesInOverlay(t *testing.T) { testAllOrModules(t, testNewPackagesInOverlay) }
func TestNewPackagesInOverlay(t *testing.T) { testAllOrModulesParallel(t, testNewPackagesInOverlay) }
func testNewPackagesInOverlay(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{
{
@ -468,7 +468,7 @@ func testNewPackagesInOverlay(t *testing.T, exporter packagestest.Exporter) {
// Test that we can create a package and its test package in an overlay.
func TestOverlayNewPackageAndTest(t *testing.T) {
testAllOrModules(t, testOverlayNewPackageAndTest)
testAllOrModulesParallel(t, testOverlayNewPackageAndTest)
}
func testOverlayNewPackageAndTest(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{
@ -651,7 +651,7 @@ func TestOverlayGOPATHVendoring(t *testing.T) {
}
}
func TestContainsOverlay(t *testing.T) { testAllOrModules(t, testContainsOverlay) }
func TestContainsOverlay(t *testing.T) { testAllOrModulesParallel(t, testContainsOverlay) }
func testContainsOverlay(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -680,7 +680,7 @@ func testContainsOverlay(t *testing.T, exporter packagestest.Exporter) {
}
}
func TestContainsOverlayXTest(t *testing.T) { testAllOrModules(t, testContainsOverlayXTest) }
func TestContainsOverlayXTest(t *testing.T) { testAllOrModulesParallel(t, testContainsOverlayXTest) }
func testContainsOverlayXTest(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -713,7 +713,7 @@ func testContainsOverlayXTest(t *testing.T, exporter packagestest.Exporter) {
}
func TestInvalidFilesBeforeOverlay(t *testing.T) {
testAllOrModules(t, testInvalidFilesBeforeOverlay)
testAllOrModulesParallel(t, testInvalidFilesBeforeOverlay)
}
func testInvalidFilesBeforeOverlay(t *testing.T, exporter packagestest.Exporter) {
@ -753,7 +753,7 @@ func testInvalidFilesBeforeOverlay(t *testing.T, exporter packagestest.Exporter)
// Tests golang/go#35973, fixed in Go 1.14.
func TestInvalidFilesBeforeOverlayContains(t *testing.T) {
testAllOrModules(t, testInvalidFilesBeforeOverlayContains)
testAllOrModulesParallel(t, testInvalidFilesBeforeOverlayContains)
}
func testInvalidFilesBeforeOverlayContains(t *testing.T, exporter packagestest.Exporter) {
testenv.NeedsGo1Point(t, 15)
@ -860,7 +860,7 @@ func isTestVariant(libID, testID string) bool {
}
func TestInvalidXTestInGOPATH(t *testing.T) {
testAllOrModules(t, testInvalidXTestInGOPATH)
testAllOrModulesParallel(t, testInvalidXTestInGOPATH)
}
func testInvalidXTestInGOPATH(t *testing.T, exporter packagestest.Exporter) {
t.Skip("Not fixed yet. See golang.org/issue/40825.")
@ -893,7 +893,7 @@ func testInvalidXTestInGOPATH(t *testing.T, exporter packagestest.Exporter) {
// Reproduces golang/go#40685.
func TestAddImportInOverlay(t *testing.T) {
testAllOrModules(t, testAddImportInOverlay)
testAllOrModulesParallel(t, testAddImportInOverlay)
}
func testAddImportInOverlay(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{
@ -962,7 +962,7 @@ func _() {
// Tests that overlays are applied for different kinds of load patterns.
func TestLoadDifferentPatterns(t *testing.T) {
testAllOrModules(t, testLoadDifferentPatterns)
testAllOrModulesParallel(t, testLoadDifferentPatterns)
}
func testLoadDifferentPatterns(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{

View File

@ -54,9 +54,15 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}
// testAllOrModules tests f against all packagestest exporters in long mode,
// but only against the Modules exporter in short mode.
func testAllOrModules(t *testing.T, f func(*testing.T, packagestest.Exporter)) {
func skipIfShort(t *testing.T, reason string) {
if testing.Short() {
t.Skipf("skipping slow test in short mode: %s", reason)
}
}
// testAllOrModulesParallel tests f, in parallel, against all packagestest
// exporters in long mode, but only against the Modules exporter in short mode.
func testAllOrModulesParallel(t *testing.T, f func(*testing.T, packagestest.Exporter)) {
t.Parallel()
packagestest.TestAll(t, func(t *testing.T, exporter packagestest.Exporter) {
t.Helper()
@ -116,7 +122,7 @@ func TestLoadZeroConfig(t *testing.T) {
}
}
func TestLoadImportsGraph(t *testing.T) { testAllOrModules(t, testLoadImportsGraph) }
func TestLoadImportsGraph(t *testing.T) { testAllOrModulesParallel(t, testLoadImportsGraph) }
func testLoadImportsGraph(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -290,7 +296,9 @@ func testLoadImportsGraph(t *testing.T, exporter packagestest.Exporter) {
}
}
func TestLoadImportsTestVariants(t *testing.T) { testAllOrModules(t, testLoadImportsTestVariants) }
func TestLoadImportsTestVariants(t *testing.T) {
testAllOrModulesParallel(t, testLoadImportsTestVariants)
}
func testLoadImportsTestVariants(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -422,7 +430,7 @@ func imports(p *packages.Package) []string {
return keys
}
func TestConfigDir(t *testing.T) { testAllOrModules(t, testConfigDir) }
func TestConfigDir(t *testing.T) { testAllOrModulesParallel(t, testConfigDir) }
func testConfigDir(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -485,7 +493,7 @@ func testConfigDir(t *testing.T, exporter packagestest.Exporter) {
}
}
func TestConfigFlags(t *testing.T) { testAllOrModules(t, testConfigFlags) }
func TestConfigFlags(t *testing.T) { testAllOrModulesParallel(t, testConfigFlags) }
func testConfigFlags(t *testing.T, exporter packagestest.Exporter) {
// Test satisfying +build line tags, with -tags flag.
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -546,7 +554,7 @@ package b`,
}
}
func TestLoadTypes(t *testing.T) { testAllOrModules(t, testLoadTypes) }
func TestLoadTypes(t *testing.T) { testAllOrModulesParallel(t, testLoadTypes) }
func testLoadTypes(t *testing.T, exporter packagestest.Exporter) {
// In LoadTypes and LoadSyntax modes, the compiler will
// fail to generate an export data file for c, because it has
@ -604,7 +612,7 @@ func testLoadTypes(t *testing.T, exporter packagestest.Exporter) {
// TestLoadTypesBits is equivalent to TestLoadTypes except that it only requests
// the types using the NeedTypes bit.
func TestLoadTypesBits(t *testing.T) { testAllOrModules(t, testLoadTypesBits) }
func TestLoadTypesBits(t *testing.T) { testAllOrModulesParallel(t, testLoadTypesBits) }
func testLoadTypesBits(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -680,7 +688,7 @@ func testLoadTypesBits(t *testing.T, exporter packagestest.Exporter) {
}
}
func TestLoadSyntaxOK(t *testing.T) { testAllOrModules(t, testLoadSyntaxOK) }
func TestLoadSyntaxOK(t *testing.T) { testAllOrModulesParallel(t, testLoadSyntaxOK) }
func testLoadSyntaxOK(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -770,7 +778,7 @@ func testLoadSyntaxOK(t *testing.T, exporter packagestest.Exporter) {
}
}
func TestLoadDiamondTypes(t *testing.T) { testAllOrModules(t, testLoadDiamondTypes) }
func TestLoadDiamondTypes(t *testing.T) { testAllOrModulesParallel(t, testLoadDiamondTypes) }
func testLoadDiamondTypes(t *testing.T, exporter packagestest.Exporter) {
// We make a diamond dependency and check the type d.D is the same through both paths
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -810,7 +818,7 @@ func testLoadDiamondTypes(t *testing.T, exporter packagestest.Exporter) {
}
}
func TestLoadSyntaxError(t *testing.T) { testAllOrModules(t, testLoadSyntaxError) }
func TestLoadSyntaxError(t *testing.T) { testAllOrModulesParallel(t, testLoadSyntaxError) }
func testLoadSyntaxError(t *testing.T, exporter packagestest.Exporter) {
// A type error in a lower-level package (e) prevents go list
// from producing export data for all packages that depend on it
@ -886,7 +894,7 @@ func testLoadSyntaxError(t *testing.T, exporter packagestest.Exporter) {
// This function tests use of the ParseFile hook to modify
// the AST after parsing.
func TestParseFileModifyAST(t *testing.T) { testAllOrModules(t, testParseFileModifyAST) }
func TestParseFileModifyAST(t *testing.T) { testAllOrModulesParallel(t, testParseFileModifyAST) }
func testParseFileModifyAST(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -968,7 +976,7 @@ const A = 1
}
func TestLoadAllSyntaxImportErrors(t *testing.T) {
testAllOrModules(t, testLoadAllSyntaxImportErrors)
testAllOrModulesParallel(t, testLoadAllSyntaxImportErrors)
}
func testLoadAllSyntaxImportErrors(t *testing.T, exporter packagestest.Exporter) {
// TODO(matloob): Remove this once go list -e -compiled is fixed.
@ -1053,7 +1061,7 @@ import (
}
}
func TestAbsoluteFilenames(t *testing.T) { testAllOrModules(t, testAbsoluteFilenames) }
func TestAbsoluteFilenames(t *testing.T) { testAllOrModulesParallel(t, testAbsoluteFilenames) }
func testAbsoluteFilenames(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -1132,7 +1140,7 @@ func testAbsoluteFilenames(t *testing.T, exporter packagestest.Exporter) {
}
}
func TestContains(t *testing.T) { testAllOrModules(t, testContains) }
func TestContains(t *testing.T) { testAllOrModulesParallel(t, testContains) }
func testContains(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -1164,7 +1172,7 @@ func testContains(t *testing.T, exporter packagestest.Exporter) {
// application determines the Sizes function used by the type checker.
// This behavior is a stop-gap until we make the build system's query
// tool report the correct sizes function for the actual configuration.
func TestSizes(t *testing.T) { testAllOrModules(t, testSizes) }
func TestSizes(t *testing.T) { testAllOrModulesParallel(t, testSizes) }
func testSizes(t *testing.T, exporter packagestest.Exporter) {
// Only run this test on operating systems that have both an amd64 and 386 port.
switch runtime.GOOS {
@ -1201,7 +1209,9 @@ func testSizes(t *testing.T, exporter packagestest.Exporter) {
// TestContainsFallbackSticks ensures that when there are both contains and non-contains queries
// the decision whether to fallback to the pre-1.11 go list sticks across both sets of calls to
// go list.
func TestContainsFallbackSticks(t *testing.T) { testAllOrModules(t, testContainsFallbackSticks) }
func TestContainsFallbackSticks(t *testing.T) {
testAllOrModulesParallel(t, testContainsFallbackSticks)
}
func testContainsFallbackSticks(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -1234,7 +1244,7 @@ func testContainsFallbackSticks(t *testing.T, exporter packagestest.Exporter) {
// Test that Load with no patterns is equivalent to loading "." via the golist
// driver.
func TestNoPatterns(t *testing.T) { testAllOrModules(t, testNoPatterns) }
func TestNoPatterns(t *testing.T) { testAllOrModulesParallel(t, testNoPatterns) }
func testNoPatterns(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -1256,7 +1266,7 @@ func testNoPatterns(t *testing.T, exporter packagestest.Exporter) {
}
}
func TestJSON(t *testing.T) { testAllOrModules(t, testJSON) }
func TestJSON(t *testing.T) { testAllOrModulesParallel(t, testJSON) }
func testJSON(t *testing.T, exporter packagestest.Exporter) {
//TODO: add in some errors
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -1424,7 +1434,7 @@ func TestRejectInvalidQueries(t *testing.T) {
}
}
func TestPatternPassthrough(t *testing.T) { testAllOrModules(t, testPatternPassthrough) }
func TestPatternPassthrough(t *testing.T) { testAllOrModulesParallel(t, testPatternPassthrough) }
func testPatternPassthrough(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -1560,7 +1570,7 @@ EOF
// list. This would then cause a nil pointer crash.
// This bug was triggered by the simple package layout below, and thus this
// test will make sure the bug remains fixed.
func TestBasicXTest(t *testing.T) { testAllOrModules(t, testBasicXTest) }
func TestBasicXTest(t *testing.T) { testAllOrModulesParallel(t, testBasicXTest) }
func testBasicXTest(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -1578,7 +1588,7 @@ func testBasicXTest(t *testing.T, exporter packagestest.Exporter) {
}
}
func TestErrorMissingFile(t *testing.T) { testAllOrModules(t, testErrorMissingFile) }
func TestErrorMissingFile(t *testing.T) { testAllOrModulesParallel(t, testErrorMissingFile) }
func testErrorMissingFile(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -1605,7 +1615,7 @@ func testErrorMissingFile(t *testing.T, exporter packagestest.Exporter) {
}
func TestReturnErrorWhenUsingNonGoFiles(t *testing.T) {
testAllOrModules(t, testReturnErrorWhenUsingNonGoFiles)
testAllOrModulesParallel(t, testReturnErrorWhenUsingNonGoFiles)
}
func testReturnErrorWhenUsingNonGoFiles(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -1633,7 +1643,7 @@ func testReturnErrorWhenUsingNonGoFiles(t *testing.T, exporter packagestest.Expo
}
func TestReturnErrorWhenUsingGoFilesInMultipleDirectories(t *testing.T) {
testAllOrModules(t, testReturnErrorWhenUsingGoFilesInMultipleDirectories)
testAllOrModulesParallel(t, testReturnErrorWhenUsingGoFilesInMultipleDirectories)
}
func testReturnErrorWhenUsingGoFilesInMultipleDirectories(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -1665,7 +1675,7 @@ func testReturnErrorWhenUsingGoFilesInMultipleDirectories(t *testing.T, exporter
}
func TestReturnErrorForUnexpectedDirectoryLayout(t *testing.T) {
testAllOrModules(t, testReturnErrorForUnexpectedDirectoryLayout)
testAllOrModulesParallel(t, testReturnErrorForUnexpectedDirectoryLayout)
}
func testReturnErrorForUnexpectedDirectoryLayout(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -1695,7 +1705,7 @@ func testReturnErrorForUnexpectedDirectoryLayout(t *testing.T, exporter packages
}
}
func TestMissingDependency(t *testing.T) { testAllOrModules(t, testMissingDependency) }
func TestMissingDependency(t *testing.T) { testAllOrModulesParallel(t, testMissingDependency) }
func testMissingDependency(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -1717,7 +1727,7 @@ func testMissingDependency(t *testing.T, exporter packagestest.Exporter) {
}
}
func TestAdHocContains(t *testing.T) { testAllOrModules(t, testAdHocContains) }
func TestAdHocContains(t *testing.T) { testAllOrModulesParallel(t, testAdHocContains) }
func testAdHocContains(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -1759,7 +1769,7 @@ func testAdHocContains(t *testing.T, exporter packagestest.Exporter) {
}
}
func TestCgoNoCcompiler(t *testing.T) { testAllOrModules(t, testCgoNoCcompiler) }
func TestCgoNoCcompiler(t *testing.T) { testAllOrModulesParallel(t, testCgoNoCcompiler) }
func testCgoNoCcompiler(t *testing.T, exporter packagestest.Exporter) {
testenv.NeedsTool(t, "cgo")
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -1793,7 +1803,7 @@ const A = http.MethodGet
}
}
func TestCgoMissingFile(t *testing.T) { testAllOrModules(t, testCgoMissingFile) }
func TestCgoMissingFile(t *testing.T) { testAllOrModulesParallel(t, testCgoMissingFile) }
func testCgoMissingFile(t *testing.T, exporter packagestest.Exporter) {
testenv.NeedsTool(t, "cgo")
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -1880,7 +1890,7 @@ func TestLoadImportsC(t *testing.T) {
}
func TestCgoNoSyntax(t *testing.T) {
testAllOrModules(t, testCgoNoSyntax)
testAllOrModulesParallel(t, testCgoNoSyntax)
}
func testCgoNoSyntax(t *testing.T, exporter packagestest.Exporter) {
testenv.NeedsTool(t, "cgo")
@ -1922,9 +1932,10 @@ func testCgoNoSyntax(t *testing.T, exporter packagestest.Exporter) {
}
func TestCgoBadPkgConfig(t *testing.T) {
testAllOrModules(t, testCgoBadPkgConfig)
testAllOrModulesParallel(t, testCgoBadPkgConfig)
}
func testCgoBadPkgConfig(t *testing.T, exporter packagestest.Exporter) {
skipIfShort(t, "builds and links a fake pkgconfig binary")
testenv.NeedsTool(t, "cgo")
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -1994,7 +2005,7 @@ func main() {
return tmpdir
}
func TestIssue32814(t *testing.T) { testAllOrModules(t, testIssue32814) }
func TestIssue32814(t *testing.T) { testAllOrModulesParallel(t, testIssue32814) }
func testIssue32814(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
Name: "golang.org/fake",
@ -2022,7 +2033,7 @@ func testIssue32814(t *testing.T, exporter packagestest.Exporter) {
}
func TestLoadTypesInfoWithoutNeedDeps(t *testing.T) {
testAllOrModules(t, testLoadTypesInfoWithoutNeedDeps)
testAllOrModulesParallel(t, testLoadTypesInfoWithoutNeedDeps)
}
func testLoadTypesInfoWithoutNeedDeps(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -2049,7 +2060,7 @@ func testLoadTypesInfoWithoutNeedDeps(t *testing.T, exporter packagestest.Export
}
func TestLoadWithNeedDeps(t *testing.T) {
testAllOrModules(t, testLoadWithNeedDeps)
testAllOrModulesParallel(t, testLoadWithNeedDeps)
}
func testLoadWithNeedDeps(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -2093,7 +2104,7 @@ func testLoadWithNeedDeps(t *testing.T, exporter packagestest.Exporter) {
}
func TestImpliedLoadMode(t *testing.T) {
testAllOrModules(t, testImpliedLoadMode)
testAllOrModulesParallel(t, testImpliedLoadMode)
}
func testImpliedLoadMode(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -2131,7 +2142,7 @@ func testImpliedLoadMode(t *testing.T, exporter packagestest.Exporter) {
}
func TestIssue35331(t *testing.T) {
testAllOrModules(t, testIssue35331)
testAllOrModulesParallel(t, testIssue35331)
}
func testIssue35331(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -2161,7 +2172,7 @@ func testIssue35331(t *testing.T, exporter packagestest.Exporter) {
}
func TestMultiplePackageVersionsIssue36188(t *testing.T) {
testAllOrModules(t, testMultiplePackageVersionsIssue36188)
testAllOrModulesParallel(t, testMultiplePackageVersionsIssue36188)
}
func testMultiplePackageVersionsIssue36188(t *testing.T, exporter packagestest.Exporter) {
@ -2270,7 +2281,7 @@ func TestLoadModeStrings(t *testing.T) {
}
func TestCycleImportStack(t *testing.T) {
testAllOrModules(t, testCycleImportStack)
testAllOrModulesParallel(t, testCycleImportStack)
}
func testCycleImportStack(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -2300,7 +2311,7 @@ func testCycleImportStack(t *testing.T, exporter packagestest.Exporter) {
}
func TestForTestField(t *testing.T) {
testAllOrModules(t, testForTestField)
testAllOrModulesParallel(t, testForTestField)
}
func testForTestField(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -2346,7 +2357,7 @@ func testForTestField(t *testing.T, exporter packagestest.Exporter) {
}
func TestIssue37529(t *testing.T) {
testAllOrModules(t, testIssue37529)
testAllOrModulesParallel(t, testIssue37529)
}
func testIssue37529(t *testing.T, exporter packagestest.Exporter) {
// Tests #37529. When automatic vendoring is triggered, and we try to determine
@ -2386,7 +2397,7 @@ func testIssue37529(t *testing.T, exporter packagestest.Exporter) {
}
}
func TestIssue37098(t *testing.T) { testAllOrModules(t, testIssue37098) }
func TestIssue37098(t *testing.T) { testAllOrModulesParallel(t, testIssue37098) }
func testIssue37098(t *testing.T, exporter packagestest.Exporter) {
// packages.Load should only return Go sources in
// (*Package).CompiledGoFiles. This tests #37098, where using SWIG to
@ -2450,7 +2461,7 @@ func testIssue37098(t *testing.T, exporter packagestest.Exporter) {
}
// TestInvalidFilesInXTest checks the fix for golang/go#37971 in Go 1.15.
func TestInvalidFilesInXTest(t *testing.T) { testAllOrModules(t, testInvalidFilesInXTest) }
func TestInvalidFilesInXTest(t *testing.T) { testAllOrModulesParallel(t, testInvalidFilesInXTest) }
func testInvalidFilesInXTest(t *testing.T, exporter packagestest.Exporter) {
testenv.NeedsGo1Point(t, 15)
exported := packagestest.Export(t, exporter, []packagestest.Module{
@ -2477,7 +2488,7 @@ func testInvalidFilesInXTest(t *testing.T, exporter packagestest.Exporter) {
}
}
func TestTypecheckCgo(t *testing.T) { testAllOrModules(t, testTypecheckCgo) }
func TestTypecheckCgo(t *testing.T) { testAllOrModulesParallel(t, testTypecheckCgo) }
func testTypecheckCgo(t *testing.T, exporter packagestest.Exporter) {
testenv.NeedsGo1Point(t, 15)
testenv.NeedsTool(t, "cgo")
@ -2520,7 +2531,7 @@ func testTypecheckCgo(t *testing.T, exporter packagestest.Exporter) {
}
func TestModule(t *testing.T) {
testAllOrModules(t, testModule)
testAllOrModulesParallel(t, testModule)
}
func testModule(t *testing.T, exporter packagestest.Exporter) {
exported := packagestest.Export(t, exporter, []packagestest.Module{{
@ -2560,9 +2571,10 @@ func testModule(t *testing.T, exporter packagestest.Exporter) {
}
func TestExternal_NotHandled(t *testing.T) {
testAllOrModules(t, testExternal_NotHandled)
testAllOrModulesParallel(t, testExternal_NotHandled)
}
func testExternal_NotHandled(t *testing.T, exporter packagestest.Exporter) {
skipIfShort(t, "builds and links fake driver binaries")
testenv.NeedsGoBuild(t)
tempdir, err := ioutil.TempDir("", "testexternal")
@ -2646,7 +2658,7 @@ func main() {
}
func TestInvalidPackageName(t *testing.T) {
testAllOrModules(t, testInvalidPackageName)
testAllOrModulesParallel(t, testInvalidPackageName)
}
func testInvalidPackageName(t *testing.T, exporter packagestest.Exporter) {

View File

@ -19,11 +19,6 @@ import (
// This test loads the metadata for the standard library,
func TestStdlibMetadata(t *testing.T) {
// TODO(adonovan): see if we can get away without this hack.
// if runtime.GOOS == "android" {
// t.Skipf("incomplete std lib on %s", runtime.GOOS)
// }
testenv.NeedsGoPackages(t)
runtime.GC()
@ -61,9 +56,7 @@ func TestStdlibMetadata(t *testing.T) {
}
func TestCgoOption(t *testing.T) {
if testing.Short() {
t.Skip("skipping in short mode; uses tons of memory (https://golang.org/issue/14113)")
}
skipIfShort(t, "uses tons of memory (https://golang.org/issue/14113)")
testenv.NeedsGoPackages(t)