From 69432435e09ac2f08fb21fd8ab37347a626a1eb5 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 6 Jul 2017 18:06:43 -0700 Subject: [PATCH] parser: Add unit tests for parser output flags ('showflags' option) Add logic to ParserTestRunner to allow testing of ParserOutput flags, and use it in the existing {{REVISIONID}} test, and for the added flag for user-signature from I77de05849c (T84843). Change-Id: I96e3d050e17a2d7e3d0478c702ecd53310259f56 --- tests/parser/ParserTestRunner.php | 7 +++++++ tests/parser/parserTests.txt | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index 77717f0161..9dce73f0bb 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -778,6 +778,7 @@ class ParserTestRunner { if ( isset( $opts['pst'] ) ) { $out = $parser->preSaveTransform( $test['input'], $title, $user, $options ); + $output = $parser->getOutput(); } elseif ( isset( $opts['msg'] ) ) { $out = $parser->transformMsg( $test['input'], $options, $title ); } elseif ( isset( $opts['section'] ) ) { @@ -828,6 +829,12 @@ class ParserTestRunner { } } + if ( isset( $output ) && isset( $opts['showflags'] ) ) { + $actualFlags = array_keys( TestingAccessWrapper::newFromObject( $output )->mFlags ); + sort( $actualFlags ); + $out .= "\nflags=" . join( ', ', $actualFlags ); + } + ScopedCallback::consume( $teardownGuard ); $expected = $test['result']; diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 4c48ed53d6..041b40f149 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -10421,11 +10421,13 @@ parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } Magic Word: {{REVISIONID}} !! options parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +showflags !! wikitext {{REVISIONID}} !! html/*

1337

+flags=vary-revision-id !! end !! test @@ -13634,6 +13636,19 @@ pst !! end +!! test +ParserOutput flags from signature expansion (T84843) +!! options +pst +showflags +!! wikitext +~~~~ +!! html/php +[[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC) +flags=user-signature +!! end + + !! test pre-save transform: Signature expansion in nowiki tags (T2093) !! options -- 2.20.1