| 1 | // Copyright 2024 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 stdversion_test |
| 6 | |
| 7 | import ( |
| 8 | "path/filepath" |
| 9 | "testing" |
| 10 | |
| 11 | "golang.org/x/tools/go/analysis/analysistest" |
| 12 | "golang.org/x/tools/go/analysis/passes/stdversion" |
| 13 | "golang.org/x/tools/internal/testenv" |
| 14 | "golang.org/x/tools/internal/testfiles" |
| 15 | ) |
| 16 | |
| 17 | func Test(t *testing.T) { |
| 18 | testenv.NeedsGo1Point(t, 23) // TODO(#68658): Waiting on 1.22 backport. |
| 19 | |
| 20 | // The test relies on go1.21 std symbols, but the analyzer |
| 21 | // itself requires the go1.22 implementation of versions.FileVersions. |
| 22 | dir := testfiles.ExtractTxtarFileToTmp(t, filepath.Join(analysistest.TestData(), "test.txtar")) |
| 23 | analysistest.Run(t, dir, stdversion.Analyzer, |
| 24 | "example.com/basic", |
| 25 | "example.com/despite", |
| 26 | "example.com/mod20", |
| 27 | "example.com/mod21", |
| 28 | "example.com/mod22", |
| 29 | "example.com/old", |
| 30 | ) |
| 31 | } |