2 use Wikimedia\ScopedCallback;
64 parent::__construct();
67 $this->ptRunner =
new ParserTestRunner( $this->ptRecorder );
69 if ( is_string(
$flags ) ) {
74 $mwTestDir =
$IP .
'/tests/';
76 # Human friendly helpers
80 # Will hold the .txt parser test files we will include
83 # Filter out .txt files
84 $files = ParserTestRunner::getParserTestFiles();
85 foreach ( $files
as $extName => $parserTestFile ) {
86 $isCore = ( 0 === strpos( $parserTestFile, $mwTestDir ) );
88 if ( $isCore && $wantsCore ) {
89 self::debug(
"included core parser tests: $parserTestFile" );
90 $filesToTest[$extName] = $parserTestFile;
91 } elseif ( !$isCore && $wantsRest ) {
92 self::debug(
"included non core parser tests: $parserTestFile" );
93 $filesToTest[$extName] = $parserTestFile;
95 self::debug(
"skipped parser tests: $parserTestFile" );
99 . implode(
' ', $filesToTest ) );
103 foreach ( $filesToTest
as $extensionName => $fileName ) {
104 if ( is_int( $extensionName ) ) {
108 $extensionName = basename( dirname( $fileName ) );
110 $testsName = $extensionName .
'__' . basename( $fileName,
'.txt' );
111 $parserTestClassName = ucfirst( $testsName );
115 $parserTestClassName =
'ParserTest_' .
116 preg_replace(
'/[^a-zA-Z0-9_\x7f-\xff]/',
'_', $parserTestClassName );
118 if ( isset( $testList[$parserTestClassName] ) ) {
121 $parserTestClassName .= $counter;
123 $testList[$parserTestClassName] =
true;
128 self::debug(
"Adding test class $parserTestClassName" );
130 $this->ptRunner, $parserTestClassName, $fileName ) );
137 $type = $db->getType();
138 $prefix =
$type ===
'oracle' ?
141 $teardown = $this->ptRunner->setDatabase( $db );
142 $teardown = $this->ptRunner->setupUploads( $teardown );
143 $this->ptTeardownScope = $teardown;
148 if ( $this->ptTeardownScope ) {
149 ScopedCallback::consume( $this->ptTeardownScope );
157 protected static function debug( $msg ) {