Commit graph

1079 commits

Author SHA1 Message Date
Arlo Breault
ed543be03b Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit 241a08fb80cd5b4b16146eb99054b25c0261998c

Change-Id: I8d176b76891e10de096247f6ad3ed52ec6f5735e
2021-02-18 11:23:19 -05:00
Arlo Breault
c44a3958a3 Don't apply French spacing in raw text elements
This also means we don't need to take special care for French spacing in
attributes, since it's no longer applied there.

Adds a test that captures this change.

Note that the test "Nowiki and french spacing" wonders whether this
escaping should be applied to nowiki content.

Bug: T255007
Change-Id: Ic8965e81882d7cf024bdced437f684064a30ac86
2021-02-16 19:26:29 -05:00
Umherirrender
a1de8b8700 Tests: Mark more more closures as static
Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208

Bug: T274036
Change-Id: I695873737167a75f0d94901fa40383a33984ca55
2021-02-09 02:55:57 +00:00
Reedy
729f20afc8 Tests: Mark more closures as static
Bug: T274036
Change-Id: I911d3041cebe417d162934223b46ea295c6d20e3
2021-02-07 13:26:56 +01:00
Umherirrender
205f141bb8 Improve some class properties documentation in tests
Change-Id: Id9c9e56865cf9a6bb112be37a5674ec753604fb1
2021-02-02 16:48:15 +00:00
jenkins-bot
eb4b304ed8 Merge "Add missing @param and @return to documentation in tests" 2021-01-30 15:22:33 +00:00
jenkins-bot
7b2a853019 Merge "Parser test for Balinese language conversion" 2021-01-30 15:22:25 +00:00
Arlo Breault
21dfb00fa3 Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit 4dd80737783737621bf1fc0e0b7e954f3d1bbf3c

Change-Id: Ib780af2f1e71aa6df8369d17cebf66d3bc85686b
2021-01-29 17:28:43 -05:00
jenkins-bot
03e2d471c4 Merge "Rewrite <langconvert> to support BCP 47 tags" 2021-01-28 16:30:31 +00:00
Tim Starling
0384793a2e Parser test for Balinese language conversion
Bug: T263082
Change-Id: I0a51656c54fbd547a6283dd23a7ee571dfb43d08
2021-01-28 03:43:07 +00:00
Umherirrender
47cc4da6d7 Remove unneeded @return documentation
Change-Id: If79d2126cc1b6a6e9876a972c9560d045de42ff6
2021-01-25 19:44:27 +01:00
Subramanya Sastry
0f86da8d4f ParserTests: Update error message to point to the failing test file
Change-Id: Idd5963aedffb2520153a6d99a1661c0471686008
2021-01-22 14:59:21 -06:00
Umherirrender
7691dbeca9 Add missing @param and @return to documentation in tests
Change-Id: Ic663e81cca0bf007804a70772250914a85f1fef4
2021-01-22 19:57:25 +01:00
jenkins-bot
e845067ab6 Merge "Adopt pipe trick with Arabic comma" 2021-01-16 03:29:36 +00:00
Arlo Breault
96d9eaa8c7 Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit ebf0a41507ec09a17f247acd2fdbb72555cbf2af

Change-Id: Ic3f59b93ae7b3132e1f410d0dfd35b1a4f6852be
2021-01-14 10:21:57 -05:00
David Kamholz
cdbd2e791d Rewrite <langconvert> to support BCP 47 tags
This validates langconvert's "from" and "to" arguments as valid BCP 47 tags. For example, it will accept "sr-Cyrl" and "sr-cyrl" and reject the non-standard internal MediaWiki code "sr-ec". I made the BCP 47 matching case insensitive as that seems to conform with how MediaWiki handles it elsewhere and case sensitive matching would probably be a headache for users.

