Skip to content

Commit

Permalink
internal/typeparams: delete const Enabled=true and simplify
Browse files Browse the repository at this point in the history
Change-Id: I8e95226d03d94027aee803a0431320bc7ee83600
Reviewed-on: https://go-review.googlesource.com/c/tools/+/549235
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
adonovan committed Dec 12, 2023
1 parent e46688f commit 23c86e8
Show file tree
Hide file tree
Showing 60 changed files with 93 additions and 665 deletions.
4 changes: 0 additions & 4 deletions cmd/stringer/endtoend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"testing"

"golang.org/x/tools/internal/testenv"
"golang.org/x/tools/internal/typeparams"
)

// This file contains a test that compiles and runs each program in testdata
Expand Down Expand Up @@ -62,9 +61,6 @@ func TestEndToEnd(t *testing.T) {
if err != nil {
t.Fatalf("Readdirnames: %s", err)
}
if typeparams.Enabled {
names = append(names, moreTests(t, "testdata/typeparams", "typeparams")...)
}
// Generate, compile, and run the test programs.
for _, name := range names {
if name == "typeparams" {
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 1 addition & 6 deletions go/analysis/passes/assign/assign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/assign"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
tests := []string{"a"}
if typeparams.Enabled {
tests = append(tests, "typeparams")
}
analysistest.RunWithSuggestedFixes(t, testdata, assign.Analyzer, tests...)
analysistest.RunWithSuggestedFixes(t, testdata, assign.Analyzer, "a", "typeparams")
}
7 changes: 1 addition & 6 deletions go/analysis/passes/atomic/atomic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/atomic"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
tests := []string{"a"}
if typeparams.Enabled {
tests = append(tests, "typeparams")
}
analysistest.Run(t, testdata, atomic.Analyzer, tests...)
analysistest.Run(t, testdata, atomic.Analyzer, "a", "typeparams")
}
7 changes: 1 addition & 6 deletions go/analysis/passes/bools/bools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/bools"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
tests := []string{"a"}
if typeparams.Enabled {
tests = append(tests, "typeparams")
}
analysistest.Run(t, testdata, bools.Analyzer, tests...)
analysistest.Run(t, testdata, bools.Analyzer, "a", "typeparams")
}
7 changes: 0 additions & 7 deletions go/analysis/passes/buildssa/buildssa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/buildssa"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
Expand All @@ -30,9 +29,6 @@ func Test(t *testing.T) {
}

func TestGenericDecls(t *testing.T) {
if !typeparams.Enabled {
t.Skip("TestGenericDecls requires type parameters.")
}
testdata := analysistest.TestData()
result := analysistest.Run(t, testdata, buildssa.Analyzer, "b")[0].Result

Expand All @@ -48,9 +44,6 @@ func TestGenericDecls(t *testing.T) {
}

func TestImporting(t *testing.T) {
if !typeparams.Enabled {
t.Skip("TestImporting depends on testdata/b/b/go which uses type parameters.")
}
testdata := analysistest.TestData()
result := analysistest.Run(t, testdata, buildssa.Analyzer, "c")[0].Result

Expand Down
8 changes: 1 addition & 7 deletions go/analysis/passes/cgocall/cgocall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/cgocall"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
tests := []string{"a", "b", "c"}
if typeparams.Enabled {
// and testdata/src/typeparams/typeparams.go when possible
tests = append(tests, "typeparams")
}
analysistest.Run(t, testdata, cgocall.Analyzer, tests...)
analysistest.Run(t, testdata, cgocall.Analyzer, "a", "b", "c", "typeparams")
}
7 changes: 1 addition & 6 deletions go/analysis/passes/composite/composite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/composite"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
pkgs := []string{"a"}
if typeparams.Enabled {
pkgs = append(pkgs, "typeparams")
}
analysistest.RunWithSuggestedFixes(t, testdata, composite.Analyzer, pkgs...)
analysistest.RunWithSuggestedFixes(t, testdata, composite.Analyzer, "a", "typeparams")
}
7 changes: 1 addition & 6 deletions go/analysis/passes/copylock/copylock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/copylock"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
pkgs := []string{"a"}
if typeparams.Enabled {
pkgs = append(pkgs, "typeparams")
}
analysistest.Run(t, testdata, copylock.Analyzer, pkgs...)
analysistest.Run(t, testdata, copylock.Analyzer, "a", "typeparams")
}
10 changes: 1 addition & 9 deletions go/analysis/passes/ctrlflow/ctrlflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,11 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/ctrlflow"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()

