Commit graph

155 commits

Author SHA1 Message Date
Tim Starling
a387fee397 Split up testHelpers.inc, break off fuzz testing
* Split up testHelpers.inc into one class per file, with the file named
  after the class per the usual convention. Put them in tests/parser
  since they are all parser-related, even though a couple are reused by
  other unit tests.
* Also rename parserTest.inc and parserTestsParserHook.php to follow the
  usual convention, and split off ParserTestResultNormalizer
* Move fuzz testing out to its own maintenance script. It's really not
  helpful to have fuzz testing, which is designed to run forever,
  exposed as a PHPUnit test.
* Increased fuzz test memory limit, and increased the memory headroom for
  getMemoryBreakdown(), since HHVM's ReflectionClass has an internal
  cache which uses quite a lot of memory.
* Temporarily switched a couple of ParserTest methods from private to
  public to support fuzz testing from a separate class -- I plan on
  replacing this interface in a subsequent commit.

Change-Id: Ib1a07e109ec1005bff2751b78eb4de35f2dfc472
2016-09-08 09:06:45 +10:00
Tim Starling
65054c94c2 NewParserTest: tear down globals before returning early
teardownGlobals() was called at the end of testParserTest(), but not
when returning early or throwing a "skipped" exception. This caused a
test failure when VisualEditor tests were run after parser tests, due to
$wgThumbLimits having the value set in parser tests.

Change-Id: I12d9365813fc51c15f6649084c373f5b7ccfac26
2016-08-26 10:17:12 +10:00
Kunal Mehta
9ae93d74fd Override MediaHandlers in tests using MediaWikiServices
Change-Id: Ie39fd9243e7817191b87179f792d932f7b96de0c
2016-08-03 16:47:46 -07:00
Tim Starling
8a57d86ea7 Rewrite TidySupport and add option --use-tidy-config
* Have TidySupport provide $wgTidyConfig instead of the legacy globals
* Add --use-tidy-config option to parserTests.php. This tells
  TidySupport to use the tidy configuration from LocalSettings.php
  instead of the traditional safe defaults.
* Add a way for TidySupport to disable tidy via $wgTidyConfig, using
  driver=>disabled

Change-Id: Ie76e68e2d5238d0a1aef49a1a815c0d1cd8bfdae
2016-07-12 14:25:03 -07:00
jenkins-bot
ff13c3d92a Merge "Add an audio file parser test" 2016-06-14 16:46:26 +00:00
Kunal Mehta
ee5078708a Add a parser test for $wgNoFollowDomainExceptions functionality
Verify that domains on the exception list don't get a "nofollow"
attribute.

Change-Id: I01a7fc0fd9ccd21069beb26dcf3f775c79e00202
2016-05-31 22:20:36 -07:00
Derk-Jan Hartman
1d41e80818 Add an audio file parser test
Change-Id: I478b1ea23700a66520d51ec40dcf5c392318d8b6
2016-05-18 17:48:30 +02:00
Brian Wolff
ee4d5c6eed Remove support for $wgWellFormedXml=false
tl;dr: Having unnessary complexity in security critical code is bad.

* Extra options add extra complexity and maintenance burden
** Thus we should only have one html output mode. well formed = false
     was already vetoed in T52040, so lets go with WellFormed=true.
* Options which are used by very few people tend to get tested less
* Escaping is an area of code where we should be very conservative
* Having escaping rules depend on making assumptions about which
    characters various browsers consider "whitespace" is scary
* $wgWellFormedXml=false has had a negative security impact in the
    past (Usually not directly its fault, but has made other bugs
    more exploitable)
* Saving a couple bytes (even less bytes after gzip taken into
    account) is really not worth it in this context (imho).

Change-Id: I5c922e0980d3f9eb39adb5bb5833e158afda42ed
2016-05-12 17:40:01 -04:00
Kunal Mehta
21070456b0 Parser tests: Also register namespace 101 to accompany 100
It is expected that namespaces (except for NS_SPECIAL) will have a
paired subject and talk namespace. While not having the accompanying
talk namespace mostly works, it can cause unexpected issues when some
code paths (e.g. WikiPage::onArticleCreate()) expect it to exist.

Change-Id: I8f02fd886d0256679dfc10e1743204da4c6678b7
2016-05-12 11:37:00 -07:00
Kunal Mehta
f1e8d27a91 Add TitleParser and TitleFormatter to MediaWikiServices
Depends-On: Ibfd0a7f98f50506cd8402f966682f320bf715c8a
Change-Id: I81d48616afd1ab2bde1a5f1d12f4aefb1c866d43
2016-05-11 10:18:40 -07:00
Tim Starling
09ff912ddd parserTests.php: fix three bitrot bugs with --record
* Add a subtest index to the recorded test name, to avoid an SQL
  duplicate key error.
* Introduce TestFileDataProvider. Previously, the order of named
  parameters in TestFileIterator was relevant but undocumented, so
  adding a subtest parameter broke phpunit tests.
* Don't implicitly commit (commitMasterChanges) an explicit transaction,
  since that now causes a fatal error.
* Reset namespace cache as in NewParserTest.php, so that the MemoryAlpha
  article insertion doesn't fail. This was only visible with --record
  because the namespace cache is initialised by
  SpecialVersion::getVersion() during recorder setup.

Change-Id: Ied4636b4acbf1d268e45901fed4d4e077b5ed666
2016-04-08 12:20:50 +10:00
Timo Tijhof
32f374074c parserTest: Remove mention of non-existent 'noxml' option
The 'noxml' documentation in parserTests.txt was added in 2006 (7eea2398; r12504),
however it wasn't actually implemented.

It wasn't until 2009 (7aa4a8f9; r54767) that $wgWellFormedXml was created,
which defaults to true and has no relation to this option.

Remove the 'noxml' options from existing tests.

Change-Id: Ie3ae9f491b5747716080607b81b9763bf2bcc889
2016-03-24 00:48:02 +00:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
Sébastien Santoro
e789f51f11 Remove $wgAllowMicroDataAttributes and $wgAllowRdfaAttributes
$wgAllowMicroDataAttributes and $wgAllowRdfaAttributes have been
introduced in MediaWiki 1.16 and required at this moment $wgHTML5
to be true. This last setting has been removed in MediaWiki 1.22.

To simplify the code maintenance and the configuration complexity,
those settings are removed and the features are always available.

RDFa users must now explicitly set $wgHtml5Version to a RDFa
version. Currently the correct values are:

  - HTML+RDFa 1.0
  - XHTML+RDFa 1.0

Bug: T130040
Change-Id: I17a7bff2cad170e381eabf0aec4e26e4fd0cddc3
2016-03-18 17:24:56 +00:00
daniel
a8995619c1 Avoid rebuilding database fixtures for every test run
This reduces the runtime of database-bound tests by about 40%
(on my system, from 4:55 to 2:47; results from Jenkins are
inconclusive).

The basic idea is to call addCoreDBData() only once, and have
a addDBDataOnce() that is called once per test class, not for
every test method lie addDBData() is. Most tests could be
trivially be changed to implement addDBDataOnce() instead of
addDBData(). The ones for which this did not work immediately
were left out for now. A closer look at the tests that still
implement addDBData() may reveal additional potential for
improvement.

TODO: Once this is merged, try to change addDBData() to
addDBDataOnce() where possible in extensions.

Change-Id: Iec4ed4c8419fb4ad87e6710de808863ede9998b7
2016-03-10 23:44:34 +00:00
Timo Tijhof
2eeda9bc7d parserTest: Make $wgResourceBasePath match $wgScriptPath
Right now it forgets to reset $wgResourceBasePath, which means it
is inherited from the wikis's (or Jenkins') default settings which
is typically '/w'. That caused parser tests to behave as if pointers
to /extensions were outside /w.

Also update wgScriptPath to be '' instead of '/'. Otherwise this
can cause double-slash prefixed urls.

Change-Id: Ic455d62fca8fcac2c4ecc055cc0d7e311b70a94a
2016-02-23 02:23:05 +00:00
Derk-Jan Hartman
61d078a2f5 Parsertests: Fix the video parsertests to run using phpunit
Bug: T126723
Change-Id: Ib3777413e1f86ddca9e460b41a8e3ef0eb8fb7cc
2016-02-19 18:15:54 +01:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Derk-Jan Hartman
175e95a909 ParserTests: Add a video file to parser test suite
Introduce an ogv video file to the parser file testsuite, so that we
can use it later in TimedMediaHandler parsertests.

Change-Id: I6a3b307ad9c82e9df0aeec025934d736eec8375f
2016-01-07 13:24:43 -08:00
Antoine Musso
50c5a9d27d tests: let us select/exclude ParserTests
The MediaWiki test suite is painfully slow and delays merging of
changes. More than half of the time is spent in
ParserTest_Parser⁄parserTests::testParserTest which is the PHPUnit
wrapping class for the parser tests.

This patch let us extract the parser tests so we can run them
independently. By running them parallely with the rest of the tests,
that will speed up the gate processing time.

