Commit 6df42e36 authored by Tamer Tas's avatar Tamer Tas Committed by Commit Bot

[testrunner] remove dead code

This code is very old and is not referenced anywhere else.

Verifying that the code isn't called anywhere else:
- https://cs.chromium.org/search/?q=FilterTestCasesByArgs&type=cs
- https://cs.chromium.org/search/?q=FilterTestCasesByStatus&type=cs

R=machenbach@chromium.org
CC=yangguo@chromium.org,sergiyb@chromium.org

No-Try: true
Change-Id: I18b0309430d86649046e64e863ca252951786061
Reviewed-on: https://chromium-review.googlesource.com/c/1394553Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Tamer Tas <tmrts@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58539}
parent fc664bda
......@@ -140,69 +140,6 @@ class TestSuite(object):
def ReadTestCases(self):
self.tests = self.ListTests()
def FilterTestCasesByStatus(self,
slow_tests_mode=None,
pass_fail_tests_mode=None):
"""Filters tests by outcomes from status file.
Status file has to be loaded before using this function.
Args:
slow_tests_mode: What to do with slow tests.
pass_fail_tests_mode: What to do with pass or fail tests.
Mode options:
None (default) - don't skip
"skip" - skip if slow/pass_fail
"run" - skip if not slow/pass_fail
"""
def _skip_slow(is_slow, mode):
return (
(mode == 'run' and not is_slow) or
(mode == 'skip' and is_slow))
def _skip_pass_fail(pass_fail, mode):
return (
(mode == 'run' and not pass_fail) or
(mode == 'skip' and pass_fail))
def _compliant(test):
if test.do_skip:
return False
if _skip_slow(test.is_slow, slow_tests_mode):
return False
if _skip_pass_fail(test.is_pass_or_fail, pass_fail_tests_mode):
return False
return True
self.tests = filter(_compliant, self.tests)
def FilterTestCasesByArgs(self, args):
"""Filter test cases based on command-line arguments.
args can be a glob: asterisks in any position of the argument
represent zero or more characters. Without asterisks, only exact matches
will be used with the exeption of the test-suite name as argument.
"""
filtered = []
globs = []
for a in args:
argpath = a.split('/')
if argpath[0] != self.name:
continue
if len(argpath) == 1 or (len(argpath) == 2 and argpath[1] == '*'):
return # Don't filter, run all tests in this suite.
path = '/'.join(argpath[1:])
globs.append(path)
for t in self.tests:
for g in globs:
if fnmatch.fnmatch(t.path, g):
filtered.append(t)
break
self.tests = filtered
def _create_test(self, path, **kwargs):
if self.suppress_internals:
test_class = self._suppressed_test_class()
......
......@@ -17,88 +17,6 @@ from testrunner.objects.testcase import TestCase
class TestSuiteTest(unittest.TestCase):
def test_filter_testcases_by_status_first_pass(self):
suite = TestSuite('foo', 'bar')
suite.rules = {
'': {
'foo/bar': set(['PASS', 'SKIP']),
'baz/bar': set(['PASS', 'FAIL']),
},
}
suite.prefix_rules = {
'': {
'baz/': set(['PASS', 'SLOW']),
},
}
suite.tests = [
TestCase(suite, 'foo/bar', 'foo/bar'),
TestCase(suite, 'baz/bar', 'baz/bar'),
]
suite.FilterTestCasesByStatus()
self.assertEquals(
[TestCase(suite, 'baz/bar', 'baz/bar')],
suite.tests,
)
outcomes = suite.GetStatusFileOutcomes(suite.tests[0].name,
suite.tests[0].variant)
self.assertEquals(set(['PASS', 'FAIL', 'SLOW']), outcomes)
def test_filter_testcases_by_status_second_pass(self):
suite = TestSuite('foo', 'bar')
suite.rules = {
'': {
'foo/bar': set(['PREV']),
},
'default': {
'foo/bar': set(['PASS', 'SKIP']),
'baz/bar': set(['PASS', 'FAIL']),
},
'stress': {
'baz/bar': set(['SKIP']),
},
}
suite.prefix_rules = {
'': {
'baz/': set(['PREV']),
},
'default': {
'baz/': set(['PASS', 'SLOW']),
},
'stress': {
'foo/': set(['PASS', 'SLOW']),
},
}
test1 = TestCase(suite, 'foo/bar', 'foo/bar')
test2 = TestCase(suite, 'baz/bar', 'baz/bar')
suite.tests = [
test1.create_variant(variant='default', flags=[]),
test1.create_variant(variant='stress', flags=['-v']),
test2.create_variant(variant='default', flags=[]),
test2.create_variant(variant='stress', flags=['-v']),
]
suite.FilterTestCasesByStatus()
self.assertEquals(
[
TestCase(suite, 'foo/bar', 'foo/bar').create_variant(None, ['-v']),
TestCase(suite, 'baz/bar', 'baz/bar'),
],
suite.tests,
)
self.assertEquals(
set(['PREV', 'PASS', 'SLOW']),
suite.GetStatusFileOutcomes(suite.tests[0].name,
suite.tests[0].variant),
)
self.assertEquals(
set(['PREV', 'PASS', 'FAIL', 'SLOW']),
suite.GetStatusFileOutcomes(suite.tests[1].name,
suite.tests[1].variant),
)
def test_fail_ok_outcome(self):
suite = TestSuite('foo', 'bar')
suite.rules = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment