Page MenuHomePhabricator

Create a "unit-testing" framework for DOM transformers
Closed, ResolvedPublic

Description

For token transformers, we now have the transformTests.js script to help unit test individual token transformers. This lets us feed the same token streams to the JS code and the ported PHP code and (a) verify that the output token streams match (b) evaluate performance.

We need an equivalent functionality for DOM transformations. All DOM transformations now have the ability to dump the DOM before and after the transformation which can be used to generate unit test input and output for comparison on the PHP side.

parse.js script already has the ability to dump DOMs pre/post a dom-pass which can be used for testing and comparing the JS and PHP outputs. parse.js --dump=help lists the dumping options. However, this dump is primarily targeted for debugging and needs to be adapted for generating dom tests. Here is a possible approach:

parse.js already has a --genTest option. Now it accepts `--genTest dom:PASS-NAME,dom:ANOTHER-PASS-NAME --genDIrectory ../tests --genFragments true --pageName Hampi
This produces a pair of test files in the ../test directory called hampi-PASS-NAME-pre.txt and hampi-PASS-NAME-post.txt The default is to not generate fragments but that can be enabled for special reasons with --genFragments true option.

Event Timeline

ssastry created this task.Nov 9 2018, 9:18 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 9 2018, 9:18 PM
ssastry triaged this task as Medium priority.Nov 9 2018, 9:18 PM
ssastry moved this task from Backlog to Prototype / Evaluation on the Parsoid-PHP board.
ssastry updated the task description. (Show Details)Nov 14 2018, 10:43 PM

Change 474775 had a related patch set uploaded (by Sbailey; owner: Sbailey):
[mediawiki/services/parsoid@master] Added new genTest capabilities creating two dom dump files

https://gerrit.wikimedia.org/r/474775

Rical added a subscriber: Rical.Nov 20 2018, 9:23 PM

I am Rical and I receiveded an email titled :
[Gerrit] mediawiki...parsoid[master]: Added new genTest capabilities creating two dom dump files
sended at 19/11/2018 à 21:40
In which I read : "Sbailey would like Rical to review this change."
I sometime read some change in gerrit, but I am not able to rigthly understand and comment them.

I am Rical and I receiveded an email titled :
[Gerrit] mediawiki...parsoid[master]: Added new genTest capabilities creating two dom dump files
sended at 19/11/2018 à 21:40
In which I read : "Sbailey would like Rical to review this change."
I sometime read some change in gerrit, but I am not able to rigthly understand and comment them.

Hey Rical ... I think @Sbailey might have added you unintentionally .. she has since removed you from it.

Change 474775 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Added genTest capabilities for DOM passes

https://gerrit.wikimedia.org/r/474775

First phase of generating dom pre and post pass test files completed:
https://gerrit.wikimedia.org/r/#/c/mediawiki/services/parsoid/+/474775/

Sbailey updated the task description. (Show Details)Nov 27 2018, 9:39 PM
Sbailey removed a subscriber: Rical.

Change 476997 had a related patch set uploaded (by Sbailey; owner: Sbailey):
[mediawiki/services/parsoid@master] WIP domTest.js initial incomplete implementation

https://gerrit.wikimedia.org/r/476997

Change 476997 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Implemented domTests.js for unit testing DOM transformations

https://gerrit.wikimedia.org/r/476997

ssastry closed this task as Resolved.Dec 18 2018, 8:17 PM