Mark the MediaWikiParserTest and NewParserTest class as belonging to the
test group 'ParserTests'.  Will let us filter them out via PHPUnit
option --exclude-group

Introduce a new PHPUnit test suite 'parsertests' which loads the
MediaWiki core parser tests wrapper 'MediaWikiParserTest' and the suite
which loads the extensions parser tests (ExtensionsParserTestSuite.php).
This way we can run solely the parser tests with:

  cd tests/phpunit
  php phpunit.php --testsuite ParserTests

Wikimedia CI can then be configure to run two jobs:

 A) php phpunit.php --exclude-group ParserTests
 B) php phpunit.php --testsuite ParserTests

Bug: T114314
Change-Id: Ie819bab43163995048c073691c4c5d258f797c02
2015-12-01 12:26:10 +00:00
Reedy
00c426e3c2 Replace wfBaseConvert with Wikimedia\base_convert
Change-Id: Iadab3d018c3559daf79be90edb23d131729bdb68
2015-11-24 22:51:42 +00:00
umherirrender
5311afb6a4 phpcs: Assignment expression not allowed
Fix some "Assignment expression not allowed"

Found by tests:
https://integration.wikimedia.org/ci/job/mediawiki-core-phpcs/2736/consoleFull

Change-Id: Ibfc62b0aaa5c7fa63081edea3ef2b4d0dc984f85
2015-11-18 19:39:19 +01:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Aaron Schulz
cc4ca3e86d Removed deprecated $wgDeferredUpdateList
Change-Id: I7072ad3b34dd9a0726df6d1c044616c3b4bcd79f
2015-09-21 16:30:16 -07:00
Tim Starling
2c6c954e23 Abstract and refactor Tidy support
* Split tidy implementations into a class hierarchy
* Bring all tidy configuration into a single associative array and
  deprecate the old configuration.
* Remove $wgAlwaysUseTidy

This is preparatory to replacement of Tidy (T89331). I used the name
"Raggett" for things relating to Dave Raggett's Tidy, since if we use
"tidy" to mean the new abstract system as well as Raggett's tidy, it
gets confusing.

Change-Id: I77af1a16cbbb47fc226d05fb9aad56c58e8910b5
2015-09-10 20:18:52 -07:00
Aaron Schulz
8194b2014b Deprecate $wgEnableParserCache
* There is little reason to disable it and one can set $wgParserCacheType
  if truly needed

Change-Id: Iec5fc7729d0f9de67ec2aa6c0e9c2c1e3e0d57ad
2015-06-04 19:23:03 +01:00
Bartosz Dziewoński
302e9e48f6 Parser tests for page status indicators
https://www.mediawiki.org/wiki/Help:Page_status_indicators

Change-Id: Ic461fe889a3f8ef9f332019f72cfb732c0ec1eca
2015-03-29 22:31:51 +00:00
Arlo Breault
78c3f2f4b1 Tidy up tidy usage
* There's a branch path in the sanitizer that depends on $wgUseTidy,
   which means the test output differs from on wiki.

 * In general, we should set these variables to match the wiki behaviour
   in tests.

 * Exposes T92892, Sanitizer removes empty tags when tidy is disabled.

 * Tweaked tests for T19663 to use an extension tag to show that
   HTML5 tags with non-word characters make it through the parser
   intact (before being ultimately sanitized).

