Tim Starling has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/282097

Change subject: parserTests.php: fix three bitrot bugs with --record
......................................................................

parserTests.php: fix three bitrot bugs with --record

* Add a subtest index to the recorded test name, to avoid an SQL
  duplicate key error.
* Don't implicitly commit (commitMasterChanges) an explicit transaction,
  since that now causes a fatal error.
* Reset namespace cache as in NewParserTest.php, so that the MemoryAlpha
  article insertion doesn't fail. This was only visible with --record
  because the namespace cache is initialised by
  SpecialVersion::getVersion() during recorder setup.

Change-Id: Ied4636b4acbf1d268e45901fed4d4e077b5ed666
---
M tests/parser/parserTest.inc
M tests/testHelpers.inc
2 files changed, 32 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/97/282097/1

diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc
index 56108c9..78e5f6f 100644
--- a/tests/parser/parserTest.inc
+++ b/tests/parser/parserTest.inc
@@ -244,6 +244,10 @@
                // "extra language links"
                // see https://gerrit.wikimedia.org/r/111390
                array_push( $wgExtraInterlanguageLinkPrefixes, 'mul' );
+
+               // Reset namespace cache
+               MWNamespace::getCanonicalNamespaces( true );
+               Language::factory( 'en' )->resetNamespaces();
        }
 
        /**
@@ -536,7 +540,7 @@
                        $result =
                                $this->runTest( $t['test'], $t['input'], 
$t['result'], $t['options'], $t['config'] );
                        $ok = $ok && $result;
-                       $this->recorder->record( $t['test'], $result );
+                       $this->recorder->record( $t['test'], $t['subtest'], 
$result );
                }
 
                if ( $this->showProgress ) {
diff --git a/tests/testHelpers.inc b/tests/testHelpers.inc
index 76544a5..62e9731 100644
--- a/tests/testHelpers.inc
+++ b/tests/testHelpers.inc
@@ -44,9 +44,10 @@
        /**
         * Called after each test
         * @param string $test
+        * @param integer $subtest
         * @param bool $result
         */
-       public function record( $test, $result );
+       public function record( $test, $subtest, $result );
 
        /**
         * Called before finishing the test run
@@ -74,7 +75,7 @@
                $this->success = 0;
        }
 
-       function record( $test, $result ) {
+       function record( $test, $subtest, $result ) {
                $this->total++;
                $this->success += ( $result ? 1 : 0 );
        }
@@ -147,9 +148,17 @@
                $this->results = [];
        }
 
-       function record( $test, $result ) {
-               parent::record( $test, $result );
-               $this->results[$test] = $result;
+       function getName( $test, $subtest ) {
+               if ( $subtest ) {
+                       return "$test subtest #$subtest";
+               } else {
+                       return $test;
+               }
+       }
+
+       function record( $test, $subtest, $result ) {
+               parent::record( $test, $subtest, $result );
+               $this->results[ $this->getName( $test, $subtest ) ] = $result;
        }
 
        function report() {
@@ -299,10 +308,9 @@
        }
 
        /**
-        * Commit transaction and clean up for result recording
+        * Close the DB connection
         */
        function end() {
-               $this->lb->commitMasterChanges();
                $this->lb->closeAll();
                parent::end();
        }
@@ -350,16 +358,24 @@
         * @param string $test
         * @param bool $result
         */
-       function record( $test, $result ) {
-               parent::record( $test, $result );
+       function record( $test, $subtest, $result ) {
+               parent::record( $test, $subtest, $result );
 
                $this->db->insert( 'testitem',
                        [
                                'ti_run' => $this->curRun,
-                               'ti_name' => $test,
+                               'ti_name' => $this->getName( $test, $subtest ),
                                'ti_success' => $result ? 1 : 0,
                        ],
                        __METHOD__ );
+       }
+
+       /**
+        * Commit transaction and clean up for result recording
+        */
+       function end() {
+               $this->db->commit( __METHOD__ );
+               parent::end();
        }
 }
 
@@ -479,6 +495,7 @@
 
                $this->test = [
                        'test' => ParserTest::chomp( $this->sectionData['test'] 
),
+                       'subtest' => $this->nextSubTest,
                        'input' => ParserTest::chomp( 
$this->sectionData[$input] ),
                        'result' => ParserTest::chomp( 
$this->sectionData[$result] ),
                        'options' => ParserTest::chomp( 
$this->sectionData['options'] ),

-- 
To view, visit https://gerrit.wikimedia.org/r/282097
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ied4636b4acbf1d268e45901fed4d4e077b5ed666
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Tim Starling <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to