Improve Parser::braceSubstitution() coverage
authorKunal Mehta <legoktm@member.fsf.org>
Sun, 27 May 2018 05:57:55 +0000 (22:57 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Sun, 27 May 2018 05:57:55 +0000 (22:57 -0700)
Change-Id: I3d9426143fe486c6aed0494b68773a36e24c02d9

tests/parser/ParserTestRunner.php
tests/parser/parserTests.txt

index 08ec9f6..ce1dae6 100644 (file)
@@ -829,6 +829,13 @@ class ParserTestRunner {
                        $titleText = 'Parser test';
                }
 
+               if ( isset( $opts['maxincludesize'] ) ) {
+                       $options->setMaxIncludeSize( $opts['maxincludesize'] );
+               }
+               if ( isset( $opts['maxtemplatedepth'] ) ) {
+                       $options->setMaxTemplateDepth( $opts['maxtemplatedepth'] );
+               }
+
                $local = isset( $opts['local'] );
                $preprocessor = isset( $opts['preprocessor'] ) ? $opts['preprocessor'] : null;
                $parser = $this->getParser( $preprocessor );
@@ -1083,6 +1090,11 @@ class ParserTestRunner {
                        'wgFragmentMode' => [ 'legacy' ],
                ];
 
+               $nonIncludable = self::getOptionValue( 'wgNonincludableNamespaces', $opts, false );
+               if ( $nonIncludable !== false ) {
+                       $setup['wgNonincludableNamespaces'] = [ $nonIncludable ];
+               }
+
                if ( $config ) {
                        $configLines = explode( "\n", $config );
 
index d17fbbe..bffc56e 100644 (file)
@@ -109,6 +109,14 @@ Template:echo
 {{{1}}}
 !! endarticle
 
+!! article
+Template:echo3
+!! text
+{{{1}}}
+{{{1}}}
+{{{1}}}
+!! endarticle
+
 // For Serbian; localize Template namespace
 !! article
 Шаблон:Echo
@@ -128,6 +136,12 @@ Template:echo_with_div
 <div>{{{1}}}</div>
 !! endarticle
 
+!! article
+Template:echo with depth
+!! text
+{{echo|{{{1}}}}}
+!! endarticle
+
 !! article
 Template:blank_param
 !! text
@@ -1825,6 +1839,28 @@ b
 </p>
 !! end
 
+!! test
+post-expand include size being exceeded
+!! options
+maxincludesize=20
+!! wikitext
+{{echo3|1234567890}}
+!! html
+<p><a href="/wiki/Template:Echo3" title="Template:Echo3">Template:Echo3</a><!-- WARNING: template omitted, post-expand include size too large -->
+</p>
+!! end
+
+!! test
+max template depth being reached
+!! options
+maxtemplatedepth=1
+!! wikitext
+{{echo with depth|too deep!}}
+!! html
+<p><span class="error">Template recursion depth limit exceeded (1)</span>
+</p>
+!! end
+
 !! test
 Multiple comments should still parse as SOL-transparent
 !! options
@@ -11504,6 +11540,17 @@ Template from main namespace
 </p>
 !! end
 
+!! test
+Template from non-includable namespace
+!! options
+wgNonincludableNamespaces=10
+!! wikitext
+{{echo|uh oh!}}
+!! html
+<p><a href="/wiki/Template:Echo" title="Template:Echo">Template:Echo</a>
+</p>
+!! end
+
 !! article
 Template:table
 !! text