aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/suites/ParsoidTestFileSuite.php
Commit message (Collapse)AuthorAgeFilesLines
* parsertests: Misc cleanupDaimona Eaytoy2024-03-151-5/+3
| | | | Change-Id: Id1b073d80e896a26493206141bddfcf65c171d0b
* ParsoidTestFileSuite: Fix use of undefined $runnerOpts variableSubramanya Sastry2024-01-261-2/+2
| | | | | | | | | | | | | * be3018b2 removed the definition of local variable $runnerOpts from a closure since it was unused within the closure. It was referenced outside the closure but that was clearly buggy. Some other refactoring before be3018b2 likely broke this. * Looks like this bug has no real impact in typical test runs because of the "?? null" which hid the undefined access to $runnerOpts from when $runnerOpts is defined but 'selser' is not set there. Change-Id: I0df36653de4c70c7a4669b874f43385a18ac5e9d
* Replace usages of deprecated MWExceptionDaimona Eaytoy2023-06-061-1/+1
| | | | | | | Use SPL exceptions instead when the exception is unchecked. Bug: T328220 Change-Id: Ia1e5edc2ef3269a44b670262b78b305d07559829
* ParserTestRunner: Additional refactoring and cleanupSubramanya Sastry2023-04-111-4/+1
| | | | | | | | | Clean up to bypass skipped tests early in both legacy and parsoid test runs without duplicating the skipped test check. Also got rid of two FIXMEs with this refactoring. Change-Id: I854f89bd823aab297efe29cd4fdee675afd77752
* Just another 80 or so PHPStorm inspection fixes (#4)Tim Starling2023-03-251-2/+1
| | | | | | | | | | | | | * Unnecessary regex modifier. I agree with this inspection which flags /s modifiers on regexes that don't use a dot. * Property declared dynamically. * Unused local variable. But it's acceptable for an unused local variable to take the return value of a method under test, when it is being tested for its side-effects. And it's acceptable for an unused local variable to document unused list expansion elements, or the nature of array keys in a foreach. Change-Id: I067b5b45dd1138c00e7269b66d3d1385f202fe7f
* Followup to 02d13afa: Respect parsoid-compatible options in CLI runsSubramanya Sastry2022-10-251-10/+2
| | | | | | | | It was possible to run non-compatible tests via the CLI which, among other things, would have caused a "--parsoid --updateKnownFailures" test run to add bogus entries to the knownFailures json file. Change-Id: Ie3c51b97edb9839f775301670018bb4ba3290fbe
* Followup on 02d13afa: Unbreak Parsoid parser test runsSubramanya Sastry2022-08-251-3/+6
| | | | Change-Id: I226b145eb20440d068f92a0c99d11cbced4cf64d
* Merge "Set skipMode to something other than legacy"jenkins-bot2022-08-191-1/+3
|\
| * Set skipMode to something other than legacyArlo Breault2022-08-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | At present, $validTestModes[0] is 'legacy' when running `composer phpunit -- --testsuite=parsertests` It seems like any other value would be preferable since we're in ParsoidTestFileSuite.php and we want the isLegacy check in getTestSkipMessage to be false. Introduced in a5a04f5 Change-Id: I94699e5cc6dcc7e371c4020faa4dfbf2fa335704
* | Merge "Allow parsoid-compatible parser tests to select a subset of parsoid ↵jenkins-bot2022-08-191-0/+8
|\| | | | | | | modes"
| * Allow parsoid-compatible parser tests to select a subset of parsoid modesC. Scott Ananian2022-08-181-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This lets you tag a parser test file with: !! options parsoid-compatible=wt2html !! end to indicate that you want to run only the parsoid wt2html tests on this file. This is especially useful when gradually adding integrated-mode parsoid output clauses to an existing test file. Change-Id: Id870d23da3c127fea61d6b8ab98200c0e4c661e2
* | tests/parser/TestMode: move parser test helper class to parsoid libraryC. Scott Ananian2022-08-161-1/+1
|/ | | | | | Depends-On: I6a653889afd42fefb61daefd8ac842107dce8759 Depends-On: I73f320dfb03e5c26971a7bc36564021d2c9f3695 Change-Id: Id3e44a5b419d7f6917819e72c046f94a3a2286fe
* Clean up line indent with mixed tabs and whitespacesUmherirrender2022-07-091-1/+1
| | | | Change-Id: Ifcd15ecc4212d4ebfc26b2e18d6f1da47abf2a86
* Pass <Test,TestMode> as argument pair, deprecate old TestFileReaderC. Scott Ananian2022-06-031-37/+41
| | | | | | | | | | | | | | | | | | | | | 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
* Add Parsoid capabilities to parserTests.php scriptSubramanya Sastry2022-05-201-48/+4
| | | | | | | | | | | | | * 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
* ParserTest runner improvements (improve feature parity with Parsoid)Subramanya Sastry2022-05-201-29/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add partial support for running Parsoid selser testsSubramanya Sastry2022-04-211-2/+8
| | | | | | | | | | | | | | | | | | * This patch only adds support for - selser manual edits tests - selser changetree [5] tests Both these types of selser tests are known statically. * This doesn't yet add support for selser auto-edit tests since they cannot be determined statically. There is some code already in place in the test runner to apply change trees, but it will all likely get refactored in a future patch. Bug: T270311 Depends-On: I3be7826e08be120043f3bcd9151bade930b65fb7 Change-Id: Ic824dae6ee49867c766d40c11acfda117c7e2689
* Add support for Parsoid html2wt & html2html testing modesSubramanya Sastry2022-04-211-1/+1
| | | | | | | | | | | | | * Did a bunch of DRYing out and extracted helper functions. * The actual wt2html, wt2wt, html2wt, and html2html functions are much simpler to grok. * Fix handling of knownFailures. Bug: T270311 Depends-On: Iff4a45bf35e35f6980e73567538b164e3f0b03bc Depends-On: If083275fe8ca0beb2ba8ddb883297b6f221cc466 Depends-On: I1e7d61e9d0fd9d7d3aa7f2f55ea718d808c985cb Change-Id: I904b22c44bf5a7522d92cf761d5a0a82713b834e
* Add wt2wt test mode to ParsoidTestRunnerSubramanya Sastry2022-04-061-4/+3
| | | | | | | * Make use of caching support in the (Parsoid)Test object. Bug: T270311 Change-Id: I76894c6633dc37fb08af089ea852862ca6a5e90f
* Refactor Parsoid test runner to simplify testing non-wt2html modesSubramanya Sastry2022-04-061-13/+27
| | | | | | | | | | | | | | * This creates a fresh PHPUnit test for every test mode of a test. Parsoid's native test runner does this a lot more efficiently by reusing pipelines, env objects, and also intermediate test results. That way of running tests is trickier in the PHPUnit test setup. * Non-wt2html test modes will come in future patches. Bug: T270311 Depends-On: Iacdff9e47e0d98ac3aa3a61757935d6ea3e91096 Change-Id: I58f63ebd53939b358cefe60ac34f26cded52697d
* build: Updating dependencieslibraryupgrader2021-07-221-2/+2
| | | | | | | | | | | | | | composer: * mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0 The following sniffs now pass and were enabled: * Generic.ControlStructures.InlineControlStructure * MediaWiki.PHPUnit.AssertCount.NotUsed npm: * svgo: 2.3.0 → 2.3.1 * https://npmjs.com/advisories/1754 (CVE-2021-33587) Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
* Tests: Mark more more closures as staticUmherirrender2021-02-091-1/+1
| | | | | | | Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208 Bug: T274036 Change-Id: I695873737167a75f0d94901fa40383a33984ca55
* Add support for running parsertests with Parsoid in integrated modeC. Scott Ananian2020-12-231-0/+81
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