@@ -428,7 +428,7 @@ func TestArchiveSelectionAfterSerialization(t *testing.T) {
428
428
origJS := renderPackage (t , origArchives [rootPath ], false )
429
429
readJS := renderPackage (t , readArchives [rootPath ], false )
430
430
431
- if diff := cmp .Diff (string ( origJS ), string ( readJS ) ); diff != "" {
431
+ if diff := cmp .Diff (origJS , readJS ); diff != "" {
432
432
t .Errorf ("the reloaded files produce different JS:\n %s" , diff )
433
433
}
434
434
}
@@ -444,12 +444,12 @@ func compareOrder(t *testing.T, sourceFiles []srctesting.Source, minify bool) {
444
444
445
445
outputReversed := compile (t , sourceFiles , minify )
446
446
447
- if diff := cmp .Diff (string ( outputNormal ), string ( outputReversed ) ); diff != "" {
447
+ if diff := cmp .Diff (outputNormal , outputReversed ); diff != "" {
448
448
t .Errorf ("files in different order produce different JS:\n %s" , diff )
449
449
}
450
450
}
451
451
452
- func compile (t * testing.T , sourceFiles []srctesting.Source , minify bool ) [] byte {
452
+ func compile (t * testing.T , sourceFiles []srctesting.Source , minify bool ) string {
453
453
t .Helper ()
454
454
rootPkg := srctesting .ParseSources (t , sourceFiles , nil )
455
455
archives := compileProject (t , rootPkg , minify )
@@ -460,11 +460,7 @@ func compile(t *testing.T, sourceFiles []srctesting.Source, minify bool) []byte
460
460
t .Fatalf (`root package not found in archives: %s` , path )
461
461
}
462
462
463
- b := renderPackage (t , a , minify )
464
- if len (b ) == 0 {
465
- t .Fatal (`compile had no output` )
466
- }
467
- return b
463
+ return renderPackage (t , a , minify )
468
464
}
469
465
470
466
// compileProject compiles the given root package and all packages imported by the root.
@@ -563,7 +559,7 @@ func reloadCompiledProject(t *testing.T, archives map[string]*Archive, rootPkgPa
563
559
return reloadCache
564
560
}
565
561
566
- func renderPackage (t * testing.T , archive * Archive , minify bool ) [] byte {
562
+ func renderPackage (t * testing.T , archive * Archive , minify bool ) string {
567
563
t .Helper ()
568
564
569
565
sel := & dce.Selector [* Decl ]{}
@@ -578,7 +574,11 @@ func renderPackage(t *testing.T, archive *Archive, minify bool) []byte {
578
574
t .Fatal (err )
579
575
}
580
576
581
- return buf .Bytes ()
577
+ b := buf .String ()
578
+ if len (b ) == 0 {
579
+ t .Fatal (`render package had no output` )
580
+ }
581
+ return b
582
582
}
583
583
584
584
type selectionTester struct {
0 commit comments