Patchwork [3,of,3] test-template-engine: do not evaluate unused keywords by custom engine

login
register
mail settings
Submitter Yuya Nishihara
Date March 16, 2018, 4:02 p.m.
Message ID <c1f88589ddc9885b3902.1521216173@mimosa>
Download mbox | patch
Permalink /patch/29564/
State Accepted
Headers show

Comments

Yuya Nishihara - March 16, 2018, 4:02 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1521212774 -32400
#      Sat Mar 17 00:06:14 2018 +0900
# Node ID c1f88589ddc9885b39025f3d4b19a5cf3cfe3251
# Parent  7977db549515436936f56befb1b065d0b956996e
test-template-engine: do not evaluate unused keywords by custom engine

If the custom engine, "mytemplater", were installed as the default, it would
enter to an infinite recursion at stringify(v) because template keywords may
generate a nested mapping containing the same keywords.

Spotted by a future patch which will replace context.resource('templ')(...)
with context.process(...).

Patch

diff --git a/tests/test-template-engine.t b/tests/test-template-engine.t
--- a/tests/test-template-engine.t
+++ b/tests/test-template-engine.t
@@ -16,8 +16,7 @@ 
   >         props = self._defaults.copy()
   >         props.update(map)
   >         for k, v in props.items():
-  >             if k in (b'templ', b'ctx', b'repo', b'revcache', b'cache',
-  >                      b'troubles'):
+  >             if b'{{%s}}' % k not in tmpl:
   >                 continue
   >             if callable(v) and getattr(v, '_requires', None) is None:
   >                 props = self._resources.copy()