Title: [189195] trunk/Tools
Revision
189195
Author
[email protected]
Date
2015-08-31 16:44:41 -0700 (Mon, 31 Aug 2015)

Log Message

Modify prepare-Changelog to be aware of files that are marked as tests as well as files
that are marked as requiring corresponding tests.
https://bugs.webkit.org/show_bug.cgi?id=148498
<rdar://problem/21555314>

Patch by Jason Marcell <[email protected]> on 2015-08-31
Reviewed by Dan Bernstein and David Kilzer.

* Scripts/prepare-ChangeLog: Added "attributeCache" to cache Subversion properties in order to
simulate Git's attribute behevaior.
(main): Added "requiresTests" array to contain files that require tests.
(generateNewChangeLogs): Checks "requiresTests" array to determine whether to inject "tests"
section in ChangeLog.
(attributeCommand): Queries a given file for a given Git attribute value. If using Subversion,
however, we check if the file or any containing folder has the given property set to "1" and
return 1 if so; return 0 otherwise.
(generateFileList): Adds files to "requiresTests" array if Git attribute is set to "1". Also
adds files to "addedRegressionTests" array if "test" attribute is set to "1".

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (189194 => 189195)


--- trunk/Tools/ChangeLog	2015-08-31 23:30:10 UTC (rev 189194)
+++ trunk/Tools/ChangeLog	2015-08-31 23:44:41 UTC (rev 189195)
@@ -1,3 +1,23 @@
+2015-08-31  Jason Marcell  <[email protected]>
+
+        Modify prepare-Changelog to be aware of files that are marked as tests as well as files
+        that are marked as requiring corresponding tests.
+        https://bugs.webkit.org/show_bug.cgi?id=148498
+        <rdar://problem/21555314>
+
+        Reviewed by Dan Bernstein and David Kilzer.
+
+        * Scripts/prepare-ChangeLog: Added "attributeCache" to cache Subversion properties in order to
+        simulate Git's attribute behevaior.
+        (main): Added "requiresTests" array to contain files that require tests.
+        (generateNewChangeLogs): Checks "requiresTests" array to determine whether to inject "tests"
+        section in ChangeLog.
+        (attributeCommand): Queries a given file for a given Git attribute value. If using Subversion,
+        however, we check if the file or any containing folder has the given property set to "1" and
+        return 1 if so; return 0 otherwise.
+        (generateFileList): Adds files to "requiresTests" array if Git attribute is set to "1". Also
+        adds files to "addedRegressionTests" array if "test" attribute is set to "1".
+
 2015-08-26  Andy Estes  <[email protected]>
 
         [Content Filtering] Determine navigation and content policy before continuing to filter a load

Modified: trunk/Tools/Scripts/prepare-ChangeLog (189194 => 189195)


--- trunk/Tools/Scripts/prepare-ChangeLog	2015-08-31 23:30:10 UTC (rev 189194)
+++ trunk/Tools/Scripts/prepare-ChangeLog	2015-08-31 23:44:41 UTC (rev 189195)
@@ -64,6 +64,7 @@
 use POSIX qw(strftime);
 use VCSUtils;
 
+sub attributeCommand($$);
 sub changeLogDate($);
 sub changeLogEmailAddressFromArgs($$);
 sub changeLogNameFromArgs($$);
@@ -81,7 +82,7 @@
 sub generateFileList(\%$$$);
 sub generateFunctionLists($$$$$);
 sub generateFunctionListsByRanges($$$$);
-sub generateNewChangeLogs($$$$$$$$$$$$);
+sub generateNewChangeLogs($$$$$$$$$$$$$);
 sub getLatestChangeLogs($);
 sub get_function_line_ranges($$);
 sub get_function_line_ranges_for_cpp($$);
@@ -117,6 +118,8 @@
 use constant GIT => "git";
 use constant SupportedTestExtensions => {map { $_ => 1 } qw(html shtml svg xml xhtml pl php)};
 
+my %attributeCache;
+
 exit(main());
 
 sub main()
@@ -184,7 +187,7 @@
     my %paths = processPaths(@ARGV);
 
     # Find the list of modified files
-    my ($changedFiles, $conflictFiles, $functionLists, $addedRegressionTests) = generateFileList(%paths, $gitCommit, $gitIndex, $mergeBase);
+    my ($changedFiles, $conflictFiles, $functionLists, $addedRegressionTests, $requiresTests) = generateFileList(%paths, $gitCommit, $gitIndex, $mergeBase);
 
     if (!@$changedFiles && !@$conflictFiles && !keys %$functionLists) {
         print STDERR "  No changes found.\n";
@@ -226,7 +229,7 @@
         resolveConflictedChangeLogs($changeLogs);
     }
 
