Commit graph

72349 commits

Author SHA1 Message Date
Amir Sarabadani
d56829dca8 Clean up array() syntax from docs, part VI
Change-Id: Ib0eea494e2065c7ab356dc45fd174544a9c1c942
2016-09-12 14:36:37 +04:30
Tim Starling
3979e37fcf parserTests.php: Fix exit status
The return value of Maintenance::execute() is discarded, not used as an
exit status.

Change-Id: I9dd92e43b5b1df1a63d0e8302d360d0bb0f57e7b
2016-09-12 06:48:17 +00:00
Tim Starling
b6730b1ea3 Release notes for parser tests refactor
Change-Id: Ic5cd1e368067024bd264ae991d04f61c58535cd1
2016-09-12 16:29:24 +10:00
Tim Starling
6117fb244f Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.

Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.

General:

* Split out the pre-Setup.php global variable configuration from
  phpunit.php into a new class called TestSetup, also called it from
  parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
  Maintenance.
* In Setup.php improved "caches" debug output.

PHPUnit frontend:

* Delete the entire contents of NewParserTest and replace it with a
  small wrapper around ParserTestRunner. It doesn't inherit from
  MediaWikiTestCase anymore since integrating the setup code was an
  unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
  instantiable TestSuite class instead of just a static method. Got rid
  of the eval(), just construct TestCase objects directly with a
  specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
  support them anymore. Note that --filter now works just as well as
  --regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
  for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
  once, as is implied by the documentation.

parserTests.php frontend:

* Made parserTests.php into a Maintenance subclass, moved CLI-specific
  code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
  backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
  to the old default behaviour

Test file reading and interpretation:

* Rename TestFileIterator to TestFileReader, and make it read and buffer
  an entire file, instead of iterating.
* The previous code had an associative array representation of test
  specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
  unnecessary now that all extensions use ParserFirstCallInit. Resurrect
  an old interpretation of the feature which was accidentally broken: if
  a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
  human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
  articles in them. This greatly speeds up execution time when --regex
  matches a small number of tests. It may possibly break extensions, but
  they would have been randomly broken anyway since there is no
  guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
  link formatting, life is complicated enough already. It can go in
  OutputPageTest if that's a thing we really need.

Result recording and display:

* Make TestRecorder into a generic plugin interface for progress output
  etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
  a long inheritance chain. All test recorders now directly inherit from
  TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
  frontend. Most events are ignored since they are never emitted in the
  PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.

Setup and teardown:

* Introduce a new API for setup/teardown where setup functions return a
  ScopedCallback object which automatically performs the corresponding
  teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
  here which was simply copied from Setup.php without review, and had
  nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
  performance, give staticSetup() precedence in cases where they were
  both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
  from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
  don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
  I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
  customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
  handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
  now! Also, the relevant parser tests were removed from the Math
  extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
  allows setup/teardown to be done once for each batch of articles
  instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
  copied in from Setup.php in 2010, and are redundant since we do
  actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
  this alone.

Fuzz tests:

* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
  where they used to reside.

Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-12 16:11:42 +10:00
Tim Starling
df29a359f8 Renames preparatory to parser tests refactor
Since in several cases, with an all-in-one commit, git's file rename
detection failed, I split the renames out into their own commit to
make review easier. Some changes here won't make complete sense without
the following commit.

* Moved TestsAutoLoader to tests/common/. It will be joined by a friend.
* Renamed ParserTest to ParserTestRunner, since the former name was
  overly generic.
* Renamed TestFileIterator to TestFileReader. Please see the subsequent
  commit for rationale.
* Moved parserTests.php to tests/parser/. It was the only file left in
  tests/, and it should have been moved to tests/parser years ago,
  analogous to phpunit.php.
* Renamed NewParserTest to ParserIntegrationTest. This was a tricky one,
  apparently the name has to end in "Test" or else the structure test
  will fail. Analogous to ParserMethodsTest etc. Rationale: because it's
  not new anymore.
* Renamed MediaWikiParserTest to ParserTestTopLevelSuite and moved it to
  the suites directory. A more descriptive name. Being in suites/
  shields it from StructureTests, and is correct anyway.

Change-Id: Iddc6eaf815fdd64b3addb8570b4b6303ab99d634
2016-09-12 15:46:15 +10:00
Aaron Schulz
fdd40afc42 Avoid "No transaction is active" saveFileDependencies() tests errors
Unit tests run in CLI mode without DBO_TRX