// load testdata/src/a/a.go
tests := []string{"a"}
if typeparams.Enabled {
// and testdata/src/typeparams/typeparams.go when possible
tests = append(tests, "typeparams")
}
results := analysistest.Run(t, testdata, ctrlflow.Analyzer, tests...)
results := analysistest.Run(t, testdata, ctrlflow.Analyzer, "a", "typeparams")

// Perform a minimal smoke test on
// the result (CFG) computed by ctrlflow.
Expand Down
7 changes: 1 addition & 6 deletions go/analysis/passes/deepequalerrors/deepequalerrors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/deepequalerrors"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
tests := []string{"a"}
if typeparams.Enabled {
tests = append(tests, "typeparams")
}
analysistest.Run(t, testdata, deepequalerrors.Analyzer, tests...)
analysistest.Run(t, testdata, deepequalerrors.Analyzer, "a", "typeparams")
}
7 changes: 1 addition & 6 deletions go/analysis/passes/errorsas/errorsas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/errorsas"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
tests := []string{"a"}
if typeparams.Enabled {
tests = append(tests, "typeparams")
}
analysistest.Run(t, testdata, errorsas.Analyzer, tests...)
analysistest.Run(t, testdata, errorsas.Analyzer, "a", "typeparams")
}
7 changes: 1 addition & 6 deletions go/analysis/passes/httpresponse/httpresponse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/httpresponse"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
tests := []string{"a"}
if typeparams.Enabled {
tests = append(tests, "typeparams")
}
analysistest.Run(t, testdata, httpresponse.Analyzer, tests...)
analysistest.Run(t, testdata, httpresponse.Analyzer, "a", "typeparams")
}
7 changes: 1 addition & 6 deletions go/analysis/passes/ifaceassert/ifaceassert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/ifaceassert"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
pkgs := []string{"a"}
if typeparams.Enabled {
pkgs = append(pkgs, "typeparams")
}
analysistest.Run(t, testdata, ifaceassert.Analyzer, pkgs...)
analysistest.Run(t, testdata, ifaceassert.Analyzer, "a", "typeparams")
}
4 changes: 0 additions & 4 deletions go/analysis/passes/internal/analysisutil/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ import (
"testing"

"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
"golang.org/x/tools/internal/typeparams"
)

