Commit graph

39 commits

Author SHA1 Message Date
Daimona Eaytoy
8176dac4a6 phpunit: Remove MediaWikiPHPUnitTestListener
The two hooks were moved to a PHPUnit extensions which uses hooks. The
rest was simply deleted. The reason for this change is that TestListener
was removed in PHPUnit 9, with PHPUnit hooks as replacement.

No hooks exist for startSuite/endSuite, plus we should avoid adding too
much functionality: if the output of PHPUnit isn't clear, that should be
reported upstream. Additionally, PHPUnit hooks were also deprecated in
PHPUnit 10, which means that extending PHPUnit becomes more and more
difficult. As such, the two hooks will be hard-deprecated & removed
soon.

Removing all these wfDebugLog and other function calls should also
hopefully speed up the suite.

Bug: T243600
Bug: T225730
Change-Id: I2b67cd0074aca4b0ea76696ce9f24be68f5f88f8
2021-03-20 15:55:26 +01:00
Daimona Eaytoy
86c0a64e91 Use PHPUnit hooks for augmented logs
The TestListener interface is deprecated. This replacement has the
downside of using a public static property, but there seems to be no
other way to pass extra data to the printer (BTW: the ResultPrinter
class is internal, so it'd be even better if we could avoid subclassing
it).

Bug: T243600
Change-Id: I083146b7336ac09dfd077c8e6817553738282662
2020-09-22 11:28:10 +00:00
Tim Starling
15e058d46e Show the PHPUnit help in phpunit.php --help
Split Maintenance::showHelp() from Maintenance::maybeHelp(), and
override it in phpunit.php. Expose PHPUnit's protected method
Command::showHelp() in our subclass and call it, so that running
"phpunit.php  --help" causes the MediaWiki options to be shown, followed
by the PHPUnit options.

Change-Id: I4687d484e322a465af0492789645819cd8a7b67c
2019-11-25 17:19:20 +11:00
Daimona Eaytoy
1c20e1e032 phpunit: Add typehints for PHPUnit 8
Split from Ic14f5debc53e55d67146dc96279d26dfd52b4000.

