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
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
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
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
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
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
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
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
* 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
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
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
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
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