Bug: T271758
Change-Id: I9f765fe650279820d61c3a7e499ca99468df3d14
2021-01-13 19:00:47 -08:00
Arlo Breault
78e85ab9e5 Split out media parser tests
Bug: T111604
Bug: T271129
Change-Id: I9893d11d50b8e5884239da2bb41262e093afc47f
2021-01-13 15:53:33 -05:00
jenkins-bot
0259ec87a7 Merge "Safer autoloading with respect to file-scope code" 2021-01-12 10:23:28 +00:00
Ebrahim Byagowi
9fe1d1f734 Adopt pipe trick with Arabic comma
Currently MediaWiki turns `[[test, abc]]` to `[[test, abc|test]]`
while saving the page but that comma isn't in use in Persian
so this patch makes MediaWiki to treat Arabic comma the same way
as regular comma.

Change-Id: Ib8051023abc25b7c4f97a3f50246f35650057ec9
2021-01-11 21:43:33 +00:00
Tim Starling
20d06b34bb Safer autoloading with respect to file-scope code
Many files were in the autoloader despite having potentially harmful
file-scope code.

* Exclude all CommandLineInc maintenance scripts from the autoloader.
* Introduce  "NO_AUTOLOAD" tag which excludes the file containing it
  from the autoloader. Use it on CommandLineInc.php and a few
  suspicious-looking files without classes in case they are refactored
  to add classes in the future.
* Add a test which parses all non-PSR4 class files and confirms that
  they do not contain dangerous file-scope code. It's slow (15s) but
  its results were enlightening.
* Several maintenance scripts define constants in the file scope,
  intending to modify the behaviour of MediaWiki. Either move the
  define() to a later setup function, or protect with NO_AUTOLOAD.
* Use require_once consistently with Maintenance.php and
  doMaintenance.php, per the original convention which is supposed to
  allow one maintenance script to use the class of another maintenance
  script. Using require breaks autoloading of these maintenance class
  files.
* When Maintenance.php is included, check if MediaWiki has already
  started, and if so, return early. Revert the fix for T250003 which
  is incompatible with this safety measure. Hopefully it was superseded
  by splitting out the class file.
* In runScript.php add a redundant PHP_SAPI check since it does some
  things in file-scope code before any other check will be run.
* Change the if(false) class_alias(...) to something more hackish and
  more compatible with the new test.
* Some site-related scripts found Maintenance.php in a non-standard way.
  Use the standard way.
* fileOpPerfTest.php called error_reporting(). Probably debugging code
  left in; removed.
* Moved mediawiki.compress.7z registration from the class file to the
  caller.

Change-Id: I1b1be90343a5ab678df6f1b1bdd03319dcf6537f
2021-01-11 11:59:36 +11:00
jenkins-bot
a34e301357 Merge "ParserTestRunner: share more code w/ MediaWikiIntegrationTestCase" 2021-01-08 05:42:37 +00:00
C. Scott Ananian
665eae14ac ParserTestRunner: share more code w/ MediaWikiIntegrationTestCase
Refactor the database setup code to share more code between
ParserTestRunner and MediaWikiIntegrationTestCase.  Made
`::setupAllTestDBs` static so it can be reused from
ParserTestRunner.

Made ParserTestRunner::addArticle more like
MediaWikiIntegrationTestCase::addCoreDBData().  Some additional
refactoring work could be done here in the future to share more code.

After the refactoring the ParserTestTables hook is no longer necessary
and so has been (soft) deprecated.  MediaWikiIntegrationTestCase
clones all database tables, so ParserTestRunner no longer needs to ask
extensions for a list of specific tables it should clone.  Cleaning up
the handful of extensions which define this hook will be left to a
future patch set.

Change-Id: I5124789fac333a664b73b4b4a1e801ecc0a618ca
2021-01-07 23:31:12 -05:00
C. Scott Ananian
a41f284324 CoreTagHooks: First argument passed to parser tags can be null
Document and enforce the correct type for the first argument to
a Parser tag hook, which will be `null` if the tag is self-closed.