Bug: T192167
Change-Id: Iec3b9f6f3702578ac76806e73ff0263aa15ac458
2019-11-17 15:15:24 +01:00
Daimona Eaytoy
a184478c14 phpunit: delete MediaWikiTestResult and TestRunner
These were made final in PHPUnit8. Since there seems to be no easy way
to work around that, partially revert
Ibcaf9ca81c8dc63cce6dc6f6fb1fffee19f8804e and start using static
properties again (cfr. T192167#5550034).

Split from Ic14f5debc53e55d67146dc96279d26dfd52b4000.

Bug: T192167
Change-Id: I3fe163738662ae41eb275a0327cb33187290a70f
2019-11-17 15:02:54 +01:00
Max Semenik
fb06e4cd85 Update tests to use PHPUnit 6 class names
Bug: T192167
Change-Id: I42b0c8908b4968b95b08f861a40af18dc79fa0a1
2019-10-06 01:01:28 -07:00
Erik Bernhardson
96657099fc Report logs for each individual test failure
The initial implementation of reporting logs with test failures was
incorrect, it always reported the logs of the most recent test run.
Attach logs to the Test when a failure is reported and pull them
back out in the result printer.

Bug: T217489
Change-Id: I5aa55d6fa7a7ec03a2e71636b6b0366ea40605cb
2019-03-06 15:13:53 -08:00
Erik Bernhardson
56ffbc2a4e Print logs generated during unit test when test fails
When a unit test fails it is possible, perhaps even likely in some
cases, that some code that was run logged useful information about
how that failure came to be.

Help people out, tell them what happened!

Change-Id: I30bbc31799a65024868678d052fec9aafacc1aff
2019-02-06 14:43:32 -08:00
Aryeh Gregor
383a925f68 Output only to stderr in unit tests
Otherwise, session tests don't work in PHP 7.2 because headers are
already sent: https://bugs.php.net/bug.php?id=75628

Bug: T206476
Change-Id: Ie88db4a61a56b756c6445d2579a2f30da22c3ee8
2018-10-08 21:04:12 +03:00
Tim Starling
65adc37348 Make phpunit.php less hackish, and install the listener unconditionally
* Instead of rewriting $argv, add a Command subclass called
  MediaWikiPHPUnitCommand which overrides the configuration using the
  stub functions in Command which were provided for that purpose.
* Revert c804a0b5b9, which added redundant debug output to tests,
  and instead install the MediaWikiPHPUnitTestListener listener
  unconditionally. Deprecate and make non-functional the --debug-tests
  option. If you don't want tests to produce debug output, you can
  always turn the channel off.
* Because I added our listener to the listener array instead of making
  it override the printer, it's no longer necessary to derive from
  PHPUnit\TextUI\ResultPrinter. Instead we derive from BaseTestListener.
  So we don't need to call the (empty) parent methods.
* Remove the --with-phpunitclass feature since it doesn't work with this
  scheme.
* Instead of passing CLI args to MediaWikiTestCase via a public static
  variable, inject it non-statically by overriding the TestRunner and
  TestResult.
* Remove --file, which has been non-functional since my 2016 refactor.

Change-Id: Ibcaf9ca81c8dc63cce6dc6f6fb1fffee19f8804e
2018-09-04 15:30:20 +10:00
addshore
892a992ab8 Remove MediaWikiPHPUnitCommand
All functionality has been moved to other places

Change-Id: I6b6b0ef846bc63108c4dff9e17098432fd9d1697
2014-08-02 21:35:34 +00:00
addshore
c454a77916 Move debug-tests out of MediaWikiPHPUnitCommand
This also slightly refactors MediaWikiPHPUnitTestListener
so we can pass it into phpunit directly using the
--printer option

Change-Id: I6a19e3902130eeba6a0941f24a4f440b712058e5
2014-08-02 21:34:34 +00:00
addshore
9d69b15958 Move profile In/OUT call out of MWPHPUnitCommand
Change-Id: I710fddc20e88745c9091432dff87b5e361c1f71a
2014-05-05 12:55:56 +00:00
addshore
159dc79049 Move teardownTestDB and wfLogProfilingData out of MWPHPUnitCommand
Change-Id: Ic175c1457e7f76a2b5232a2b5d3563c5982cfee2
2014-05-05 13:55:42 +01:00
addshore
e7867c803f Remove includepath stuff from MediaWikiPHPUnitCommand
Change-Id: I949c1ca350a28c606fba7406e9904e836e596b49
2014-05-05 13:17:22 +01:00
addshore
fefc843bd7 Remove color opt setting from MediaWikiPHPUnitCommand
Change-Id: I08d3b53f80520452aef3fcf2017747406a38664d
2014-05-05 13:09:56 +01:00
umherirrender
5dbfd5bf80 Fixed spacing
- Removed trailing spaces in comments
- Removed multiple empty lines
- Removed space after object operator

Change-Id: I9fd3256ab490c7cd2034de3fd94e6be6e6d6d8f2
2013-11-21 18:52:25 +00:00
umherirrender
24bfde2710 Fix spacing and break some lines
Change-Id: Ia57685d8858e02e399ad5c75ce64d12609d340ac
2013-08-24 17:06:25 +02:00
daniel
41e2e116e2 Allow debugging of unit tests via wfDebugLog.
This adds a listener to the PHPUnit test runner that will report
testing progress via wfDebugLog. This is useful for debugging
situations in which phpunit itself fails to report errors and
does not terminate normally. Having a debug log should at least
help with locating the trigger of the problem.

Change-Id: I433537a7f26197d8cff6f133e26ae5709871500f
2013-07-25 09:54:14 +00:00
Alexandre Emsenhuber
6a0e704c62 Fix --file parameter description in MediaWikiPHPUnitCommand.php
Change-Id: Ie134c06943be38cd65f8dae54332d38278ea0f96
2013-05-11 08:01:36 +02:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00:00
Aaron Schulz
9cc7e6a39a [JobQueue] Cleanups for JobQueueRedis.
* Cleaned up 'server' option to not fragment the pool.
  Also made it actually match the documentation.
* Made it use doGetPeriodicTasks() for job recycling.
* Made it so that other job queue classes can be tested.
* Renamed "redisConf" => "redisConfig".
* Tweaked comments about the "random" order option.

Change-Id: I7823d90010e6bc9d581435c3be92830c5ba68480
2013-02-21 05:38:01 +00:00
Siebrand Mazeland
ac63001d8e Update formatting
1 of n.

Change-Id: I852729f08bbb0c5e39c2db44362ccdc7f59dcc08
2013-02-14 12:22:13 +01:00
Antoine Musso
0fd05285d7 pass codesniffer on tests/
Fix almost all occurences of the following sniffs:

Generic.CodeAnalysis.UselessOverridingMethod.Found
Generic.Formatting.NoSpaceAfterCast.SpaceFound
Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma
Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine
Generic.PHP.LowerCaseConstant.Found
PSR2.Classes.PropertyDeclaration.ScopeMissing
PSR2.Files.EndFileNewline.TooMany
PSR2.Methods.MethodDeclaration.StaticBeforeVisibility

Change-Id: I96aacef5bafe5a2bca659744fba1380999cfc37d
2013-01-28 12:14:26 +01:00
Matthias Mullie
74f581e348 Added merge() function to BagOStuff for CAS-like functionality.
* merge() will use CAS if supported or use locking otherwise
* The lock()/unlock() methods now have a default implementation
* added unit tests for merge

Change-Id: Ic27088488f8532f149cb4b36e156516f22880134
2013-01-10 09:03:09 +01:00
daniel
278210a26b Make --wiki work with phpunit.php.
This introduces --wiki as a dummy paramter to the PHPUnit job, so it no
longer complains and errors our. The parameter is already picked up
correctly be Maintenance.php.

I have a wiki family setup with a Wikibase repo and client using the
same install base, and the same LanguageSettings.php. Different
databases etc are triggered based on the request URI or, for maintenance
scripts, by the --wiki paramters.

I can run maintenance scripts etc against the client setup using --wiki
client. But how do I run unit tests against the client setup? If I try:

  $ phpunit.php --wiki client
  unrecognized option --wiki
  $

That's because after Maintenances.inc (correctly) processes the command
line parameters, phpunit also tries to process them - and complains,
because it doesn't know --wiki.

This change introduces --wiki as a dummy parameter to phpunit to work
around this. With this patch applied, I can run unit tests against my
client setup using phpunit.php --wiki client as expected.

Change-Id: I6cf319cdbdf55a541c986838d370aa324994ae78
2012-12-13 13:11:36 +00:00
daniel
e2bb376dd7 Added profiling to test runner.
MediaWikiTestCase now calls wfProfileIn/wfProfileOut for each call
to a test function. This makes it easy to track down slow tests.

Change-Id: I5ff2fea957c082f41da37936fe44948ad006f573
2012-11-22 19:34:32 +01:00
daniel
e606537090 Log profiling data when tests have finished.
Previously, no profiling data was recorded from unit test runs.
That made it impossible to a) use unit tests for selective profiling
of individual functions, and b) made it impossibel to profile
the tests themselves.