-    generateNewChangeLogs($prefixes, $filesInChangeLog, $addedRegressionTests, $functionLists, $bugURL, $bugDescription, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs, $delimiters);
+    generateNewChangeLogs($prefixes, $filesInChangeLog, $addedRegressionTests, $requiresTests, $functionLists, $bugURL, $bugDescription, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs, $delimiters);
 
     if ($writeChangeLogs) {
         print STDERR "-- Please remember to include a detailed description in your ChangeLog entry. --\n-- See <http://webkit.org/coding/contributing.html> for more info --\n";
@@ -527,9 +530,9 @@
     close RESOLVE;
 }
 
-sub generateNewChangeLogs($$$$$$$$$$$$)
+sub generateNewChangeLogs($$$$$$$$$$$$$)
 {
-    my ($prefixes, $filesInChangeLog, $addedRegressionTests, $functionLists, $bugURL, $bugDescription, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs, $delimiters) = @_;
+    my ($prefixes, $filesInChangeLog, $addedRegressionTests, $requiresTests, $functionLists, $bugURL, $bugDescription, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs, $delimiters) = @_;
 
     # Generate new ChangeLog entries and (optionally) write out new ChangeLog files.
     foreach my $prefix (@$prefixes) {
@@ -570,7 +573,7 @@
 
         print CHANGE_LOG normalizeLineEndings("        Reviewed by $reviewer.\n\n", $endl);
 
-        if ($prefix =~ m/WebCore/ || `pwd` =~ m/WebCore/) {
+        if ($prefix =~ m/WebCore/ || `pwd` =~ m/WebCore/ || @$requiresTests) {
             if (@$addedRegressionTests) {
                 print CHANGE_LOG normalizeLineEndings(testListForChangeLog(sort @$addedRegressionTests), $endl);
             } else {
@@ -1801,6 +1804,46 @@
     return "$command 2>&1";
 }
 
+sub attributeCommand($$)
+{
+    my ($file, $attr) = @_;
+
+    my $result;
+    if (isSVN()) {
+        my $foundAttribute = 0;
+        my $subPath = ".";
+        my (@directoryParts) = File::Spec->splitdir($file);
+        foreach my $part (@directoryParts) {
+            if ($part eq ".") {
+                next;
+            }
+            $subPath = File::Spec->join($subPath, $part);
+            $subPath =~ s/^\.\///;
+            if ($foundAttribute || exists $attributeCache{$attr}{$subPath} && $attributeCache{$attr}{$subPath} eq "1") {
+                $attributeCache{$attr}{$subPath} = "1";
+                $foundAttribute = 1;
+                next;
+            }
+            my $command = SVN . " propget $attr $subPath";
+            my $attrib = $attributeCache{$attr}{$subPath} || `$command`;
+            chomp $attrib;
+            if ($attrib eq "1") {
+                $foundAttribute = 1;
+            }
+            $attributeCache{$attr}{$subPath} = $attrib || "0";
+        }
+        $result = $attributeCache{$attr}{$file};
+    } elsif (isGit()) {
+        my $command = GIT . " check-attr $attr -- $file";
+        $result = `$command`;
+        chomp $result;
+        $result =~ s/.*\W(\w)/$1/;
+    }
+
+    $result =~ s/\D//g;
+    return int($result || 0);
+}
+
 sub createPatchCommand($$$$)
 {
     my ($changedFilesString, $gitCommit, $gitIndex, $mergeBase) = @_;
@@ -1925,6 +1968,7 @@
     my @conflictFiles;
     my %functionLists;
     my @addedRegressionTests;
+    my @requiresTests;
     print STDERR "  Running status to find changed, added, or removed files.\n";
     open STAT, "-|", statusCommand($paths, $gitCommit, $gitIndex, $mergeBase) or die "The status failed: $!.\n";
     while (<STAT>) {
@@ -1984,6 +2028,10 @@
                        && $file !~ /-expected(-mismatch)?\.html$/
                        && !scalar(grep(/^resources$/i, @components))
                        && !scalar(grep(/^script-tests$/i, @components));
+            } elsif (attributeCommand($file, "test")) {
+                push @addedRegressionTests, $file;
+            } elsif (attributeCommand($file, "requiresTests")) {
+                push @requiresTests, $file
             }
             push @changedFiles, $file if $components[$#components] ne "ChangeLog";
         } elsif (isConflictStatus($status, $gitCommit, $gitIndex) || isConflictStatus($propertyStatus, $gitCommit, $gitIndex)) {
@@ -1995,7 +2043,7 @@
         }
     }
     close STAT;
-    return (\@changedFiles, \@conflictFiles, \%functionLists, \@addedRegressionTests);
+    return (\@changedFiles, \@conflictFiles, \%functionLists, \@addedRegressionTests, \@requiresTests);
 }
 
 sub isUnmodifiedStatus($)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to