Commit graph

1259 commits

Author SHA1 Message Date
Subramanya Sastry
e9acc7c060 ParserTestRunner: Fix wiki url for Parsoid-specific config
* This makes 3 more tests match Parsoid's standalone run output

Change-Id: I12f6557c865a3bf8de234c9a084f188fc9320558
2022-06-09 10:00:25 -04:00
Subramanya Sastry
61b54be68c ParserTests: Reset ParsoidSiteConfig always
When a test sets options to change global config, we have to rebuild
the ParsoidSiteConfig instance to pick up the test options since
the service container caches the SiteConfig instance.

For now, we are unconditionally resetting SiteConfig before every
<test,mode> combination. At a later time, we can figure out a way
to do it more conditionally; filed T310283 for that.

Bug: T310283
Change-Id: Ia2dfd37e3da3e1e8b31ab917b1f831eaea5eb5c5
2022-06-09 09:59:33 -04:00
Arlo Breault
add3488ae1 Sync up with Parsoid parserTests
This now aligns with Parsoid commit 2c045e909e60a0306d945d3d9f0cd9ac8360f249

Change-Id: I1d1def1dfab5455d068520ca4c16af0fe3e277dd
2022-06-08 12:24:35 -04:00
jenkins-bot
e3f5fdd8b1 Merge "Set alt in galleries, despite caption being visible" 2022-06-08 16:06:15 +00:00
C. Scott Ananian
5fdcdd307a Follow up to d522079c: Fix crashes with skipped tests.
This is an alternative to I55280b0d57d689bb7b43adde5025749f64a2683a.

Change-Id: Ib825c2e968256803dd402937862b1cd8b32cf2fc
2022-06-07 18:41:20 -04:00
Arlo Breault
0a82cbf301 Set alt in galleries, despite caption being visible
Similar to e7004a6 for tooltips.

Matches Parsoid commit I9d82c8003fd67cd984a8f4523e4993ed1f22b5d2

Bug: T297443
Bug: T162360
Bug: T63566
Change-Id: Ia3b13424d9f77586d334a477822e6e918d3b65c3
2022-06-07 18:20:26 -04:00
Subramanya Sastry
0442728ed8 ParserTestRuner: Init 'selser' to prevent 'Undefined index' warnings
Change-Id: I81135bb7974a5434fd3180ef942cdd1a03868789
2022-06-06 11:34:19 -05:00
C. Scott Ananian
d522079c9f ParserTestRunner: move more common code into ::runTest()
Move the TestRecorder calls into runTest() to DRY out the parsoid and
legacy test runners a bit.

Change-Id: Ice91811c9106f07a95a0f8910f439eb784b35d7e
2022-06-03 17:44:26 -04:00
C. Scott Ananian
760c2fe94b Parser tests: the Test::$config property is now always an array
Previously versions of Parsoid represented the !!config section as
a string which then had to be parsed by the ParserTestRunner.

Bug: T307720
Depends-On: Ieaac08e8171fd4c2a233646a84caac70ec30db6f
Change-Id: I3c5666d061c469049bf150ff0fa3010cb907a493
2022-06-03 17:16:24 -04:00
C. Scott Ananian
a5a04f56bd Pass <Test,TestMode> as argument pair, deprecate old TestFileReader
We introduced a new type for "ParserTestMode" and then uniformly pass
this around alongside the ParserTest object itself.  (We started by
using a string for the $mode but the "explicit changetree" mode
requires more structured data.  We *could* encode this in JSON just to
keep the string type around, but it seems cleaner and more future
proof to wrap this in a proper class type.)

Removed the old TestFileReader wrapper class, which served only as
a thunk to convert the new Test class into the same sort of array
which the legacy parser test runner code expected.  There's still
some remaining ::testToArray() usage here for the TestRecorder
framework, but that will be cleaned up in a future patch.

Also updated the TestRecorder with stronger types: use the same
<Test,TestMode> pair when invoking the TestRecorder, instead of the
loosely typed array we'd used previously.

Change-Id: Iec4c0c7972a655b4faccacc67bdc3ca66d4c163d
2022-06-03 17:15:38 -04:00
Umherirrender
3acc9e63c0 tests/parser: Run phan
Run phan over classes in tests/parser

The dependency of classes between parser and phpunit is not clear.
Classes used by both possible needs part of /common/

