From dd1f55a3dce69cccefcd988d1f67a10a8890ad95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Thu, 4 May 2017 09:29:37 -0700 Subject: [PATCH] Allow to specify negative frontmatter values in templates files --- tools/generation/lib/template.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/generation/lib/template.py b/tools/generation/lib/template.py index 53bd03ba19..14cc3caebe 100644 --- a/tools/generation/lib/template.py +++ b/tools/generation/lib/template.py @@ -3,6 +3,7 @@ import os, re import codecs, yaml +from collections import OrderedDict from util.find_comments import find_comments from util.parse_yaml import parse_yaml @@ -151,23 +152,33 @@ class Template: features = [] features += case_values['meta'].get('features', []) features += self.attribs['meta'].get('features', []) + features = list(OrderedDict.fromkeys(features)) if len(features): lines += ['features: ' + yaml.dump(features).strip()] flags = ['generated'] flags += case_values['meta'].get('flags', []) flags += self.attribs['meta'].get('flags', []) + flags = list(OrderedDict.fromkeys(flags)) lines += ['flags: ' + yaml.dump(flags).strip()] includes = [] includes += case_values['meta'].get('includes', []) includes += self.attribs['meta'].get('includes', []) + includes = list(OrderedDict.fromkeys(includes)) if len(includes): lines += ['includes: ' + yaml.dump(includes).strip()] if case_values['meta'].get('negative'): + if self.attribs['meta'].get('negative'): + raise Exception('Cannot specify negative in case and template file') + negative = case_values['meta'].get('negative') + else: + negative = self.attribs['meta'].get('negative') + + if negative: lines += ['negative:'] - as_yaml = yaml.dump(case_values['meta'].get('negative'), + as_yaml = yaml.dump(negative, default_flow_style=False) lines += indent(as_yaml.strip(), ' ').split('\n')