From 2b8c82e72515a396d886d73dcd92081af2cb8483 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sun, 9 Feb 2014 09:02:44 +0100 Subject: [PATCH] Bug 956474 - Enforce that keywords in expressions are recognized; r=wlach --- .../manifestparser/manifestparser.py | 2 +- .../tests/test_testmanifest.py | 24 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/testing/mozbase/manifestdestiny/manifestparser/manifestparser.py b/testing/mozbase/manifestdestiny/manifestparser/manifestparser.py index ffc764bb358c..d569523cfd80 100755 --- a/testing/mozbase/manifestdestiny/manifestparser/manifestparser.py +++ b/testing/mozbase/manifestdestiny/manifestparser/manifestparser.py @@ -276,7 +276,7 @@ def parse(text, **values): :rtype: the final value of the expression. :raises: :py:exc::ParseError: will be raised if parsing fails. """ - return ExpressionParser(text, values).parse() + return ExpressionParser(text, values, strict=True).parse() ### path normalization diff --git a/testing/mozbase/manifestdestiny/tests/test_testmanifest.py b/testing/mozbase/manifestdestiny/tests/test_testmanifest.py index 898706f4d040..bdeecb7ba117 100644 --- a/testing/mozbase/manifestdestiny/tests/test_testmanifest.py +++ b/testing/mozbase/manifestdestiny/tests/test_testmanifest.py @@ -2,7 +2,7 @@ import os import unittest -from manifestparser import TestManifest +from manifestparser import TestManifest, ParseError here = os.path.dirname(os.path.abspath(__file__)) @@ -13,22 +13,34 @@ class TestTestManifest(unittest.TestCase): # Test filtering based on platform: filter_example = os.path.join(here, 'filter-example.ini') manifest = TestManifest(manifests=(filter_example,)) - self.assertEqual([i['name'] for i in manifest.active_tests(os='win', disabled=False, exists=False)], + self.assertEqual([i['name'] for i in manifest.active_tests(os='win', toolkit='windows', disabled=False, exists=False)], ['windowstest', 'fleem']) - self.assertEqual([i['name'] for i in manifest.active_tests(os='linux', disabled=False, exists=False)], + self.assertEqual([i['name'] for i in manifest.active_tests(os='linux', toolkit='gtk2', disabled=False, exists=False)], ['fleem', 'linuxtest']) # Look for existing tests. There is only one: - self.assertEqual([i['name'] for i in manifest.active_tests()], + self.assertEqual([i['name'] for i in manifest.active_tests(os='', widget='')], ['fleem']) # You should be able to expect failures: - last_test = manifest.active_tests(exists=False, toolkit='gtk2')[-1] + last_test = manifest.active_tests(exists=False, toolkit='gtk2', os='linux')[-1] self.assertEqual(last_test['name'], 'linuxtest') self.assertEqual(last_test['expected'], 'pass') - last_test = manifest.active_tests(exists=False, toolkit='cocoa')[-1] + last_test = manifest.active_tests(exists=False, toolkit='cocoa', os='mac')[-1] self.assertEqual(last_test['expected'], 'fail') + def test_unknown_keywords(self): + filter_example = os.path.join(here, 'filter-example.ini') + manifest = TestManifest(manifests=(filter_example,)) + + with self.assertRaises(ParseError): + # toolkit missing + manifest.active_tests(os='win', disabled=False, exists=False) + + with self.assertRaises(ParseError): + # os missing + manifest.active_tests(toolkit='windows', disabled=False, exists=False) + def test_comments(self): """ ensure comments work, see