func TestHasSideEffects(t *testing.T) {
if !typeparams.Enabled {
t.Skip("type parameters are not enabled")
}
src := `package p
type T int
Expand Down
8 changes: 2 additions & 6 deletions go/analysis/passes/loopclosure/loopclosure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ import (
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/loopclosure"
"golang.org/x/tools/internal/testenv"
"golang.org/x/tools/internal/typeparams"
"golang.org/x/tools/txtar"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
tests := []string{"a", "golang.org/...", "subtests"}
if typeparams.Enabled {
tests = append(tests, "typeparams")
}
analysistest.Run(t, testdata, loopclosure.Analyzer, tests...)
analysistest.Run(t, testdata, loopclosure.Analyzer,
"a", "golang.org/...", "subtests", "typeparams")
}

func TestVersions22(t *testing.T) {
Expand Down
10 changes: 3 additions & 7 deletions go/analysis/passes/lostcancel/lostcancel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
package lostcancel_test

import (
"testing"

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/lostcancel"
"golang.org/x/tools/internal/typeparams"
"testing"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
tests := []string{"a", "b"}
if typeparams.Enabled {
tests = append(tests, "typeparams")
}
analysistest.Run(t, testdata, lostcancel.Analyzer, tests...)
analysistest.Run(t, testdata, lostcancel.Analyzer, "a", "b", "typeparams")
}
10 changes: 3 additions & 7 deletions go/analysis/passes/nilfunc/nilfunc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
package nilfunc_test

import (
"testing"

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/nilfunc"
"golang.org/x/tools/internal/typeparams"
"testing"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
tests := []string{"a"}
if typeparams.Enabled {
tests = append(tests, "typeparams")
}
analysistest.Run(t, testdata, nilfunc.Analyzer, tests...)
analysistest.Run(t, testdata, nilfunc.Analyzer, "a", "typeparams")
}
7 changes: 0 additions & 7 deletions go/analysis/passes/nilness/nilness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/nilness"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
Expand All @@ -18,17 +17,11 @@ func Test(t *testing.T) {
}

func TestInstantiated(t *testing.T) {
if !typeparams.Enabled {
t.Skip("TestInstantiated requires type parameters")
}
testdata := analysistest.TestData()
analysistest.Run(t, testdata, nilness.Analyzer, "c")
}

func TestTypeSet(t *testing.T) {
if !typeparams.Enabled {
t.Skip("TestTypeSet requires type parameters")
}
testdata := analysistest.TestData()
analysistest.Run(t, testdata, nilness.Analyzer, "d")
}
7 changes: 1 addition & 6 deletions go/analysis/passes/printf/printf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/printf"
"golang.org/x/tools/internal/testenv"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
Expand All @@ -19,9 +18,5 @@ func Test(t *testing.T) {
testdata := analysistest.TestData()
printf.Analyzer.Flags.Set("funcs", "Warn,Warnf")

tests := []string{"a", "b", "nofmt"}
if typeparams.Enabled {
tests = append(tests, "typeparams")
}
analysistest.Run(t, testdata, printf.Analyzer, tests...)
analysistest.Run(t, testdata, printf.Analyzer, "a", "b", "nofmt", "typeparams")
}
7 changes: 1 addition & 6 deletions go/analysis/passes/shift/shift_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/shift"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
pkgs := []string{"a"}
if typeparams.Enabled {
pkgs = append(pkgs, "typeparams")
}
analysistest.Run(t, testdata, shift.Analyzer, pkgs...)
analysistest.Run(t, testdata, shift.Analyzer, "a", "typeparams")
}
7 changes: 1 addition & 6 deletions go/analysis/passes/stdmethods/stdmethods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,11 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/stdmethods"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
pkgs := []string{"a"}
if typeparams.Enabled {
pkgs = append(pkgs, "typeparams")
}
analysistest.Run(t, testdata, stdmethods.Analyzer, pkgs...)
analysistest.Run(t, testdata, stdmethods.Analyzer, "a", "typeparams")
}

func TestAnalyzeEncodingXML(t *testing.T) {
Expand Down
7 changes: 1 addition & 6 deletions go/analysis/passes/stringintconv/string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import (

"golang.org/x/tools/go/analysis/analysistest"
"golang.org/x/tools/go/analysis/passes/stringintconv"
"golang.org/x/tools/internal/typeparams"
)

func Test(t *testing.T) {
testdata := analysistest.TestData()
pkgs := []string{"a"}
if typeparams.Enabled {
pkgs = append(pkgs, "typeparams")
}
analysistest.RunWithSuggestedFixes(t, testdata, stringintconv.Analyzer, pkgs...)
analysistest.RunWithSuggestedFixes(t, testdata, stringintconv.Analyzer, "a", "typeparams")
}
Loading

0 comments on commit 23c86e8

Please sign in to comment.