test262-runner -s --test-only should replace test results
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Aug 2018 11:49:08 +0000 (11:49 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Aug 2018 11:49:08 +0000 (11:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188450

Reviewed by Michael Saboff.

* Scripts/test262/Runner.pm:
(main):
(SetFailureForTest):
(UpdateResults):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235359 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/test262/Runner.pm

index 63a875c..8856fb4 100644 (file)
@@ -1,3 +1,15 @@
+2018-08-27  Keith Miller  <keith_miller@apple.com>
+
+        test262-runner -s --test-only should replace test results
+        https://bugs.webkit.org/show_bug.cgi?id=188450
+
+        Reviewed by Michael Saboff.
+
+        * Scripts/test262/Runner.pm:
+        (main):
+        (SetFailureForTest):
+        (UpdateResults):
+
 2018-08-26  Sam Weinig  <sam@webkit.org>
 
         Using _WKRemoteObjectInterface with a protocol that inherits from a non-NSObject protocol crashes
index 3fe2f4f..f4cd5ee 100755 (executable)
@@ -443,14 +443,7 @@ sub main {
             $failcount++;
 
             # Record this round of failures
-            if ( $failed{$test->{path}} ) {
-                $failed{$test->{path}}->{$test->{mode}} =  $test->{error};
-            }
-            else {
-                $failed{$test->{path}} = {
-                    $test->{mode} => $test->{error}
-                };
-            }
+            SetFailureForTest(\%failed, $test);
 
             # If an unexpected failure
             if (!$expectedFailure || ($expectedFailure ne $test->{error})) {
@@ -520,6 +513,9 @@ sub main {
     }
 
     if ($saveExpectations) {
+        if (!$runningAllTests) {
+            UpdateResults($expect, \@results, \%failed);
+        }
         DumpFile($expectationsFile, \%failed);
         print "Saved expectation file in: $expectationsFile\n";
     }
@@ -908,6 +904,42 @@ sub getHarness {
     return $content || '';
 }
 
+sub SetFailureForTest {
+    my ($failed, $test) = @_;
+
+    if ($failed->{$test->{path}}) {
+        $failed->{$test->{path}}->{$test->{mode}} = $test->{error};
+    }
+    else {
+        $failed->{$test->{path}} = {
+            $test->{mode} => $test->{error}
+        };
+    }
+}
+
+sub UpdateResults {
+    print "Updating results... \n";
+
+    my ($expect, $results, $failed) = @_;
+
+    foreach my $test (@{$results}) {
+        delete $expect->{$test->{path}};
+    }
+
+    foreach my $path (keys($expect)) {
+        foreach my $mode (keys($expect->{$path})) {
+            my $test = {
+                path => $path,
+                mode => $mode,
+                error => $expect->{$path}->{$mode},
+                result => 'FAIL'
+            };
+
+            SetFailureForTest($failed, $test);
+        }
+    }
+}
+
 sub summarizeResults {
     print "Summarizing results...\n";