From d0823139f3529cb55af8bfb0eba3a249b718c94f Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Fri, 13 Feb 2015 11:31:24 -0800 Subject: [PATCH] More descriptive message for autoloader failures Previously, it just failed with "No such file or directory" without explaining what's wrong where why. Change-Id: I776e8fe61f74fd21295da48a45c86ffed9489e23 --- tests/phpunit/structure/AutoLoaderTest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/structure/AutoLoaderTest.php b/tests/phpunit/structure/AutoLoaderTest.php index 2142061896..681b2d23cd 100644 --- a/tests/phpunit/structure/AutoLoaderTest.php +++ b/tests/phpunit/structure/AutoLoaderTest.php @@ -44,7 +44,7 @@ class AutoLoaderTest extends MediaWikiTestCase { $files = array_unique( $expected ); - foreach ( $files as $file ) { + foreach ( $files as $class => $file ) { // Only prefix $IP if it doesn't have it already. // Generally local classes don't have it, and those from extensions and test suites do. if ( substr( $file, 0, 1 ) != '/' && substr( $file, 1, 1 ) != ':' ) { @@ -53,7 +53,19 @@ class AutoLoaderTest extends MediaWikiTestCase { $filePath = $file; } + if ( !file_exists( $filePath ) ) { + $actual[$class] = "[file '$filePath' does not exist]"; + continue; + } + + wfSuppressWarnings(); $contents = file_get_contents( $filePath ); + wfRestoreWarnings(); + + if ( $contents === false ) { + $actual[$class] = "[couldn't read file '$filePath']"; + continue; + } // We could use token_get_all() here, but this is faster $matches = array(); -- 2.20.1