rebaseline.py: Allow multiple testnames on the command line.
authorsenorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 29 Nov 2012 21:50:34 +0000 (21:50 +0000)
committersenorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 29 Nov 2012 21:50:34 +0000 (21:50 +0000)
Review URL: https://codereview.appspot.com/6856118

git-svn-id: http://skia.googlecode.com/svn/trunk@6623 2bbb7eff-a529-9590-31e7-b0007b416f81

tools/rebaseline.py

index e907c75..a36dbc7 100755 (executable)
@@ -8,8 +8,9 @@ found in the LICENSE file.
 '''
 
 '''
-Rebaselines a single GM test, on all bots and all configurations.
-Must be run from an SVN checkout of the gm-expected directory.
+Rebaselines the given GM tests, on all bots and all configurations.
+Must be run from the gm-expected directory.  If run from a git or SVN
+checkout, the files will be added to the staging area for commit.
 '''
 
 import os, subprocess, sys, tempfile
@@ -37,40 +38,40 @@ pairs = [
     'Skia_Xoom_4-1_Float_Release_32'],
 ]
 
-if len(sys.argv) != 2:
-    print 'Usage:  ' + os.path.basename(sys.argv[0]) + ' <testname>'
+if len(sys.argv) < 2:
+    print 'Usage:  ' + os.path.basename(sys.argv[0]) + ' <testname> '
+    '[ <testname> ... ]'
     exit(1)
 
-testname = sys.argv[1]
-
 is_svn_checkout = os.path.exists(os.path.join('..', '.svn'))
 is_git_checkout = os.path.exists(os.path.join('..', '.git'))
 
-for pair in pairs:
-    if (pair[0] == 'base-shuttle-win7-intel-angle'):
-        testtypes = [ 'angle' ]
-    else:
-        testtypes = [ '4444', '565', '8888', 'gpu', 'pdf' ]
-    print pair[0] + ':'
-    for testtype in testtypes:
-        infilename = testname + '_' + testtype + '.png'
-        print infilename
+for testname in sys.argv[1:]:
+    for pair in pairs:
+        if (pair[0] == 'base-shuttle-win7-intel-angle'):
+            testtypes = [ 'angle' ]
+        else:
+            testtypes = [ '4444', '565', '8888', 'gpu', 'pdf' ]
+        print pair[0] + ':'
+        for testtype in testtypes:
+            infilename = testname + '_' + testtype + '.png'
+            print infilename
 
-        url = 'http://skia-autogen.googlecode.com/svn/gm-actual/' + pair[0] + '/' + pair[1] + '/' + pair[0] + '/' + infilename
-        cmd = [ 'curl', '--fail', '--silent', url ]
-        temp = tempfile.NamedTemporaryFile()
-        ret = subprocess.call(cmd, stdout=temp)
-        if ret != 0:
-            print 'Couldn\'t fetch ' + url
-            continue
-        outfilename = os.path.join(pair[0], infilename);
-        cmd = [ 'cp', temp.name, outfilename ]
-        subprocess.call(cmd);
-        if is_svn_checkout:
-            cmd = [ 'svn', 'add', '--quiet', outfilename ]
-            subprocess.call(cmd)
-            cmd = [ 'svn', 'propset', '--quiet', 'svn:mime-type', 'image/png', outfilename ];
-            subprocess.call(cmd)
-        elif is_git_checkout:
-            cmd = [ 'git', 'add', outfilename ]
-            subprocess.call(cmd)
+            url = 'http://skia-autogen.googlecode.com/svn/gm-actual/' + pair[0] + '/' + pair[1] + '/' + pair[0] + '/' + infilename
+            cmd = [ 'curl', '--fail', '--silent', url ]
+            temp = tempfile.NamedTemporaryFile()
+            ret = subprocess.call(cmd, stdout=temp)
+            if ret != 0:
+                print 'Couldn\'t fetch ' + url
+                continue
+            outfilename = os.path.join(pair[0], infilename);
+            cmd = [ 'cp', temp.name, outfilename ]
+            subprocess.call(cmd);
+            if is_svn_checkout:
+                cmd = [ 'svn', 'add', '--quiet', outfilename ]
+                subprocess.call(cmd)
+                cmd = [ 'svn', 'propset', '--quiet', 'svn:mime-type', 'image/png', outfilename ];
+                subprocess.call(cmd)
+            elif is_git_checkout:
+                cmd = [ 'git', 'add', outfilename ]
+                subprocess.call(cmd)