@@ -197,12 +197,17 @@ var data = []entry{
197
197
}
198
198
199
199
func TestFiles (t * testing.T ) {
200
+ t .Parallel ()
200
201
for _ , e := range data {
201
202
source := filepath .Join (dataDir , e .source )
202
203
golden := filepath .Join (dataDir , e .golden )
203
- check (t , source , golden , e .mode )
204
- // TODO(gri) check that golden is idempotent
205
- //check(t, golden, golden, e.mode)
204
+ mode := e .mode
205
+ t .Run (e .source , func (t * testing.T ) {
206
+ t .Parallel ()
207
+ check (t , source , golden , mode )
208
+ // TODO(gri) check that golden is idempotent
209
+ //check(t, golden, golden, e.mode)
210
+ })
206
211
}
207
212
}
208
213
@@ -295,6 +300,7 @@ func testComment(t *testing.T, f *ast.File, srclen int, comment *ast.Comment) {
295
300
// even if the position information of comments introducing newlines
296
301
// is incorrect.
297
302
func TestBadComments (t * testing.T ) {
303
+ t .Parallel ()
298
304
const src = `
299
305
// first comment - text and position changed by test
300
306
package p
@@ -481,6 +487,7 @@ func TestStmtLists(t *testing.T) {
481
487
}
482
488
483
489
func TestBaseIndent (t * testing.T ) {
490
+ t .Parallel ()
484
491
// The testfile must not contain multi-line raw strings since those
485
492
// are not indented (because their values must not change) and make
486
493
// this test fail.
@@ -495,28 +502,31 @@ func TestBaseIndent(t *testing.T) {
495
502
panic (err ) // error in test
496
503
}
497
504
498
- var buf bytes.Buffer
499
505
for indent := 0 ; indent < 4 ; indent ++ {
500
- buf .Reset ()
501
- (& Config {Tabwidth : tabwidth , Indent : indent }).Fprint (& buf , fset , file )
502
- // all code must be indented by at least 'indent' tabs
503
- lines := bytes .Split (buf .Bytes (), []byte {'\n' })
504
- for i , line := range lines {
505
- if len (line ) == 0 {
506
- continue // empty lines don't have indentation
507
- }
508
- n := 0
509
- for j , b := range line {
510
- if b != '\t' {
511
- // end of indentation
512
- n = j
513
- break
506
+ indent := indent
507
+ t .Run (fmt .Sprint (indent ), func (t * testing.T ) {
508
+ t .Parallel ()
509
+ var buf bytes.Buffer
510
+ (& Config {Tabwidth : tabwidth , Indent : indent }).Fprint (& buf , fset , file )
511
+ // all code must be indented by at least 'indent' tabs
512
+ lines := bytes .Split (buf .Bytes (), []byte {'\n' })
513
+ for i , line := range lines {
514
+ if len (line ) == 0 {
515
+ continue // empty lines don't have indentation
516
+ }
517
+ n := 0
518
+ for j , b := range line {
519
+ if b != '\t' {
520
+ // end of indentation
521
+ n = j
522
+ break
523
+ }
524
+ }
525
+ if n < indent {
526
+ t .Errorf ("line %d: got only %d tabs; want at least %d: %q" , i , n , indent , line )
514
527
}
515
528
}
516
- if n < indent {
517
- t .Errorf ("line %d: got only %d tabs; want at least %d: %q" , i , n , indent , line )
518
- }
519
- }
529
+ })
520
530
}
521
531
}
522
532
@@ -567,6 +577,7 @@ func (l *limitWriter) Write(buf []byte) (n int, err error) {
567
577
568
578
// Test whether the printer stops writing after the first error
569
579
func TestWriteErrors (t * testing.T ) {
580
+ t .Parallel ()
570
581
const filename = "printer.go"
571
582
src , err := ioutil .ReadFile (filename )
572
583
if err != nil {
0 commit comments