https://bugzilla.wikimedia.org/show_bug.cgi?id=20077
Summary: PHPunit tests in .../phase3/tests/ directory no longer
work
Product: MediaWiki
Version: 1.16-svn
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: Normal
Component: Maintenance scripts
AssignedTo: [email protected]
ReportedBy: [email protected]
Created an attachment (id=6429)
--> (https://bugzilla.wikimedia.org/attachment.cgi?id=6429)
patch to fix 5 bugs in .../phase3/tests/ directory and to add a --runall option
to run-tests.php
The attached patch fixes several bugs in and adds one feature to
/phase3/tests/. (BEFORE COMMITTING THIS PATCH, PLEASE READ THE ARCHITECTURAL
DISCUSSION IN THE 3 PARAGRAPHS AT END OF THIS TEXT) The patch is merged, diffed
and tested against r54465. The following files are affected:
* run-test.php: fixed bug related to the pathname to the PHPUnit directory.
Added a --help command line option and a --runall option. The latter allows
run-test to execute all PHPUnit tests in the /tests/ directory. In order to
utilize this option and satisfy other constraints (see below for discussion) I
renamed SearchEngineTest.php to SearchEngineTest.inc. This makes sense since
SearchEngineTest.inc contains only an abstract class, not directly executable
code. This patch adds SearchEngineTest.inc and deletes SearchEngineTest.php
from the distribution.
* ArticleTest.php: fixed bug related to global variables that may or may not
exist. Tests for global variable existence before attempting to save it for
later restoration.
* LocalFileTest.php: fixed bug related to a change in the directory structure
used to store thumbnails in file based repositories.
* MediaWiki_TestCase.php: fixed bug related to a change in the name of the
global variables $wgDBadminuser (-> $wgDBuser) and $wgDBadminpassword
(->$wgDBpassword). Also fixed bug that wrote over $wgDBprefix, causing creation
of test tables to fail. Tested code for both MySQL version >= 4.1 and < 4.1 (by
creating temporary debug version of if statement - tests occured using MySQL
version 5.0.41).
* README: Updated so it mentions requirement to set $PhpUnitDirectory in
run-test.php and explains use of new --runall option.
* SearchEngineTest.php: renamed to SearchEngineTest.inc so algorithm in
run-tests.php that automatically finds all PHPUnit tests works (see below).
* SearchMySQL4Test: renamed 'SearchEngineTest.php' to 'SearchEngineTest.inc' in
require_once() call.
There is an architectural issue related to this patch that needs attention by
senior developers. I decided to add the --runall option to run-test.php so we
can run the PHPUnit tests without relying on the make utility. However, in
order to retain the ability to use the current Makefile, I used an algorithm to
find the PHPUnit tests in the /tests/ directory that isn't very pretty.
Specifically, the algorithm assumes all files of the form <prefix>Test.php are
PHPUnit tests (e.g., ArticleTest.php). This follows the convention used by
PHPUnit tests that the unit test for class <class> is named <class>Test. This
convention was used by the developer who initially created the PHPUnit tests
for file names as well.
A better architectural approach would be to create a subdirectory of /tests/,
say PHPUnitTests, that contains all PHPUnit tests. This, however, requires a
structural change to the /tests/ directory that is sufficiently major that it
requires review. If this approach is considered superior, it would be easy to
modify run-tests.php to run all tests in the PHPUnitTests sub-directory. If
senior developers give me feedback in bug ticket comments that this strategy is
better, I can provide an updated patch fairly quickly.
Another architectural approach is to create a file in /tests/ that lists the
PHPUnit tests to run. This has the disadvantage that it requires updating
whenever a new test is added. My view is this is a less desirable option.
--
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l