File tree Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -5115,6 +5115,9 @@ func TestTestVet(t *testing.T) {
5115
5115
tg .grepStdout (`\[no test files\]` , "did not print test summary" )
5116
5116
tg .run ("test" , "-vet=off" , filepath .Join (tg .tempdir , "p1.go" ))
5117
5117
tg .grepStdout (`\[no test files\]` , "did not print test summary" )
5118
+
5119
+ tg .setenv ("GOPATH" , filepath .Join (tg .pwd (), "testdata" ))
5120
+ tg .run ("test" , "vetcycle" ) // must not fail; #22890
5118
5121
}
5119
5122
5120
5123
func TestInstallDeps (t * testing.T ) {
Original file line number Diff line number Diff line change @@ -638,6 +638,8 @@ type vetConfig struct {
638
638
GoFiles []string
639
639
ImportMap map [string ]string
640
640
PackageFile map [string ]string
641
+
642
+ SucceedOnTypecheckFailure bool
641
643
}
642
644
643
645
// VetFlags are the flags to pass to vet.
@@ -663,6 +665,13 @@ func (b *Builder) vet(a *Action) error {
663
665
vcfg .PackageFile ["fmt" ] = a1 .built
664
666
}
665
667
668
+ // During go test, ignore type-checking failures during vet.
669
+ // We only run vet if the compilation has succeeded,
670
+ // so at least for now assume the bug is in vet.
671
+ // We know of at least #18395.
672
+ // TODO(rsc,gri): Try to remove this for Go 1.11.
673
+ vcfg .SucceedOnTypecheckFailure = cfg .CmdName == "test"
674
+
666
675
js , err := json .MarshalIndent (vcfg , "" , "\t " )
667
676
if err != nil {
668
677
return fmt .Errorf ("internal error marshaling vet config: %v" , err )
Original file line number Diff line number Diff line change
1
+ package p
2
+
3
+
4
+ type (
5
+ _ interface { m (B1 ) }
6
+ A1 interface { a (D1 ) }
7
+ B1 interface { A1 }
8
+ C1 interface { B1 /* ERROR issue #18395 */ }
9
+ D1 interface { C1 }
10
+ )
11
+
12
+ var _ A1 = C1 /* ERROR cannot use C1 */ (nil )
Original file line number Diff line number Diff line change 35
35
tagList = []string {} // exploded version of tags flag; set in main
36
36
37
37
mustTypecheck bool
38
+
39
+ succeedOnTypecheckFailure bool // during go test, we ignore potential bugs in go/types
38
40
)
39
41
40
42
var exitCode = 0
@@ -291,6 +293,8 @@ type vetConfig struct {
291
293
ImportMap map [string ]string
292
294
PackageFile map [string ]string
293
295
296
+ SucceedOnTypecheckFailure bool
297
+
294
298
imp types.Importer
295
299
}
296
300
@@ -336,6 +340,7 @@ func doPackageCfg(cfgFile string) {
336
340
if err := json .Unmarshal (js , & vcfg ); err != nil {
337
341
errorf ("parsing vet config %s: %v" , cfgFile , err )
338
342
}
343
+ succeedOnTypecheckFailure = vcfg .SucceedOnTypecheckFailure
339
344
stdImporter = & vcfg
340
345
inittypes ()
341
346
mustTypecheck = true
@@ -427,6 +432,9 @@ func doPackage(names []string, basePkg *Package) *Package {
427
432
// Type check the package.
428
433
errs := pkg .check (fs , astFiles )
429
434
if errs != nil {
435
+ if succeedOnTypecheckFailure {
436
+ os .Exit (0 )
437
+ }
430
438
if * verbose || mustTypecheck {
431
439
for _ , err := range errs {
432
440
fmt .Fprintf (os .Stderr , "%v\n " , err )
You can’t perform that action at this time.
0 commit comments