Add --setversion option to parserTests
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 15 May 2009 19:23:00 +0000 (19:23 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 15 May 2009 19:23:00 +0000 (19:23 +0000)
This overrides the version string stored in the database with --record.
When using git-svn, you can do

    php maintenance/parserTests.php --quick --quiet --record \
--setversion=`git rev-parse HEAD`

to have comprehensible version info stored for the purposes of later
bisection.  Previously just "1.16alpha" would be stored, which is
useless for tracking down the old revision -- you'd have to try guessing
based on date.

It might be useful for SpecialVersion::getVersion() to support git-svn,
but that's a more complicated and intrusive change for an admittedly
small minority, so I avoided it for now.

maintenance/parserTests.inc
maintenance/parserTests.php

index 0aa55ef..4ccc932 100644 (file)
@@ -26,7 +26,7 @@
 
 /** */
 $options = array( 'quick', 'color', 'quiet', 'help', 'show-output', 'record' );
-$optionsWithArgs = array( 'regex', 'seed' );
+$optionsWithArgs = array( 'regex', 'seed', 'setversion' );
 
 require_once( 'commandLine.inc' );
 require_once( "$IP/maintenance/parserTestsParserHook.php" );
@@ -1396,7 +1396,7 @@ class DbTestRecorder extends DbTestPreviewer  {
         * and all that fun stuff
         */
        function start() {
-               global $wgDBtype, $wgDBprefix;
+               global $wgDBtype, $wgDBprefix, $options;
                $this->db->begin();
 
                if( ! $this->db->tableExists( 'testrun' ) 
@@ -1415,7 +1415,8 @@ class DbTestRecorder extends DbTestPreviewer  {
                $this->db->insert( 'testrun',
                        array(
                                'tr_date'        => $this->db->timestamp(),
-                               'tr_mw_version'  => SpecialVersion::getVersion(),
+                               'tr_mw_version'  => isset( $options['setversion'] ) ?
+                                       $options['setversion'] : SpecialVersion::getVersion(),
                                'tr_php_version' => phpversion(),
                                'tr_db_version'  => $this->db->getServerVersion(),
                                'tr_uname'       => php_uname()
index 9a1a480..c7e2260 100644 (file)
@@ -40,6 +40,8 @@ Options:
   --file=<testfile> Run test cases from a custom file instead of parserTests.txt
   --record         Record tests in database
   --compare        Compare with recorded results, without updating the database.
+  --setversion     When using --record, set the version string to use (useful
+                   with git-svn so that you can get the exact revision)
   --keep-uploads   Re-use the same upload directory for each test, don't delete it
   --fuzz           Do a fuzz test instead of a normal test
   --seed <n>       Start the fuzz test from the specified seed