Mark the methods in CoreTagHooks @internal.  They are apparently
unused outside MediaWiki core:
  https://codesearch.wmcloud.org/search/?q=CoreTagHooks&i=nope&files=&repos=

Add coverage test cases to ensure that all tag hooks properly handle
the `null` value of the first argument; prior to this patch the
`<html>` tag emitted a broken strip tag in this case.  The other hooks
passed the null to other callees in violation of their type
signatures, but eventually every other hook managed to safely cast the
null to the empty string without throwing an exception or emitting a
warning.  For those, this patch does not change existing behavior---it
just makes the cast to the empty string much more obvious to the
reader.

Change-Id: I69fde6c06eabb2db27bb1cc23d2cb19b99273391
2021-01-05 14:19:44 -05:00
C. Scott Ananian
71aa8e0e0d Add support for running parsertests with Parsoid in integrated mode
This allows us to move Parsoid-specific extension code from the
Parsoid repo into the extension's own repository and still have
Parsoid parser tests run on it via core's mechanism for running
extension tests.

Factored out some common ParserOptions setup into a common helper
function.  There are a number of features still missing from the
Parsoid test runner, which are marked with @todo comments and
phab task numbers.

Bug: T254181
Change-Id: Ifaf53862b96e9127d8f375ad8dd0cc362cba9f5b
2020-12-23 15:50:50 -05:00
C. Scott Ananian
3bf9a8e577 ParserTestFileSuite: run staticSetup once per suite
We now run staticSetup once per suite, instead of once per test.  This
matches the way that parserTests.php runs the tests, and speeds up
testing.  In addition, it allows simplifying a bit of redundant code
in ParserTestRunner::addArticles() because we know that static setup
has been done.

Change-Id: Id93412cf9eb714af693aa130de1b02c4ef87d6e0
2020-12-23 15:50:50 -05:00
Subramanya Sastry
94705b1e6a Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit b8c7ac91f5d4ec5860e23455e17a09d6c579b338

Change-Id: I80e93b2e22e10129e48a3a0312c46090e8d02551
2020-12-21 18:06:37 -06:00
C. Scott Ananian
727a77a19e ParserTestRunner: add interwiki prefixes used by Parsoid tests
Bug: T254181
Change-Id: Ia79992e8e44435746f8512b2f05408c560c80533
2020-12-21 16:53:43 -05:00
C. Scott Ananian
7b4c8f3768 ParserTestRunner: tweak filetype of djvu, allow capital E in !!hooks
Two minor improvements to parser tests:

1) Tweak the filetype of the djvu file to match what commons reports
   nowadays for a more relevant test

2) Allow capital 'E' when registering an extension requirement in the
   `!! hooks` clause of a parser test file.

Bug: T254181
Change-Id: Id4dcd0f5d040f4deb5235d565119a6f76cc7b59d
2020-12-21 16:53:43 -05:00
C. Scott Ananian
3d40c43b1f Deprecate InterwikiLoadPrefix hook
The InterwikiLoadPrefix hook isn't compatible with Parsoid, as it is
unidirectional and doesn't support enumerating all valid prefixes
(T270444).  Set/reset $wgInterwikiCache to mock the interwiki table
for parserTests and other unit tests instead.

This is a soft deprecation, as the used-in-production
Extension:Interwiki still uses InterwikiLoadPrefix, although not in a
way that would break Parsoid (since $wgInterwikiCache is set in
production).

Bug: T270444
Change-Id: If2507017c99c4ee42c104a0890bc45a84d7239d5
2020-12-21 19:28:48 +00:00
Arlo Breault
b12f5d8e20 Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit 67180924cc1d78eed9b300b6f867498da51c35bc

Change-Id: Icb1c8c3cc4e19db9fa5c93b62a6afadb9f6676dc
2020-12-18 12:30:25 -05:00
Arlo Breault
c2cef6cb58 Consistent label escaping in makeBrokenImageLinkObj
Html::element is more lenient about which characters it escapes.

