if ( !file_exists( $dir ) ) {
continue;
}
+ $counter = 1;
$dirIterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $dir )
);
foreach ( $dirIterator as $fileInfo ) {
/** @var SplFileInfo $fileInfo */
if ( substr( $fileInfo->getFilename(), -4 ) === '.txt' ) {
- $files[] = $fileInfo->getPathname();
+ $name = $info['name'] . $counter;
+ while ( isset( $files[$name] ) ) {
+ $name = $info['name'] . '_' . $counter++;
+ }
+ $files[$name] = $fileInfo->getPathname();
}
}
}
# Filter out .txt files
$files = ParserTestRunner::getParserTestFiles();
- foreach ( $files as $parserTestFile ) {
+ foreach ( $files as $extName => $parserTestFile ) {
$isCore = ( 0 === strpos( $parserTestFile, $mwTestDir ) );
if ( $isCore && $wantsCore ) {
self::debug( "included core parser tests: $parserTestFile" );
- $filesToTest[] = $parserTestFile;
+ $filesToTest[$extName] = $parserTestFile;
} elseif ( !$isCore && $wantsRest ) {
self::debug( "included non core parser tests: $parserTestFile" );
- $filesToTest[] = $parserTestFile;
+ $filesToTest[$extName] = $parserTestFile;
} else {
self::debug( "skipped parser tests: $parserTestFile" );
}
$testList = [];
$counter = 0;
- foreach ( $filesToTest as $fileName ) {
- // Call the highest level directory the extension name.
- // It may or may not actually be, but it should be close
- // enough to cause there to be separate names for different
- // things, which is good enough for our purposes.
- $extensionName = basename( dirname( $fileName ) );
+ foreach ( $filesToTest as $extensionName => $fileName ) {
+ if ( is_int( $extensionName ) ) {
+ // If there's no extension name because this is coming
+ // from the legacy global, then assume the next level directory
+ // is the extension name (e.g. extensions/FooBar/parserTests.txt).
+ $extensionName = basename( dirname( $fileName ) );
+ }
$testsName = $extensionName . '__' . basename( $fileName, '.txt' );
$parserTestClassName = ucfirst( $testsName );