Change-Id: Icee9cf84cb9e057b329dd3960fcc9b238af478a3
2016-09-11 20:46:43 -07:00
jenkins-bot
332a1d8822 Merge "Avoid "Column md_module cannot be null" error in unit tests" 2016-09-12 03:06:17 +00:00
jenkins-bot
3d7e37edd0 Merge "Use memory job queue for unit tests" 2016-09-12 01:11:29 +00:00
Aaron Schulz
402603e12f Use memory job queue for unit tests
Change-Id: I13586b9873bf09acd4a458a7af75a25d9b980fca
2016-09-11 17:23:54 -07:00
Aaron Schulz
722fcbc4f8 Avoid "Column md_module cannot be null" error in unit tests
Change-Id: I06755cbd907d8a595e55080e37779eb9d0c026ab
2016-09-11 17:07:52 -07:00
jenkins-bot
196db34293 Merge "Display an error message when the validataion of a radio input fails because user did not provide any input." 2016-09-11 23:56:41 +00:00
Huji Lee
1e7b73bb06 Display an error message when the validataion of a radio input fails because user did not provide any input.
Bug: T107486
Change-Id: Ie3a9cc11f285cadec1dde32f820643d1aabd0d1b
2016-09-11 19:47:55 -04:00
jenkins-bot
7b1f5ff878 Merge "Remove useless LoadBalancer::parentInfo() method and calls" 2016-09-11 23:26:10 +00:00
jenkins-bot
d1979242e2 Merge "Use ESTIMATE_DB_APPLY for total transaction time estimate" 2016-09-11 23:16:58 +00:00
jenkins-bot
1b826ae086 Merge "Add LBFactory::getChronologyProtectorTouched() method" 2016-09-11 23:08:50 +00:00
Aaron Schulz
703b0691ca Use ESTIMATE_DB_APPLY for total transaction time estimate
Individual write queries already do this, but the COMMIT step
still used the old accounting.

Change-Id: I416a524d6652f933cbc49033b49745db732c8b92
2016-09-11 16:04:21 -07:00
Aaron Schulz
f07408d860 Remove useless LoadBalancer::parentInfo() method and calls
Change-Id: I3550d1249c63ee5bec51dd343b3e26b515c4827e
2016-09-11 15:15:34 -07:00
Translation updater bot
0e928cc6b7 Localisation updates from https://translatewiki.net.
Change-Id: I7f5b889fba9e6a54d318b58f68c58179d1f5fba7
2016-09-11 22:19:31 +02:00
Aaron Schulz
6b8effebb3 Add LBFactory::getChronologyProtectorTouched() method
This lets callers check whether a user recently change a DB and
possibly try harder to reflect certain changes or refresh caches.

Also simplified some logging code a bit.

Change-Id: Ia1168cf0d46cfdee046838ce4c5a6294e4d81760
2016-09-11 20:07:43 +00:00
jenkins-bot
5e053d5772 Merge "Simplify some LoadBalancer methods that do iteration" 2016-09-11 20:06:15 +00:00
Aaron Schulz
5d233fdc07 Use DB_REPLICA in ContribsPager
Change-Id: Ic225b9c41d989722677caf323846783d7e0638a4
2016-09-11 06:36:51 -07:00
Aaron Schulz
3f4215b7ec Simplify some LoadBalancer methods that do iteration
Use foreachOpenConnection() and foreachOpenMasterConnection() in
more methods rather that copying that code. Also made the logic
for closeConnection() simpler by using the "serverIndex" field LB
always sets on the connection handles.

Change-Id: I5cb66da2395773d64b84d4115cbcdfc69c9e5e00
2016-09-11 06:27:14 -07:00
jenkins-bot
8cf47509be Merge "Force primary index for RevDelRevisionList query" 2016-09-11 00:49:07 +00:00
jenkins-bot
c24cbb13df Merge "Revert "Clean up user handling in UploadStash"" 2016-09-11 00:35:32 +00:00
jenkins-bot
6aa514ea8c Merge "Use Database::timestamp in LocalFile::loadFieldsWithTimestamp" 2016-09-11 00:28:14 +00:00
Roan Kattouw
59f09caabc Force primary index for RevDelRevisionList query
To work around an optimizer bug in MySQL where the
index on (rev_page, rev_id) is picked which mysteriously
leads to very slow execution times and timeouts.