But really this is just factored out of the next patch for ease of
review.

Change-Id: I9abb4d866a624df7bf4628ab9cc581967e715160
2020-12-18 11:41:09 -05:00
Arlo Breault
c203c574bd Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit c2952b434c1dc52d7c73154ca47bda19f2c2602f

Change-Id: Ic878dd183592c0ace77e3e078c40df40e54b7eab
2020-12-17 13:18:44 -05:00
Reedy
c75d2e41cc ParserTestRunner: Fix skipping typo
Change-Id: I72f2ed394141acf1fba9a450d10302607545225f
2020-12-16 23:50:51 +00:00
jenkins-bot
fe8779ebf9 Merge "Parser tests: Update TestFileReader to the latest reader from Parsoid" 2020-12-16 17:45:01 +00:00
David Kamholz
a7ad0547bc Implement <langconvert> tag
The <langconvert> tag takes two attributes: from (language variant from) and to (language variant to). It returns the content of the tag converted using LanguageConverter. It returns an error if the attributes are not present, if the variants do not exist, or if the variants belong to different languages. Currently it does not work for IuConverter, because the variants use the code ike rather than iu, and ike isn't in the list of languages with converters available.

This patchset reimplements from a parser function to a tag, and renames from transliterate to langconvert.

Bug: T263082
Change-Id: Idc3a32c66d5a0466c63e7ce8753d2619354c30b0
2020-12-14 19:40:31 -08:00
C. Scott Ananian
02ec9de651 Parser tests: Update TestFileReader to the latest reader from Parsoid
This replaces the 'requirements' from parser tests (hooks and
functionhooks) with a more flexible 'options' clause to allow
additional file-level requirements/options to support running parser
tests in multiple modes.  (For example, with the legacy parser or in
one of two parsoid modes.)

Bug: T254181
Depends-On: I636bd1f2c8aee327acbbd1636e2ac76355f1d80e
Change-Id: I58373d135c3a804f4ce9967112c338435f5cd4b6
2020-12-14 18:49:11 -05:00
Ammar Abdulhamid
71571191d4 Chain MutableRevisionRecord method calls 2
Change-Id: I86578cfbc892f171a4e433283b86d1b78fe4167d
2020-11-27 05:26:54 +01:00
C. Scott Ananian
c64e71615e Replace $wgDisable{Lang,Title}Conversion with LanguageConverterFactory methods
Replace direct access to $wgDisableLangConversion with
LanguageConverterFactory::isConversionDisabled(), and replace direct
access to $wgDisableTitleConversion with
LanguageConverterFactory::isTitleConversionDisabled().  However, most
places that check ::isTitleConversionDisabled() actually want
::isLinkConversionDisabled(), so add that too (and deprecate
isTitleConversionDisabled()).

Code search:
https://codesearch.wmcloud.org/search/?q=Disable%28Lang|Title%29Conversion&i=nope&files=&repos=

This change removes a number of spurious dependencies on the global
configuration and reduces code duplication (for example, if the logic
for disabling language conversion were ever to change).

Depends-On: I6fa8230ae97b0e34c381003548e61f9b7387d363
Change-Id: Icc4687638ff1815003dd903854efdbd904854f1e
2020-11-25 12:47:26 -05:00
Aaron Schulz
90865e0e89 tests: Use FileBackend::quick*() methods in ParserTestRunner
This avoids needs I/O from lock files

Change-Id: I0b8661712154c61f16c37c0c4303909c7b678cad
2020-11-13 06:06:59 +00:00
jenkins-bot
2752717667 Merge "Minor updates to some unrelated PHPDoc tags" 2020-10-30 17:17:57 +00:00
Umherirrender
c85a43561e Improve class property documentation
Reformat existing documentation to match the format