Change-Id: I2ceca6b7cd447876c127ed3b14e09f479defbd93
2022-06-02 00:13:30 +02:00
jenkins-bot
ecce0154d4 Merge "tests/parser: Simplify sequencer handling in DbTestRecorder" 2022-06-01 20:11:12 +00:00
jenkins-bot
c830404d1d Merge "tests/parser: Pass strings to TermColor::color" 2022-06-01 20:05:52 +00:00
jenkins-bot
e8aab65ba8 Merge "tests/parser: Remove return value from ParserTestPrinter::showFailure" 2022-06-01 20:01:23 +00:00
Umherirrender
6a10c33bfa tests/parser: Remove return value from ParserTestPrinter::showFailure
Change-Id: I26181436fdbc4557c359f484e92012878a2107d1
2022-06-01 19:06:58 +00:00
Umherirrender
23ad6813b3 tests/parser: Pass strings to TermColor::color
Change-Id: I165daa73359fbdc1c4cc1b485a19c6b2b2782d9f
2022-06-01 21:05:46 +02:00
Umherirrender
d5627eeb8d tests/parser: Simplify sequencer handling in DbTestRecorder
IDatabase::insertId is enough to get the lastval even in postgres

Change-Id: Ie7f0da9e2d2bf89ed869f68acf35064eb9985049
2022-06-01 21:01:36 +02:00
Umherirrender
c7c531778e tests/parser: Add documentation for class properties
Also add missing properties

Change-Id: Ia2443348a40fc46afb9133c997db7120461373f4
2022-06-01 20:57:09 +02:00
jenkins-bot
203e12d3a3 Merge "Revert "ParserTestRunner: undo class rename of TestFileReader"" 2022-06-01 16:51:51 +00:00
Subramanya Sastry
3e22c5b975 Revert "ParserTestRunner: undo class rename of TestFileReader"
This reverts commit 123f785cdf.

Reason for revert: This breaks parserTests.php script since the ParserTestRunner script has references to both TestFileReader classes and this patch ends up using the same reader everywhere.

Change-Id: I22bdd05f9a86674e88335cc9055f1ce6cfa128d1
2022-06-01 00:00:19 +00:00
Umherirrender
f01a391f0d tests: Fix types in documentation by adding use statements
Some types used in @param/@return are not correct,
because the class is not used with namespace

Change-Id: Ic2643687378a6addabc2c9cd402224e442257f86
2022-05-29 07:11:15 +00:00
Umherirrender
9832c7f9ba fuzzTest.php: Simplify try/catch code
Change-Id: I925dd6b6f18118c8c4c577795e373f73337851d6
2022-05-28 09:05:18 +02:00
jenkins-bot
907c80de45 Merge "tests: Use namespaced IDatabase class" 2022-05-27 23:13:16 +00:00
Umherirrender
770f905900 tests: Use namespaced IDatabase class
Change-Id: I7171ff26faee00d9eaabc33c2f3d91049ea0b40d
2022-05-28 00:09:55 +02:00
Arlo Breault
2cf5e8d9bd Sync up with Parsoid parserTests
This now aligns with Parsoid commit 4eb378d8c7cbdc9d6a939d6068f1c13e94e2b0ac

Change-Id: I3647805b5c909c227a828093bef600afb1ca475b
2022-05-27 12:16:06 -04:00
jenkins-bot
e2fbdb26e0 Merge "parserTests.php: Default to --parsoid if you pass a parsoid-specific option" 2022-05-27 16:00:29 +00:00
jenkins-bot
6475f05e79 Merge "ParserTestRunner: Use standard PHP mechanism for array defaults in constructor" 2022-05-27 15:59:02 +00:00
jenkins-bot
54974a312f Merge "Emit mw:File typeof for media" 2022-05-27 15:58:54 +00:00
C. Scott Ananian
16a537dfd6 parserTests.php: Default to --parsoid if you pass a parsoid-specific option
Change-Id: Ie3e66be8bd0df719a9487a0303885042c3bf7cb7
2022-05-27 10:12:56 -04:00
C. Scott Ananian
1e64e2f6f0 ParserTestRunner: Use standard PHP mechanism for array defaults in constructor
The ParserTestRunner code was old enough that it used a number of different
mechanisms to supply defaults for options passed via an array; uniformly use
the standard PHP "array add" mechanism instead.

Change-Id: I1791f7f8b1ae2cc6f4dd23351e9810a98b598be1
2022-05-27 10:12:56 -04:00
Arlo Breault
fadaf2a33d Emit mw:File typeof for media
This matches Parsoid commit I676a88d80e2739ba69d4e7646de56fb87ae3e8e8

A few reasons for this change:

* It's less painful to do this now than after the legacy parser is made
  to match Parsoid's output and more stuff depends on it.

* It simplifies the queries that are necessary to collect the media on a
  page, which makes it both easier to work with and requires shipping
  less bytes.