Change-Id: I09c72fd739e11a8b757f37dc4c790758d782ad73
2015-03-16 16:33:50 -04:00
Timo Tijhof
48d715148b Use MediaWikiTestCase methods for tempdir in unit tests
* Use MediaWikiTestCase::getNewTempFile and getNewTempDirectory
  instead of wfTempDir().

  The upload api tests wrote a tempnam() file directly (where
  wfTempDir() is typically shared with other systems and concurrent
  runs). Use MediaWikiTestCase::getNewTempFile and
  getNewTempDirectory instead.

  This also ensures its removal by the teardown handler without
  needing manual unlink() calls. And it doesn't rely on the test
  passing. (Many unlink calls where at the bottom of tests,
  which wouldn't be reached in case of failure).

* For the upload test, the presistent storing of
  'Oberaargletscher_from_Oberaar.jpg' (downloaded from Commons)
  was removed. Note that this didn't work for Jenkins builds anyway
  as Jenkins builds set $wgTmpDirectory to a unique directory
  in tmpfs associated with an individual build.

* For filebackend tests, moved directory creation from the dataProvider
  to the main test.

  Implemented addTmpFiles() to allow subclasses to register
  additional files (created by other means) to be cleaned up also.

  Removed unused $tmpName and $toPath parameters in data
  provider for FileBackendTest::testStore. And fixed weird double
  $op2 variable name to be called $op3.

* Skipped parserTest.inc, MockFileBackend.php, and
  UploadFromUrlTestSuite.php as those don't use MediaWikiTestCase.

Change-Id: Ic7feb06ef0c1006eb99485470a1a59419f972545
2015-02-11 03:49:02 +00:00
Bartosz Dziewoński
844618a231 Use 'rsvg-convert' binary rather than 'rsvg' everywhere
Update $wgSVGConverters['rsvg'] to something closer to WMF production
configuration (there is a more complicated setup involving two
variants of rsvg for some reason).

Documentation is scarce, but 'rsvg-convert' appears to be the "modern"
way to call rsvg, with 'rsvg' being deprecated or not recommended.

Bug: T76476
Change-Id: I5ed877f3a5a1f1e97ae881c1d03fc977276182b6
2015-02-05 18:17:32 +00:00
Kunal Mehta
e27ae6b5ec Convert more wfRunHooks() --> Hooks::run()
Change-Id: I1b1e3cb6871721fc05dda881a8020c9a5d30a514
2014-12-12 14:47:31 -08:00
umherirrender
b0cfcd0fcb Add missing @return and @param to doc blocks
Change-Id: I9d99ba1968ed8f97624d957754c8847dfe1b41da
2014-08-27 21:57:45 +02:00
umherirrender
63dc5abc9a Fixed spacing
- Added space after reserved words: function, foreach, if
- Combined 'else if' into elseif
- Added braces to one-line statements
- Added spaces after comma, before parentheses

Change-Id: Ie5bbf680d6fbe0f0872dab2700c16b1394906a72
2014-08-27 18:31:50 +02:00
jenkins-bot
7eddc5caaa Merge "Run some parser tests with tidy." 2014-08-13 21:02:56 +00:00
umherirrender
6b3cbc276c Set $wgUploadNavigationUrl to false on parser and unit tests
Setting this to default avoids failing parser tests,
when it is set in LocalSettings.php

Bug: 54576
Change-Id: I531d5839e9abe571c6c29f290bb159dabca34798
2014-08-13 15:05:14 +00:00
C. Scott Ananian
019e8ce29d Run some parser tests with tidy.
Note that the old parser tests helper function `tidy()` never actually did
anything, since $wgUseTidy was forced to `false` in the parser test setup.
Remove this unused code, and replace it with our new tidy support.

Allows new parser test sections: 'html+tidy' denotes "tidied" HTML (open
tags closed and other fixups to original wikitext markup) which should be
applicable to any parser.  'html/php+tidy' is output specific to the PHP
parser with tidy turned on.  The Parsoid backend will use the 'html/parsoid'
section if present, but if it is not present it will fallback to first the
'html+tidy' section, and if that is missing the 'html' section.

Note that 'tidy' has a large number of open bugs (see
https://bugzilla.wikimedia.org/show_bug.cgi?id=2542 ) and so in some cases
we deliberately do *not* use 'html+tidy' or 'html/php+tidy' clauses, in
order to avoid documenting broken output.  In these cases, there is no
broken HTML in the PHP parser output, and so (in theory) the 'html' and
'html+tidy' sections would be identical (that is, if tidy didn't have
bugs).

Change-Id: Iba45f38774b221522dc3b6ae2d1312fb79f8f41f
2014-08-03 17:45:54 -04:00
addshore
892a992ab8 Remove MediaWikiPHPUnitCommand
All functionality has been moved to other places

Change-Id: I6b6b0ef846bc63108c4dff9e17098432fd9d1697
2014-08-02 21:35:34 +00:00
umherirrender
d15f1cc5e1 Break some long lines in maintenance, skins, tests
Change-Id: I5d86ad3e0c90e09440268a670f5af3e2bf080612
2014-07-24 19:03:17 +02:00
This, that and the other
e349358a5d No interlanguage links after local interwiki prefixes
This was noticed on enwiki after w: was marked as a local interwiki prefix
there. Links like [[w🇩🇪Foo]] ought to act like [[🇩🇪Foo]], not
[[de:Foo]].

Also adding a number of additional parser tests related to interwiki links.

Bug: 68085
Change-Id: If39af06edb4af2da85c9bcf43df7088181809fcf
2014-07-22 15:01:07 +02:00
C. Scott Ananian
09498e1d7f Add parser test for "extra interlanguage links".
This support was added in https://gerrit.wikimedia.org/r/111390
but no parser tests were added at that time.

Bug: 32189
Change-Id: I299ce844919b3f20b3ce116adf64b37dd95325d0
2014-06-26 22:46:13 +00:00
Jackmcbarn
2d1c6e2634 Add support for testing transparent tags
Allow transparent tag hooks to be loaded during parser tests the way that
regular and function tag hooks can be.

Change-Id: I28ac9cc239628c248f72898d247fa1f6e2c308bd
2014-06-20 11:36:08 -04:00
C. Scott Ananian
dece73dff9 ParserTests: fix bits column in uploaded images for test cases.
When running parser tests on a sqlite3 database, the insertion of the
djvu image before running the test suite will fail because `NULL` is not
a valid value for the `bits` column of the `image` table.  This will
cause the test suite to eventually fail, since {{NUMBEROFFILES}} differs.

Test uploads show that `bits` is usually set to 0 for both SVG and
DJVU uploads, so fix this (in both the standalone test runner and the
phpunit test runner).

Change-Id: I8689a547d34035534723e87c4c2680c4e67245f2
2014-06-03 21:49:40 +00:00
Bartosz Dziewoński
fd718959b6 Copy various random files used by tests to tests/phpunit/data
The tests currently depend on them never being renamed, which is bad.
(Actual file data in git is de-duplicated automatically AFAIK.)

Change-Id: Id2440326981218f9e7d51541a168db59183fdadf
2014-06-03 22:52:51 +02:00
Tim Starling
4ba7a9c102 Revert "Use square bounding boxes for default-sized thumbnails"
Reverting for further discussion, due to community complaints at https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_%28technical%29&oldid=611154541#Infobox_Image

This reverts commit 7db5534179.

Change-Id: Ieea6224b2a295b5d65bbd486e30cf0573376c7e9
2014-06-02 11:24:09 +10:00
C. Scott Ananian
7db5534179 Use square bounding boxes for default-sized thumbnails
Thumbnails for portrait-orientation images have always been "too big",
especially when displayed in a gallery.  The 'upright' option did not
completely fix the issue.  Using a square bounding box for thumbnails
(and 'framed' images) without an explicit size specifiction provides
a better default appearance.

This also provides a clean syntax for content authored using
Parsoid/Visual Editor, which prefers square bounding boxes.

See:
https://www.mediawiki.org/wiki/Requests_for_comment/Square_bounding_boxes

Bug: 63903
Change-Id: I665d8945843d3b5437a74e376b63c44965590116
2014-05-21 14:30:06 -07:00
Ori Livneh
72c0ce43a8 Add $wgServerName
This partially reverts r73950 which removed $wgServerName on the ground that it
was only used for {{SERVERNAME}}. When it was pointed out that $wgServerName was
also used by several extensions, the response was not to restore the variable, but
to proceed to remove it from extensions as well.

It is a useful variable to have, as the discussion on Id819246a9 makes clear
(see Tim's comment on PS12 and Timo's reply). So let's reintroduce it, and expose
it in mw.config and ApiQuerySiteInfo as well.

Change-Id: I40a6fd427d38c64c628f70a2f407b145443ea204
2014-05-09 11:53:56 +02:00
Tpt
17117f74f5 Addition of a parser test for page= parameter of image inclusion
Support for DjVu is detected and parser tests that rely on it are disabled if needed.

Introduce DjVuSupport to easily detect DjVu support in unit tests

Change-Id: I53fd7b54e765d5f349abe74481bbc6f62f2b349e
2014-04-29 19:55:44 +02:00
umherirrender
092cd8ee31 Fixed some @params documentation (tests)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: Ic8aaf0a93796b97d0fa4617c1f86ff59f4b36131
2014-04-17 20:43:42 +02:00
C. Scott Ananian
0f799ce2b2 Update set of files cleaned up after parserTests
The parser tests now include more generated thumbnails, so we need to
update the list of thumbnail files we clean up after a run.

Change-Id: Ibabab27ecb895a61f57fff265c8d6d3147666e0d
2014-03-25 14:41:23 -04:00
C. Scott Ananian
e784f96a56 Allow setting default thumb size in parser tests
The mediawiki default thumb size is 180px.  The Parsoid default thumb
size is 220px, to match the default thumb size for most WMF wikipedias
(see https://bugzilla.wikimedia.org/show_bug.cgi?id=43336).

This discrepancy leads to inconsistent image-related test output.
Allow a test to set an explicit default thumb size with the
'thumbsize' option so that it is possible to write consistent tests.

Change-Id: Ib764d1f1660a50caaf8f0ff245822d1d1a1d264e
2014-03-20 13:40:16 -04:00