@@ -58,6 +58,7 @@ BEGIN {
5858}
5959
6060use YAML qw( Load LoadFile Dump DumpFile Bless) ;
61+ use JSON;
6162use Parallel::ForkManager;
6263use Getopt::Long qw( GetOptions) ;
6364use Pod::Usage;
@@ -79,10 +80,13 @@ my $saveExpectations;
7980my $failingOnly ;
8081my $latestImport ;
8182my $runningAllTests ;
83+ my @results ;
8284
8385my $expectationsFile = abs_path(" $Bin /expectations.yaml" );
8486my $configFile = abs_path(" $Bin /config.yaml" );
8587my $resultsFile = abs_path(" $Bin /results.yaml" );
88+ my $summaryTxtFile = abs_path(" $Bin /results-summary.txt" );
89+ my $summaryFile = abs_path(" $Bin /results-summary.yaml" );
8690
8791processCLI();
8892
@@ -137,7 +141,6 @@ sub processCLI {
137141 }
138142
139143 if ($stats ) {
140- print " Summarizing results...\n\n " ;
141144 summarizeResults();
142145 exit ;
143146 }
@@ -256,10 +259,10 @@ sub main {
256259 close $deffh ;
257260
258261 seek ($resfh , 0, 0);
259- my @res = LoadFile($resfh );
262+ @results = LoadFile($resfh );
260263 close $resfh ;
261264
262- @res = sort { " $a ->{path} . $a ->{mode}" cmp " $b ->{path} . $b ->{mode}" } @res ;
265+ @results = sort { " $a ->{path} . $a ->{mode}" cmp " $b ->{path} . $b ->{mode}" } @results ;
263266
264267 my %failed ;
265268 my $failcount = 0;
@@ -268,7 +271,7 @@ sub main {
268271 my $skipfilecount = 0;
269272
270273 # Create expectation file and calculate results
271- foreach my $test (@res ) {
274+ foreach my $test (@results ) {
272275
273276 my $expectedFailure = 0;
274277 if ($expect && $expect -> {$test -> {path }}) {
@@ -309,13 +312,12 @@ sub main {
309312 }
310313
311314 if ($runningAllTests ) {
312- DumpFile($resultsFile , \@res );
313- print " Saved all the results in the $resultsFile ." ;
314- print " Summarizing results...\n\n " ;
315+ DumpFile($resultsFile , \@results );
316+ print " Saved all the results in $resultsFile \n " ;
315317 summarizeResults();
316318 }
317319
318- my $total = scalar @res - $skipfilecount ;
320+ my $total = scalar @results - $skipfilecount ;
319321 print " \n " . $total . " tests ran\n " ;
320322
321323 if ( !$expect ) {
@@ -655,12 +657,16 @@ sub getHarness {
655657}
656658
657659sub summarizeResults {
658- my @rawresults = LoadFile( $resultsFile ) or die $! ;
660+ print " Summarizing results... \n " ;
659661
662+ if (not @results ) {
663+ my @rawresults = LoadFile($resultsFile ) or die $! ;
664+ @results = @{$rawresults [0]};
665+ }
660666 my %byfeature ;
661667 my %bypath ;
662668
663- foreach my $test (@{ $rawresults [0]} ) {
669+ foreach my $test (@results ) {
664670 my $result = $test -> {result };
665671
666672 if ($test -> {features }) {
@@ -703,43 +709,50 @@ sub summarizeResults {
703709
704710 }
705711
706- print sprintf (" %-6s %-6s %-6s %-6s %s \n " , ' % PASS' , ' PASS' , ' FAIL' , ' SKIP' , ' FOLDER' );
707- foreach my $key (sort keys %bypath ) {
708- my $c = ' bold' ;
709- $c = ' clear' if $bypath {$key }-> [1];
712+ open (my $sfh , ' >' , $summaryTxtFile ) or die $! ;
710713
714+ print $sfh sprintf (" %-6s %-6s %-6s %-6s %s \n " , ' %PASS' , ' PASS' , ' FAIL' , ' SKIP' , ' FOLDER' );
715+ foreach my $key (sort keys %bypath ) {
711716 my $per = ($bypath {$key }-> [0] / (
712717 $bypath {$key }-> [0]
713718 + $bypath {$key }-> [1]
714719 + $bypath {$key }-> [2])) * 100;
715720
716721 $per = sprintf (" %.0f" , $per ) . " %" ;
717722
718- print colored([ $c ], sprintf (" %-6s %-6d %-6d %-6d %s \n " , $per ,
719- $bypath {$key }-> [0],
720- $bypath {$key }-> [1],
721- $bypath {$key }-> [2], $key ,) );
723+ print $sfh sprintf (" %-6s %-6d %-6d %-6d %s \n " , $per ,
724+ $bypath {$key }-> [0],
725+ $bypath {$key }-> [1],
726+ $bypath {$key }-> [2], $key ,);
722727 }
723728
724- print " \n\n " ;
725- print sprintf (" %-6s %-6s %-6s %-6s %s \n " , ' % PASS' , ' PASS' , ' FAIL' , ' SKIP' , ' FEATURE' );
729+ print $sfh " \n\n " ;
730+ print $sfh sprintf (" %-6s %-6s %-6s %-6s %s \n " , ' %PASS' , ' PASS' , ' FAIL' , ' SKIP' , ' FEATURE' );
726731
727732 foreach my $key (sort keys %byfeature ) {
728- my $c = ' bold' ;
729- $c = ' clear' if $byfeature {$key }-> [1];
730-
731733 my $per = ($byfeature {$key }-> [0] / (
732734 $byfeature {$key }-> [0]
733735 + $byfeature {$key }-> [1]
734736 + $byfeature {$key }-> [2])) * 100;
735737
736738 $per = sprintf (" %.0f" , $per ) . " %" ;
737739
738- print colored([ $c ], sprintf (" %-6s %-6d %-6d %-6d %s \n " , $per ,
739- $byfeature {$key }-> [0],
740- $byfeature {$key }-> [1],
741- $byfeature {$key }-> [2], $key ) );
740+ print $sfh sprintf (" %-6s %-6d %-6d %-6d %s \n " , $per ,
741+ $byfeature {$key }-> [0],
742+ $byfeature {$key }-> [1],
743+ $byfeature {$key }-> [2], $key );
742744 }
745+
746+ close ($sfh );
747+
748+ my %resultsyaml = (
749+ byFolder => \%bypath ,
750+ byFeature => \%byfeature ,
751+ );
752+
753+ DumpFile($summaryFile , \%resultsyaml );
754+
755+ print " See summarized results in $summaryTxtFile \n " ;
743756}
744757
745758__END__
@@ -828,7 +841,7 @@ Runs the test files listed in the last import (./JSTests/test262/latest-changes-
828841
829842=item B<--stats >
830843
831- Calculate conformance statistics from test262-results.yaml file.
844+ Calculate conformance statistics from JSTests/ test262-results.yaml file. Saves results in JSTests/test262/results-summary.txt and JSTests/test262/results-summary.yaml .
832845
833846=back
834847
0 commit comments