* The nested img|audio|video tags retain the distinction, so there's
  no loss of information.

* mw:File is a closer match to the [[File:Hiho.jpg]] syntax that
  generates these elements.

* For broken media, it's unclear which type should be applied and
  mw:File obviates the question.

* For manualthumb, it's unclear which type to choose if, say, the file is
  a video but we've rendered an image.  For now, we've gone with what's
  actually rendered in the page, but again mw:File avoids the issue.
  And yes, for this special case a poster could be used, that's T121617

* There's precedent in MediaWiki, where Image: redirects to the File:
  namespace.  We should have followed that lead earlier instead of
  introducing mw:Audio and mw:Video.

Bug: T273505
Depends-On: I9f36ef8bc3023195dd31e52f04e8f0f0f792d311
Depends-On: I0b11463b802b898429a451378f15987700752e0e
Change-Id: I719a367622b3887cfea3032582a767c2c38d0f87
2022-05-26 13:52:20 -04:00
jenkins-bot
5351d2cd7d Merge "Add {{=}} as a built-in magic word" 2022-05-26 17:32:32 +00:00
C. Scott Ananian
123f785cdf ParserTestRunner: undo class rename of TestFileReader
Long term there isn't going to be a "TestFileReader" and
"ParsoidTestFileReader", the legacy test file reader is just a
temporary hack.  And these aren't "Parsoid Test Files" they
are *parser test files* (ie, implementation independent,
more or less).  Long story short, adding "Parsoid" to the
class name is a step in the wrong direction.

Change-Id: I9b520c39c6c5b52334c658ec2a97bd38612dbf61
2022-05-23 10:53:46 -04:00
Subramanya Sastry
9e6b7156bc Add Parsoid capabilities to parserTests.php script
* This adds all of Parsoid's abilities to the parserTests.php script
* Parsoid testing mode requires a "--parsoid" CLI option.
* This supports "--wt2html" and the other testing modes,
  "--updateKnownFailures", "--knownFailures", and "--changetree"
  options that are part of the Parsoid's parserTests.php script.
* Verified that the output of parserTests.php test run matches
  the output of the PHPUnit test run on the Cite extensions'
  citeParserTests.txt file.

Change-Id: I87a1f621d0a2579ac47fa80d34cf74d4456bcf62
2022-05-20 20:37:50 +00:00
Subramanya Sastry
b5bcc0dec3 ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:

1. Adds Parsoid selser auto-edit test support

   Since it isn't possible to dynamically add tests in PHPUnit
   (unlike the home-grown parser test runners), to support selser
   auto-edit tests, we create a single composite test that includes
   all the individual edits. If a single test fails, the whole test
   is considering failing.

   The test output from all the individual tests are combined into
   composite expected / actual strings and test failure diffs reveals
   diffs for individual tests.

   Future patches could enhance output further.

2. Ensure that we skip HTML-based Parsoid test modes without appropriate
   input HTML

3. Pass additional options to the parser test runner via the
   ParserTestTopLevelSuite constructor.  These support extended
   functionality of the Parsoid parser test runner which are being
   made available to core.

   At the moment the constructor will attempt to JSON-decode the
   PARSERTEST_FLAGS environment variable to supply defaults for
   these flags, which provides a hacky sort of way to pass arguments
   on the command line.  This will be integrated with the existing
   $flags passed to ParserTestTopLevelSuite in the future (T308367).

4. Add support for running tests in specific modes as well
   as ability to update the known failures json file.

   This includes some missing code to run per-test teardown functions
   in runParsoidTest.

   Unlike the Parsoid parser test runner, you can combine
   updateKnownFailures with --filter as well as with subset of
   test modes, including possibly specific selser changetrees.

   If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
   you can also update the knownFailures result for only the tests
   that are run.

   However, note that this could change the sort order in the
   *-knownFailures.json file. This leads to dirty (git) diffs when
   a full updateKnownFailures is run on the file. I am not going to
   tackle this issue for now since this is an obscure use case that
   is unlikely to be used much, if at all.

   Overall, if I copy over the -knownFailures.json file from the Parsoid
   repo into the Cite repo and update it with a phpunit.php run in core,
   it updates the known failures to reflect changes to test results from
   an integrated test run. A second run doesn't lead to any additional
   changes to the knownFailures.json file or to any test failures. I had
   to fix some bugs (referenced in the previous paragraph) to ensure
   this idempotence beyond the first run.

This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.