This change fixes this problem by calling wfLogProfilingData()
after the test runner has finished.

Thaks to Hashar for some ideas, especially the fix in GlobalFunctions.

Change-Id: Iaa295115f3c4eb3b529388dcd953fe8932448b3e
2012-11-16 20:14:29 +01:00
jeroendedauw
38c7f444e1 Use __DIR__ instead of dirname( __FILE__ )
We can now do this since we finally switched to PHP 5.3 for MW 1.20 and get rid of the silly dirname(__FILE__) stuff :)

Change-Id: Id9b2c9cd2e678197aa81c78adced5d1d31ff57b1
2012-08-27 21:45:00 +02:00
Aaron Schulz
609cf8d522 * Modified StoreBatchTest and FileBackendTest to allow specifying a registered backend to use
* Improved FileBackendTest file pruning and added more getFileList() tests
2012-01-22 00:34:04 +00:00
Jure Kajzer
5933586266 some more oracle-phpunit-fu (should not affect non-oracle)
* CloneDatabase - already droping tables in internal function, removed duplicate action
* DatabaseOracle - stopped ignoring "temporary" parameter
* added two parameters to phpunit (use-normal-tables & reuse-db), default actions stay the same
* with reuse-db oracle phpunit test run on oracle down to 1m 20s ;)
2011-11-10 13:29:32 +00:00
Antoine Musso
aee9703dda space to tab
follow up r101480
2011-11-01 16:00:49 +00:00
Antoine Musso
2d64dcd9f9 (bug 32022) phpunit.php can not execute from another directory
Adds tests/phpunit to the include_path to let PHPUnit find out our files.
Also add to change the suite.xml paths from './path' to 'path' so
stream_resolve_path() correctly find out the suite by using include_path
2011-11-01 15:09:52 +00:00
Antoine Musso
e9698b09d8 enable colors in PHPUnit (redoing r89179).
suite.xml now comes with colors=true. Under Windows, we override the
setting by forging a --no-colors. One can still force color usage
under windows by using --colors.
2011-08-16 18:23:13 +00:00
Mark A. Hershberger
a6722cc9aa w/s changes. 2011-06-02 19:32:45 +00:00
X!
332e01addf Add parsertest specific help to PHPUnit.php 2011-01-01 06:49:00 +00:00
X!
f8d74604fd More work on new parser tests:
-No need to specify a new function for each argument, use PHP5 magic to automatically set it
-Create (g|s)etCliArg() functions
-Implement some features from the old parser tests
2011-01-01 05:53:04 +00:00
Platonides
3aa8a1d61a Replace the global $additionalMWCLIArgs with a class variable.
Provide a default value for verbose since it is checked regardless of existance.
2010-12-29 16:24:59 +00:00
X!
edbf743aeb Make MediaWikiParserTest work now in PHPUnit. There are still a few bugs, such as stopping tests if one fails,
lack of fuzz testing and other parser test options, and the DB creation is still a little flaky.
A MediaWikiPHPUnitCommand class had to be created to allow for custom CLI parameters.
2010-12-29 02:23:51 +00:00