In theory, the index being forced here is (rev_id),
which is fine for this query. In WMF production,
it can also be (rev_id, rev_user) (still fine), or
(rev_page, rev_id) (the index we're trying to avoid).
Mysteriously, the optimizer bug doesn't happen if
(rev_page, rev_id) is the primary key, so this still
behaves OK.

Bug: T104313
Change-Id: I15c68ba29309dca8dea274f19389d139a82784aa
2016-09-10 17:25:10 -07:00
Translation updater bot
17f905290a Localisation updates from https://translatewiki.net.
Change-Id: I1cf537e516dca258169590bfec492452b2abf956
2016-09-10 22:49:05 +02:00
umherirrender
1bc2b88bb2 Use Database::timestamp in LocalFile::loadFieldsWithTimestamp
Postgres needs a special timestamp format on sql which is handled by
Database::timestamp.

Bug: T145066
Change-Id: I8db958ecbea7c12af8caf8354490e59500975e4b
2016-09-10 22:36:50 +02:00
Bartosz Dziewoński
d40cb98798 mw.ForeignApi: Allow anonymous requests
When 'anonymous: true' is passed:

* Send 'origin=*' in the query parameters, so that MediaWiki treats
  the request as anonymous (same as for JSONP requests).
* Set 'withCredentials: false' in AJAX options, so that the browser
  doesn't try to send cookies and accepts the response with the
  'Access-Control-Allow-Origin: *' header.

Bug: T145294
Change-Id: Ic93d733cb9e1b1d7301f8975c68ab7ded778845a
2016-09-10 21:05:04 +02:00
Bartosz Dziewoński
44947af94a Revert "Clean up user handling in UploadStash"
This reverts commit 58713d2b16.

Bug: T145228
Change-Id: Ic62f19109f98fab9dd029acccecd6518b649e34b
2016-09-10 15:27:49 +00:00
jenkins-bot
b95260df1b Merge "Clean up tests for FauxRequest/WebRequest" 2016-09-10 06:34:19 +00:00
Aaron Schulz
751c4d395f Make the page JOIN in RevDelRevisionList actually apply
The table was missing from the tables array

Change-Id: I613a2075e5d18210c8187587462b0f000769aec2
2016-09-09 23:21:32 -07:00
Timo Tijhof
3de9d6721e Clean up tests for FauxRequest/WebRequest
Follows-up 1ac5474b7b and d18d030d57.

* Always mock WebRequest in WebRequestTest.
  Avoid using FauxRequest, can easily cause false positives (it's already
  avoided in one case of that reason).

* Add a few smoke/integration tests in FauxRequest to make sure the parent
  methods work as expected, given the internal method being overridden
  in FauxRequest.

Change-Id: I1bf528f3c578ecb171a3ff4f17b26f9bb02b4f47
2016-09-09 15:35:19 -07:00
jenkins-bot
b11107325f Merge "Add more version notes to WANObjectCache" 2016-09-09 21:31:54 +00:00
jenkins-bot
c075679289 Merge "Chinese Conversion Table Update 2016-6" 2016-09-09 21:26:08 +00:00
Aaron Schulz
ad0f205feb Add more version notes to WANObjectCache
Change-Id: Ia1b74b568d2b5137c7096a3b4549ac2cd4c7fa93
2016-09-09 13:41:03 -07:00
Translation updater bot
601d1a0021 Localisation updates from https://translatewiki.net.
Change-Id: I0a15f0872c222b8be6576ea43a98cbc14c8c3a1a
2016-09-09 22:22:25 +02:00
jenkins-bot
dff332b713 Merge "objectcache: add "staleTTL" option to WANObjectCache::set()" 2016-09-09 17:38:45 +00:00
jenkins-bot
5543e00753 Merge "Hide signup/login/logout links when they would not work" 2016-09-09 15:18:36 +00:00
jenkins-bot
c64d672f59 Merge "Make $wgRevisionCacheExpiry default to one week" 2016-09-09 10:37:49 +00:00
jenkins-bot
d908ac0d44 Merge "JsonContentHandler: Make sure makeEmptyContent() is valid JSON" 2016-09-09 08:29:15 +00:00
jenkins-bot
c254d76860 Merge "Cleanup and re-indent some WANObjectCache docs" 2016-09-09 08:17:28 +00:00
Aaron Schulz
843c112884 objectcache: add "staleTTL" option to WANObjectCache::set()
Change-Id: Ib9386a8ad4ab98d07d0a3784e3afffeeca9bbd6e
2016-09-09 01:05:55 -07:00
jenkins-bot
6281fb4aad Merge "Allow --profile to be used in phpunit.php" 2016-09-09 07:58:55 +00:00
Aaron Schulz
55b4d2f620 Cleanup and re-indent some WANObjectCache docs
Change-Id: Ibf7092297ce53fd21e478a6f87a16f9b4373ad85
2016-09-09 00:57:57 -07:00
jenkins-bot
01ceb8cc9c Merge "Split up testHelpers.inc, break off fuzz testing" 2016-09-09 07:56:46 +00:00
jenkins-bot
f7d159ae11 Merge "WebRequest: Add more unit tests" 2016-09-09 06:54:45 +00:00
Kunal Mehta
303b4057f9 LinkBatch: Set visibility and document constructor
Change-Id: I9d8edeb214b9d7507826004e470dcb5c1ef015f6
2016-09-08 22:02:39 -07:00
Kunal Mehta
5d52874ddf Title: Document that Title::compare() can be used for LinkTargets
It only depends upon functions that are all in the LinkTarget interface.

Change-Id: I95e598ea6014ced8f1b947c283dd0b542756b8e2
2016-09-08 21:58:55 -07:00
Timo Tijhof
1ac5474b7b WebRequest: Add more unit tests
* Complete detectServer() coverage,
  test $wgAssumeProxiesUseDefaultProtocolPorts.
* Complete getAcceptLang() coverage.
* Add tests for getGPCVal() normalisation.
* Add tests for other getter methods.

Also:

* Ignore __construct() coverage as it only sets up properties from
  global state. The use of those properties are covered.

* Make normalizeUnicode() visibility explicit.

Change-Id: I6504136e6df47e504bc2e0e91fedddd2625f19d9
2016-09-08 21:58:09 -07:00