This patch squashes the following previous patches:
  I2f46b4b94b44aec76e33403455eb466899376a6b
  Ib01991089ec410dd45f77a20b136c8e05d855fa4
  Id0ef01e333580892aa6d415b8f66c4393b06870d

Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-05-20 16:23:16 -04:00
C. Scott Ananian
cf52f646bb Add {{=}} as a built-in magic word
This is a replay of 4bc0dc348a, which
was reverted in 9bd4fc0ae9 due to unexpected
use on Dutch Wiktionary.  In 1.36 deprecation warnings and a tracking
category were added if a wiki defined [[Template:=]] to expand to
anything other than `=` (see aeb3f45c20).
This patch follows up that deprecation by finally defining `{{=}}` as
a built-in, since the last usage on deployed wikis was cleaned up
sometime around February 2021 (list at
https://meta.wikimedia.org/wiki/Equals_sign_parser_function_template_conflicts
).

We've left the tracking category defined for now, so that any remaining
pages left in the tracking category on third-party wikis still retain
localized category documentation.  But it is expected that the next MW
release will also remove the tracking category.

Bug: T91154
Change-Id: I4717172f1d74d326212d51015a6cd87c3758f30d
2022-05-20 13:08:20 -04:00
Arlo Breault
c7d7bb921b Sync up with Parsoid parserTests
This now aligns with Parsoid commit c4f79513ba0b1fc6ccde2d2dec94102c564cfc02

Change-Id: I9aba883c549a840f564ca9dfb9487ba5bd7bcbca
2022-05-17 14:38:15 -04:00
Arlo Breault
e7004a62d4 Set tooltips in galleries, despite caption being visible
Matches Parsoid commit Icbc36b6e9aa1b9f4f27c23f4833c626a725cc154

Bug: T297443
Bug: T108380
Change-Id: Ib6606dcbe8cf9476aaf694c4f86d5dc4768b9dd2
2022-05-16 19:25:49 -04:00
Arlo Breault
e2752a0dcf Clarify tooltips are set if captions aren't visible
Matches Parsoid commit Icbc36b6e9aa1b9f4f27c23f4833c626a725cc154

Bug: T297443
Bug: T108380
Depends-On: I896e2af2e8a712a36eb23a25cad08f53574fc044
Change-Id: I30eba0fb226971ddeda4eb240929e89ef7e5f45f
2022-05-16 19:25:27 -04:00
jenkins-bot
63c77060a0 Merge "Language: Inject NamespaceInfo" 2022-05-12 18:34:50 +00:00
jenkins-bot
9a0d234e05 Merge "Add partial support for running Parsoid selser tests" 2022-05-12 02:15:58 +00:00
jenkins-bot
cb0dec9c1c Merge "Add support for Parsoid html2wt & html2html testing modes" 2022-05-12 02:12:08 +00:00
Arlo Breault
3763f78929 Sync up with Parsoid parserTests files
This now aligns with Parsoid commit dd9d522e2f3e044d95a60c207e3b41487c651d85

Change-Id: I5bf4ce64a69f09f5d1d50344f25ebd8ccf9aa539
2022-05-11 17:15:33 -04:00
Arlo Breault
4a6743577e Match Parsoid output for bad images in galleries
Note that both Parsoid and here link to the upload page despite bad
images being known.

Also note that bad images outside of galleries are yet to match Parsoid
output.

Change-Id: Iae16b6044a93a646aeb27f3d76276c0d0c3cf391
2022-05-11 13:05:56 -04:00
Arlo Breault
2cff882c79 Support unlinked media |link=| in gallery
Change-Id: Ie142752f9af9af622b9ba8175fe4c8f155199bcb
2022-05-11 12:11:44 -04:00
Arlo Breault
6289e1919d Use Linker::getImageLinkMTOParams() for galleries
This assures that nofollow's are added where necessary and sets the
title attribute on links where appropriate, matching file links outside
of galleries.

Change-Id: I999a294bbcb921fe53823503e8009ab678411bb2
2022-05-11 12:11:43 -04:00
Bartosz Dziewoński
252a1c8e5f Language: Inject NamespaceInfo
Change-Id: I90eee60467698bbefb619bfa69abfaa10c759fea
2022-05-11 17:24:17 +02:00
jenkins-bot
96b78986ce Merge "Accomodate a future change to config information in the ParserTest class" 2022-05-11 01:33:38 +00:00
jenkins-bot
69dfd13bae Merge "Treat file |link= options like wikilinks in terms of title attributes" 2022-05-10 23:30:46 +00:00
Arlo Breault
88c9d0a600 Treat file |link= options like wikilinks in terms of title attributes
Wikilinks don't include the anchor, so we match that.

Change-Id: Icddc1ce6f19c21e34ca37f35a75a7b9263f93417
2022-05-10 16:51:56 -04:00