Change-Id: I190b54b5e962f17bab6502dd1b3c02f11dc926d2
2020-10-30 10:38:58 +01:00
Thiemo Kreuz
3306f15ce3 Minor updates to some unrelated PHPDoc tags
The past weeks I collected a few minor updates in my local dev
environment, and would like to submit them now.

Change-Id: Ibe00d72763f1b66c50cf73e00c8fa52d265043fc
2020-10-28 19:00:48 +00:00
Arlo Breault
acb40ea0d5 Sync up with Parsoid parserTests.txt
This now aligns with Parsoid commit 010856ed7d4aeb9617ac264782809cc58d94fc47

Change-Id: Iae87302abe2c11deb36088100e50a638d58cffe6
2020-10-05 16:09:18 -04:00
Ed Sanders
95a64c8740 Use the same character set for link prefix as for suffix in Arabic 'ar'
The default is a-z plus every non-ASCII character, but this
is too broad.

Instead use the same character set as is used for link trails,
specifically Latin & Arabic letters.

Bonus:
Add combining diacritics to both sets as when these are appended
to letters, the resulting glyph is still considered a letter.

Bug: T263266
Change-Id: I358673f79989491799d3d68da17e73b806b167e0
2020-10-05 18:31:33 +00:00
C. Scott Ananian
33c506843b phpunit tests: Reset the SpecialPageFactory when Content Language changes
This is causing problems for Parsoid CI, as parser tests fail when
phpunit runs the tests at a different point than they are run in
core's CI due to the side-effects of content-language changes made in
other phpunit tests. (For example, phpunit runs all extension tests
after core tests, so the same parsertest can pass if included in core
and then fail when included in an extension.)

SpecialPageFactory::$aliases has a dependency on the current content
language, with no way to reset it other than to recreate the
SpecialPageFactory.

Change-Id: I278580ed5cf2c85403cbaf601f8af4753e14a9d0
2020-09-23 14:17:31 -04:00
C. Scott Ananian
c443177614 Allow parserTests to declare a dependency on a particular extension
The parsertests file allows certain tests to declare a dependency on
a particular tag hook, but this doesn't work for extensions like
TimedMediaHandler which affect the output but don't register a
unique extension tag name.  Allow using 'extension:Foo' in the
`hooks` clause to register a dependency on the specific extension name,
instead of indirectly on the registered extension tag name.

Change-Id: I2d3f7e1313b4456733f820e6d8c504bb8d7427a7
2020-09-22 12:51:34 -04:00
Arlo Breault
8329352f08 Don't preface test description with comment
This seems to primarily be used in ParserTestPrinter::showTesting()
to print the string,

"Running test $desc... "

Follow up to 585cbcd

Change-Id: I53fc98ae56e3e9faad6ab1ca5a5a778f1c146fd1
2020-09-17 15:51:44 -04:00
jenkins-bot
13dc0e893d Merge "Tracking category and parser warning for deprecated uses of {{=}}" 2020-09-15 21:48:22 +00:00
jenkins-bot
448da261a2 Merge "Allow independent parser test files to (re)define articles w/ the same names" 2020-09-15 21:47:43 +00:00
C. Scott Ananian
aeb3f45c20 Tracking category and parser warning for deprecated uses of {{=}}
We plan to add {{=}} as a built-in parser function, expanding to `=`,
in the same way that `{{!}}` is a built-in.  It will be used to
automatically escape uses of `=` in template arguments (again, in the
same way that `{{!}}` can be used to protect uses of `|` in template
arguments).

Some wikis have non-standard definitions of `Template:=`; add a
tracking category to warn these wikis to transition before we turn on
the built-in parser function in a future release.

New parser test file added, so we can re-define Template:= and test
both cases of this new warning.

Bug: T91154
Change-Id: I50ff8a7b6be95901ebb14ffbe64940a0f499cfac
2020-09-15 20:16:37 +00:00