Backed out changeset b3fe7a6a4939 (bug 958147) for m4 test failures on a CLOSED TREE

This commit is contained in:
Carsten "Tomcat" Book 2015-03-05 14:00:33 +01:00
parent 01775237e6
commit d65d7abd09
2 changed files with 39 additions and 15 deletions

View File

@ -31,6 +31,18 @@ def skip_if(tests, values):
yield test
def run_if(tests, values):
"""
Sets disabled on all tests containing the `run-if` tag and whose condition
is False. This filter is added by default.
"""
tag = 'run-if'
for test in tests:
if tag in test and not parse(test[tag], **values):
test.setdefault('disabled', '{}: {}'.format(tag, test[tag]))
yield test
def fail_if(tests, values):
"""
Sets expected to 'fail' on all tests containing the `fail-if` tag and whose
@ -217,11 +229,12 @@ class chunk_by_dir(InstanceFilter):
DEFAULT_FILTERS = (
skip_if,
run_if,
fail_if,
)
"""
By default :func:`~.active_tests` will run the :func:`~.skip_if`
and :func:`~.fail_if` filters.
By default :func:`~.active_tests` will run the :func:`~.skip_if`,
:func:`~.run_if` and :func:`~.fail_if` filters.
"""

View File

@ -8,6 +8,7 @@ from manifestparser import TestManifest
from manifestparser.filters import (
subsuite,
skip_if,
run_if,
fail_if,
enabled,
exists,
@ -86,10 +87,11 @@ class BuiltinFilters(unittest.TestCase):
tests = (
{ "name": "test0" },
{ "name": "test1", "skip-if": "foo == 'bar'" },
{ "name": "test2", "fail-if": "foo == 'bar'" },
{ "name": "test3", "disabled": "some reason" },
{ "name": "test4", "subsuite": "baz" },
{ "name": "test5", "subsuite": "baz,foo == 'bar'" })
{ "name": "test2", "run-if": "foo == 'bar'" },
{ "name": "test3", "fail-if": "foo == 'bar'" },
{ "name": "test4", "disabled": "some reason" },
{ "name": "test5", "subsuite": "baz" },
{ "name": "test6", "subsuite": "baz,foo == 'bar'" })
def test_skip_if(self):
tests = deepcopy(self.tests)
@ -100,19 +102,28 @@ class BuiltinFilters(unittest.TestCase):
tests = list(skip_if(tests, {'foo': 'bar'}))
self.assertNotIn(self.tests[1], tests)
def test_run_if(self):
tests = deepcopy(self.tests)
tests = list(run_if(tests, {}))
self.assertNotIn(self.tests[2], tests)
tests = deepcopy(self.tests)
tests = list(run_if(tests, {'foo': 'bar'}))
self.assertEquals(len(tests), len(self.tests))
def test_fail_if(self):
tests = deepcopy(self.tests)
tests = list(fail_if(tests, {}))
self.assertNotIn('expected', tests[2])
self.assertNotIn('expected', tests[3])
tests = deepcopy(self.tests)
tests = list(fail_if(tests, {'foo': 'bar'}))
self.assertEquals(tests[2]['expected'], 'fail')
self.assertEquals(tests[3]['expected'], 'fail')
def test_enabled(self):
tests = deepcopy(self.tests)
tests = list(enabled(tests, {}))
self.assertNotIn(self.tests[3], tests)
self.assertNotIn(self.tests[4], tests)
def test_subsuite(self):
sub1 = subsuite()
@ -120,13 +131,13 @@ class BuiltinFilters(unittest.TestCase):
tests = deepcopy(self.tests)
tests = list(sub1(tests, {}))
self.assertNotIn(self.tests[4], tests)
self.assertEquals(tests[-1]['name'], 'test5')
self.assertNotIn(self.tests[5], tests)
self.assertEquals(tests[-1]['name'], 'test6')
tests = deepcopy(self.tests)
tests = list(sub2(tests, {}))
self.assertEquals(len(tests), 1)
self.assertIn(self.tests[4], tests)
self.assertIn(self.tests[5], tests)
def test_subsuite_condition(self):
sub1 = subsuite()
@ -135,11 +146,11 @@ class BuiltinFilters(unittest.TestCase):
tests = deepcopy(self.tests)
tests = list(sub1(tests, {'foo': 'bar'}))
self.assertNotIn(self.tests[4], tests)
self.assertNotIn(self.tests[5], tests)
self.assertNotIn(self.tests[6], tests)
tests = deepcopy(self.tests)
tests = list(sub2(tests, {'foo': 'bar'}))
self.assertEquals(len(tests), 2)
self.assertEquals(tests[0]['name'], 'test4')
self.assertEquals(tests[1]['name'], 'test5')
self.assertEquals(tests[0]['name'], 'test5')
self.assertEquals(tests[1]['name'], 'test6')