@@ -242,8 +242,7 @@ type test struct {
242
242
donec chan bool // closed when done
243
243
dt time.Duration
244
244
245
- src string
246
- action string // "compile", "build", etc.
245
+ src string
247
246
248
247
tempDir string
249
248
err error
@@ -457,15 +456,15 @@ func (t *test) run() {
457
456
pkgPos = pos // some files are intentionally malformed
458
457
}
459
458
if ok , why := shouldTest (t .src [:pkgPos ], goos , goarch ); ! ok {
460
- t .action = "skip"
461
459
if * showSkips {
462
- fmt .Printf ("%-20s %-20s: %s\n " , t . action , t .goFileName (), why )
460
+ fmt .Printf ("%-20s %-20s: %s\n " , "skip" , t .goFileName (), why )
463
461
}
464
462
return
465
463
}
466
464
467
465
var args , flags []string
468
466
wantError := false
467
+ wantAuto := false
469
468
singlefilepkgs := false
470
469
f := strings .Fields (action )
471
470
if len (f ) > 0 {
@@ -477,27 +476,25 @@ func (t *test) run() {
477
476
switch action {
478
477
case "rundircmpout" :
479
478
action = "rundir"
480
- t .action = "rundir"
481
479
case "cmpout" :
482
480
action = "run" // the run case already looks for <dir>/<test>.out files
483
- fallthrough
484
481
case "compile" , "compiledir" , "build" , "run" , "runoutput" , "rundir" :
485
- t . action = action
482
+ // nothing to do
486
483
case "errorcheckandrundir" :
487
484
wantError = false // should be no error if also will run
488
- fallthrough
485
+ case "errorcheckwithauto" :
486
+ action = "errorcheck"
487
+ wantAuto = true
488
+ wantError = true
489
489
case "errorcheck" , "errorcheckdir" , "errorcheckoutput" :
490
- t .action = action
491
490
wantError = true
492
491
case "skip" :
493
492
if * runSkips {
494
493
break
495
494
}
496
- t .action = "skip"
497
495
return
498
496
default :
499
497
t .err = skipError ("skipped; unknown pattern: " + action )
500
- t .action = "??"
501
498
return
502
499
}
503
500
@@ -574,7 +571,7 @@ func (t *test) run() {
574
571
if * updateErrors {
575
572
t .updateErrors (string (out ), long )
576
573
}
577
- t .err = t .errorCheck (string (out ), long , t .gofile )
574
+ t .err = t .errorCheck (string (out ), wantAuto , long , t .gofile )
578
575
return
579
576
580
577
case "compile" :
@@ -622,7 +619,7 @@ func (t *test) run() {
622
619
for _ , name := range gofiles {
623
620
fullshort = append (fullshort , filepath .Join (longdir , name ), name )
624
621
}
625
- t .err = t .errorCheck (string (out ), fullshort ... )
622
+ t .err = t .errorCheck (string (out ), wantAuto , fullshort ... )
626
623
if t .err != nil {
627
624
break
628
625
}
@@ -758,7 +755,7 @@ func (t *test) run() {
758
755
return
759
756
}
760
757
}
761
- t .err = t .errorCheck (string (out ), tfile , "tmp__.go" )
758
+ t .err = t .errorCheck (string (out ), false , tfile , "tmp__.go" )
762
759
return
763
760
}
764
761
}
@@ -801,7 +798,7 @@ func (t *test) expectedOutput() string {
801
798
return string (b )
802
799
}
803
800
804
- func splitOutput (out string ) []string {
801
+ func splitOutput (out string , wantAuto bool ) []string {
805
802
// gc error messages continue onto additional lines with leading tabs.
806
803
// Split the output at the beginning of each line that doesn't begin with a tab.
807
804
// <autogenerated> lines are impossible to match so those are filtered out.
@@ -812,7 +809,7 @@ func splitOutput(out string) []string {
812
809
}
813
810
if strings .HasPrefix (line , "\t " ) {
814
811
res [len (res )- 1 ] += "\n " + line
815
- } else if strings .HasPrefix (line , "go tool" ) || strings .HasPrefix (line , "<autogenerated> " ) || strings .HasPrefix (line , "# " ) {
812
+ } else if strings .HasPrefix (line , "go tool" ) || strings .HasPrefix (line , "# " ) || ! wantAuto && strings .HasPrefix (line , "<autogenerated> " ) {
816
813
continue
817
814
} else if strings .TrimSpace (line ) != "" {
818
815
res = append (res , line )
@@ -821,14 +818,14 @@ func splitOutput(out string) []string {
821
818
return res
822
819
}
823
820
824
- func (t * test ) errorCheck (outStr string , fullshort ... string ) (err error ) {
821
+ func (t * test ) errorCheck (outStr string , wantAuto bool , fullshort ... string ) (err error ) {
825
822
defer func () {
826
823
if * verbose && err != nil {
827
824
log .Printf ("%s gc output:\n %s" , t , outStr )
828
825
}
829
826
}()
830
827
var errs []error
831
- out := splitOutput (outStr )
828
+ out := splitOutput (outStr , wantAuto )
832
829
833
830
// Cut directory name.
834
831
for i := range out {
@@ -846,7 +843,11 @@ func (t *test) errorCheck(outStr string, fullshort ...string) (err error) {
846
843
847
844
for _ , we := range want {
848
845
var errmsgs []string
849
- errmsgs , out = partitionStrings (we .prefix , out )
846
+ if we .auto {
847
+ errmsgs , out = partitionStrings ("<autogenerated>" , out )
848
+ } else {
849
+ errmsgs , out = partitionStrings (we .prefix , out )
850
+ }
850
851
if len (errmsgs ) == 0 {
851
852
errs = append (errs , fmt .Errorf ("%s:%d: missing error %q" , we .file , we .lineNum , we .reStr ))
852
853
continue
@@ -906,7 +907,7 @@ func (t *test) updateErrors(out, file string) {
906
907
// Parse new errors.
907
908
errors := make (map [int ]map [string ]bool )
908
909
tmpRe := regexp .MustCompile (`autotmp_[0-9]+` )
909
- for _ , errStr := range splitOutput (out ) {
910
+ for _ , errStr := range splitOutput (out , false ) {
910
911
colon1 := strings .Index (errStr , ":" )
911
912
if colon1 < 0 || errStr [:colon1 ] != file {
912
913
continue
@@ -991,12 +992,14 @@ type wantedError struct {
991
992
reStr string
992
993
re * regexp.Regexp
993
994
lineNum int
995
+ auto bool // match <autogenerated> line
994
996
file string
995
997
prefix string
996
998
}
997
999
998
1000
var (
999
1001
errRx = regexp .MustCompile (`// (?:GC_)?ERROR (.*)` )
1002
+ errAutoRx = regexp .MustCompile (`// (?:GC_)?ERRORAUTO (.*)` )
1000
1003
errQuotesRx = regexp .MustCompile (`"([^"]*)"` )
1001
1004
lineRx = regexp .MustCompile (`LINE(([+-])([0-9]+))?` )
1002
1005
)
@@ -1011,7 +1014,13 @@ func (t *test) wantedErrors(file, short string) (errs []wantedError) {
1011
1014
// double comment disables ERROR
1012
1015
continue
1013
1016
}
1014
- m := errRx .FindStringSubmatch (line )
1017
+ var auto bool
1018
+ m := errAutoRx .FindStringSubmatch (line )
1019
+ if m != nil {
1020
+ auto = true
1021
+ } else {
1022
+ m = errRx .FindStringSubmatch (line )
1023
+ }
1015
1024
if m == nil {
1016
1025
continue
1017
1026
}
@@ -1046,6 +1055,7 @@ func (t *test) wantedErrors(file, short string) (errs []wantedError) {
1046
1055
reStr : rx ,
1047
1056
re : re ,
1048
1057
prefix : prefix ,
1058
+ auto : auto ,
1049
1059
lineNum : lineNum ,
1050
1060
file : short ,
1051
1061
})
0 commit comments