github.com/powerman/golang-tools@v0.1.11-0.20220410185822-5ad214d8d803/go/analysis/passes/tests/tests_test.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package tests_test 6 7 import ( 8 "testing" 9 10 "github.com/powerman/golang-tools/internal/analysisinternal" 11 12 "github.com/powerman/golang-tools/go/analysis/analysistest" 13 "github.com/powerman/golang-tools/go/analysis/passes/tests" 14 "github.com/powerman/golang-tools/internal/typeparams" 15 ) 16 17 func Test(t *testing.T) { 18 // In 1.18, diagnostic for Fuzz Tests must not be used by cmd/vet. 19 // So the code for Fuzz tests diagnostics is guarded behind flag analysisinternal.DiagnoseFuzzTests 20 // Turn on the flag DiagnoseFuzzTests for analysis tests and then turn it off. 21 analysisinternal.DiagnoseFuzzTests = true 22 defer func() { 23 analysisinternal.DiagnoseFuzzTests = false 24 }() 25 testdata := analysistest.TestData() 26 pkgs := []string{ 27 "a", // loads "a", "a [a.test]", and "a.test" 28 "b_x_test", // loads "b" and "b_x_test" 29 "divergent", 30 } 31 if typeparams.Enabled { 32 pkgs = append(pkgs, "typeparams") 33 } 34 analysistest.Run(t, testdata, tests.Analyzer, pkgs...) 35 }