From f230419baf203ce592f6ea736c03b9b442de23db Mon Sep 17 00:00:00 2001 From: Subramanya Sastry Date: Thu, 11 Aug 2022 16:20:09 -0500 Subject: [PATCH] Enable testing with Parsoid + add failing test for T272507 * Turned on wt2html and wt2wt Parsoid modes for all tests with aggressive normalization to eliminate the need to add html/parsoid sections. We expect these modes to pass. * The failing wt2wt tests is because the input wikitext duplicates arguments and Parsoid's wt2html doesn't capture duplicate template args which cause the wt2wt output to be normalized. This explains the two failing wt2wt tests and the corresponding selser "failures". * The failing wt2html safesubst test might be a real failure and something we will have to look into. Will file a phab task for this. * Added a new test for T272507 that fails with Parsoid right now, but will pass in a subsequent patch. Change-Id: I96fba68dda7524d2fe562eb60ced64e5e0518f65 --- .../parser/luaParserTests-knownFailures.json | 24 ++++ tests/parser/luaParserTests.txt | 125 +++++++++++++++++- 2 files changed, 143 insertions(+), 6 deletions(-) create mode 100644 tests/parser/luaParserTests-knownFailures.json diff --git a/tests/parser/luaParserTests-knownFailures.json b/tests/parser/luaParserTests-knownFailures.json new file mode 100644 index 00000000..a9004de5 --- /dev/null +++ b/tests/parser/luaParserTests-knownFailures.json @@ -0,0 +1,24 @@ +{ + "Scribunto: Test unstripNowiki behavior": { + "wt2html": "

foo\n[[Foo]]

\n\n

'\"`UNIQ--nowiki-00000002-QINU`\"'\n'\"`UNIQ--nowiki-00000003-QINU`\"'

" + }, + "Scribunto: isSubsting during PST": { + "wt2html": "

false

" + }, + "Scribunto: named numeric parameters": { + "wt2wt": "{{#invoke:test|getArg|b|a}}\n{{#invoke:test|getArg|a|b}}", + "selser [[0,3,0]]": "{{#invoke:test|getArg|2|a|2=b}}{{#invoke:test|getArg|2|2=a|b}}", + "selser [2]": "1pjtrsw\n\n{{#invoke:test|getArg|2|a|2=b}}\n{{#invoke:test|getArg|2|2=a|b}}", + "selser [[0,2,0]]": "{{#invoke:test|getArg|2|a|2=b}}lf2d8h\n{{#invoke:test|getArg|2|2=a|b}}", + "selser [1]": "{{#invoke:test|getArg|2|a|2=b}}\n{{#invoke:test|getArg|2|2=a|b}}", + "selser [[0,4,0]]": "{{#invoke:test|getArg|2|a|2=b}}1vmugjj{{#invoke:test|getArg|2|2=a|b}}" + }, + "Scribunto: template-style argument trimming": { + "wt2wt": "{{#invoke:test|getArgLength|2| x }}\n{{#invoke:test|getArgLength|x}}", + "selser [[0,4,0]]": "{{#invoke:test|getArgLength|2| x }}149a6ep{{#invoke:test|getArgLength|2|2= x }}", + "selser [[0,3,0]]": "{{#invoke:test|getArgLength|2| x }}{{#invoke:test|getArgLength|2|2= x }}", + "selser [1]": "{{#invoke:test|getArgLength|2| x }}\n{{#invoke:test|getArgLength|2|2= x }}", + "selser [2]": "1pj31bg\n\n{{#invoke:test|getArgLength|2| x }}\n{{#invoke:test|getArgLength|2|2= x }}", + "selser [[0,2,0]]": "{{#invoke:test|getArgLength|2| x }}1ulspwn\n{{#invoke:test|getArgLength|2|2= x }}" + } +} diff --git a/tests/parser/luaParserTests.txt b/tests/parser/luaParserTests.txt index ccb67420..7bfba226 100644 --- a/tests/parser/luaParserTests.txt +++ b/tests/parser/luaParserTests.txt @@ -1,4 +1,8 @@ -!! Version 2 +!! options +parsoid-compatible +version=2 +!! end + # Force the test runner to ensure the extension is loaded !! functionhooks invoke @@ -183,7 +187,6 @@ return { } !! endarticle - !! article Module:Metatables !! text @@ -231,24 +234,34 @@ Template:Scribunto_frame_caching !! test Scribunto: no such module +!! options +parsoid={ "modes": ["wt2html","wt2wt"] } !! wikitext {{#invoke:foo|bar}} -!! html +!! html/php

Script error: No such module "foo".

+!! html/parsoid +

Script error: No such module "foo".

!! end !! test Scribunto: no such function +!! options +parsoid={ "modes": ["wt2html","wt2wt"] } !! wikitext {{#invoke:test|blah}} -!! html +!! html/php

Script error: The function "blah" does not exist.

+!! html/parsoid +

Script error: The function "blah" does not exist.

!! end !! test Scribunto: hello world +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|hello}} !! html @@ -258,6 +271,8 @@ Scribunto: hello world !! test Scribunto: getAllArgs +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|getAllArgs|x|y|z|a=1|b=2|c=3|7=?}} !! html @@ -267,6 +282,8 @@ Scribunto: getAllArgs !! test Scribunto: getAllArgs, deprecated style +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|getAllArgs2|x|y|z|a=1|b=2|c=3|7=?}} !! html @@ -276,6 +293,8 @@ Scribunto: getAllArgs, deprecated style !! test Scribunto: getNumericArgs +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|getNumericArgs|x|y|z|a=1|b=2|c=3|7=?}} !! html @@ -285,28 +304,40 @@ Scribunto: getNumericArgs !! test Scribunto: named numeric parameters +!! options +parsoid={ "modes": ["wt2html","wt2wt"] } !! wikitext {{#invoke:test|getArg|2|a|2=b}} {{#invoke:test|getArg|2|2=a|b}} -!! html +!! html/php

b b

+!! html/parsoid +

b +b

!! end !! test Scribunto: template-style argument trimming +!! options +parsoid={ "modes": ["wt2html","wt2wt"] } !! wikitext {{#invoke:test|getArgLength|2| x }} {{#invoke:test|getArgLength|2|2= x }} -!! html +!! html/php

3 1

+!! html/parsoid +

3 +1

!! end !! test Scribunto: missing argument +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|getArgType|2}} {{#invoke:test|getArgType|blah}} @@ -318,6 +349,8 @@ nil !! test Scribunto: parent frame access +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{Scribunto_all_args|x|y|z|a = 1|b = 2|c = 3}} !! html @@ -327,6 +360,8 @@ Scribunto: parent frame access !! test Scribunto: expandTemplate +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|testExpandTemplate}} !! html @@ -336,6 +371,8 @@ Scribunto: expandTemplate !! test Scribunto: expandTemplate with headers +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext ==foo== {{#invoke:test|testExpandTemplateWithHeaders}} @@ -346,6 +383,8 @@ Scribunto: expandTemplate with headers !! test Scribunto: newTemplateParserValue +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|testNewTemplateParserValue}} !! html @@ -355,6 +394,8 @@ Scribunto: newTemplateParserValue !! test Scribunto: preprocess +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|testPreprocess|foo}} !! html @@ -364,6 +405,8 @@ Scribunto: preprocess !! test Scribunto: newParserValue +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|testNewParserValue|foo}} !! html @@ -373,6 +416,8 @@ Scribunto: newParserValue !! test Scribunto: table return +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|emptyTable}} !! html @@ -382,6 +427,8 @@ Scribunto: table return !! test Scribunto: require +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|import}} !! html @@ -391,6 +438,8 @@ Scribunto: require !! test Scribunto: access to a module imported at the chunk level +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|bitop}} !! html @@ -400,6 +449,8 @@ Scribunto: access to a module imported at the chunk level !! test Scribunto: invoke instance upvalue isolation +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|isolationTestUpvalue|1}} {{#invoke:test|isolationTestUpvalue|2}} @@ -413,6 +464,8 @@ Scribunto: invoke instance upvalue isolation !! test Scribunto: invoke instance global isolation +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|isolationTestGlobal|1}} {{#invoke:test|isolationTestGlobal|2}} @@ -426,6 +479,8 @@ Scribunto: invoke instance global isolation !! test Scribunto: ASCII null +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|null}} !! html @@ -437,6 +492,7 @@ Scribunto: ASCII null Scribunto: isSubsting during PST !! options pst +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{safesubst:#invoke:test|isSubsting}} !! html @@ -445,6 +501,8 @@ true !! test Scribunto: isSubsting during normal parse +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{safesubst:#invoke:test|isSubsting}} !! html @@ -454,6 +512,8 @@ Scribunto: isSubsting during normal parse !! test Scribunto: frame:getTitle +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|getFrameTitle}} !! html @@ -463,6 +523,8 @@ Scribunto: frame:getTitle !! test Scribunto: Metatable on export table +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:Metatables|zero}} {{#invoke:Metatables|one}} @@ -476,6 +538,8 @@ You called the two method from mt2 !! test Scribunto: Correct argument numbering with equals sign in function name +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|test=InFunctionName|good|bad}} !! html @@ -485,6 +549,8 @@ Scribunto: Correct argument numbering with equals sign in function name !! test Scribunto: Strip markers in CSS +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext {{#invoke:test|testStrippedCss|#ff0000}} !! html @@ -493,9 +559,56 @@ Scribunto: Strip markers in CSS !! test Scribunto: Parser output isn't incorrectly cached across frames +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } !! wikitext Root: {{#invoke:test|testFrameCaching}} Template: {{Scribunto frame caching}} !! html

Root: Parent frame is the root: yes. Child frame is the root: no. Template: Parent frame is the root: no. Child frame is the root: no.

!! end + +# Tests for T272507 +!! article +Module:EchoTest +!! text +local p = {} +function p.echo(frame) + return frame.args[1] +end +return p +!! end + +!! article +Module:UnstripTest +!! text +local p = {} +function p.unstrip(frame) + return mw.text.nowiki(mw.text.unstripNoWiki(frame.args[1])) +end +return p +!! end + +!! test +Scribunto: Test unstripNowiki behavior +!! options +parsoid={ "modes": ["wt2html","wt2wt"] } +!! wikitext +{{#invoke:EchoTest|echo|foo}} +{{#invoke:EchoTest|echo|[[Foo]]}} + +{{#invoke:UnstripTest|unstrip|foo}} +{{#invoke:UnstripTest|unstrip|[[Foo]]}} +!! html/php +

foo +[[Foo]] +

foo +[[Foo]] +

+!! html/parsoid +

foo +[[Foo]]

+ +

foo +[[Foo]]

+!! end