Backed out 2 changesets (bug 1589056) for lint failure on test_formatters.py. CLOSED TREE

Backed out changeset 6bd10819c814 (bug 1589056)
Backed out changeset 4253a2fb8848 (bug 1589056)
This commit is contained in:
Razvan Maries 2019-10-23 15:48:39 +03:00
Родитель a2b0ab008b
Коммит a5f7ecde59
8 изменённых файлов: 13 добавлений и 129 удалений

Просмотреть файл

@ -106,8 +106,8 @@ emitted:
Name of the subtest (string).
``status``
Result of the test (string enum; ``PASS``, ``FAIL``,
``PRECONDITION_FAILED``, ``TIMEOUT``, ``NOTRUN``)
Result of the test (string enum; ``PASS``, ``FAIL``, ``TIMEOUT``,
``NOTRUN``)
``expected``
Expected result of the test. Omitted if the expected result is the
@ -126,11 +126,10 @@ emitted:
``status``
Either result of the test (if there are no subtests) in which case
(string enum ``PASS``, ``FAIL``, ``PRECONDITION_FAILED``,
``TIMEOUT``, ``CRASH``, ``ASSERT``, , ``SKIP``) or the status of
the overall file where there are subtests (string enum ``OK``,
``PRECONDITION_FAILED``, ``ERROR``, ``TIMEOUT``, ``CRASH``,
``ASSERT``, ``SKIP``).
(string enum ``PASS``, ``FAIL``, ``TIMEOUT``, ``CRASH``,
``ASSERT``, ``SKIP``) or the status of the overall file where
there are subtests (string enum ``OK``, ``ERROR``, ``TIMEOUT``,
``CRASH``, ``ASSERT``, ``SKIP``).
``expected``
The expected status, or omitted if the expected status matches the

Просмотреть файл

@ -51,7 +51,6 @@ class GroupingFormatter(base.BaseFormatter):
'OK': 0,
'PASS': 0,
'FAIL': 0,
'PRECONDITION_FAILED': 0,
'ERROR': 0,
'TIMEOUT': 0,
'SKIP': 0,
@ -62,7 +61,6 @@ class GroupingFormatter(base.BaseFormatter):
'OK': [],
'PASS': [],
'FAIL': [],
'PRECONDITION_FAILED': [],
'ERROR': [],
'TIMEOUT': [],
'CRASH': [],
@ -307,8 +305,6 @@ class GroupingFormatter(base.BaseFormatter):
output += text_for_unexpected_list(u"crashed unexpectedly", 'CRASH')
output += text_for_unexpected_list(u"had errors unexpectedly", 'ERROR')
output += text_for_unexpected_list(u"failed unexpectedly", 'FAIL')
output += text_for_unexpected_list(u"precondition failed unexpectedly",
'PRECONDITION_FAILED')
output += text_for_unexpected_list(u"timed out unexpectedly", 'TIMEOUT')
output += text_for_unexpected_list(u"passed unexpectedly", 'PASS')
output += text_for_unexpected_list(u"unexpectedly okay", 'OK')

Просмотреть файл

@ -133,7 +133,7 @@ class HTMLFormatter(base.BaseFormatter):
self.test_count[status_name] += 1
if status in ['SKIP', 'FAIL', 'PRECONDITION_FAILED', 'ERROR']:
if status in ['SKIP', 'FAIL', 'ERROR']:
if debug.get('differences'):
images = [
('image1', 'Image 1 (test)'),

Просмотреть файл

@ -31,11 +31,10 @@ class UnittestFormatter(base.BaseFormatter):
if "expected" in data:
status = data["status"]
char = {"FAIL": "F",
"PRECONDITION_FAILED": "F",
"ERROR": "E",
"PASS": "X"}[status]
if status == "FAIL" or status == "PRECONDITION_FAILED":
if status == "FAIL":
self.fails.append(data)
elif status == "ERROR":
self.errors.append(data)

Просмотреть файл

@ -190,8 +190,7 @@ class TestId(DataType):
class Status(DataType):
allowed = ["PASS", "FAIL", "OK", "ERROR", "TIMEOUT", "CRASH", "ASSERT", "PRECONDITION_FAILED",
"SKIP"]
allowed = ["PASS", "FAIL", "OK", "ERROR", "TIMEOUT", "CRASH", "ASSERT", "SKIP"]
def convert(self, data):
value = data.upper()
@ -201,8 +200,7 @@ class Status(DataType):
class SubStatus(Status):
allowed = ["PASS", "FAIL", "ERROR", "TIMEOUT", "ASSERT", "PRECONDITION_FAILED", "NOTRUN",
"SKIP"]
allowed = ["PASS", "FAIL", "ERROR", "TIMEOUT", "ASSERT", "NOTRUN", "SKIP"]
class Dict(ContainerType):

Просмотреть файл

@ -31,8 +31,8 @@ Allowed actions, and subfields:
test_end
test - ID for the test
status [PASS | FAIL | OK | ERROR | TIMEOUT | CRASH |
ASSERT PRECONDITION_FAILED | SKIP] - test status
status [PASS | FAIL | OK | ERROR |
TIMEOUT | CRASH | ASSERT | SKIP] - test status
expected [As for status] - Status that the test was expected to get,
or absent if the test got the expected status
extra - Dictionary of harness-specific extra information e.g. debug info
@ -42,8 +42,7 @@ Allowed actions, and subfields:
test_status
test - ID for the test
subtest - Name of the subtest
status [PASS | FAIL | TIMEOUT |
PRECONDITION_FAILED | NOTRUN | SKIP] - test status
status [PASS | FAIL | TIMEOUT | NOTRUN | SKIP] - test status
expected [As for status] - Status that the subtest was expected to get,
or absent if the subtest got the expected status
known_intermittent - List of known intermittent statuses that should

Просмотреть файл

@ -137,58 +137,6 @@ test_baz
""".lstrip(b'\n')),
],
'PRECONDITION_FAILED': [
('mach', {}, b"""
0:00.00 SUITE_START: running 2 tests
0:00.00 TEST_START: test_foo
0:00.00 TEST_END: PRECONDITION_FAILED, expected OK
0:00.00 TEST_START: test_bar
0:00.00 TEST_END: Test OK. Subtests passed 1/2. Unexpected 1
PRECONDITION_FAILED another subtest
0:00.00 SUITE_END
suite 1
~~~~~~~
Ran 4 checks (2 subtests, 2 tests)
Expected results: 2
Unexpected results: 2
test: 1 (1 precondition_failed)
subtest: 1 (1 precondition_failed)
Unexpected Results
------------------
test_foo
PRECONDITION_FAILED test_foo
test_bar
PRECONDITION_FAILED another subtest
""".lstrip(b'\n')),
('mach', {'verbose': True}, b"""
0:00.00 SUITE_START: running 2 tests
0:00.00 TEST_START: test_foo
0:00.00 TEST_END: PRECONDITION_FAILED, expected OK
0:00.00 TEST_START: test_bar
0:00.00 PASS a subtest
0:00.00 PRECONDITION_FAILED another subtest
0:00.00 TEST_END: Test OK. Subtests passed 1/2. Unexpected 1
0:00.00 SUITE_END
suite 1
~~~~~~~
Ran 4 checks (2 subtests, 2 tests)
Expected results: 2
Unexpected results: 2
test: 1 (1 precondition_failed)
subtest: 1 (1 precondition_failed)
Unexpected Results
------------------
test_foo
PRECONDITION_FAILED test_foo
test_bar
PRECONDITION_FAILED another subtest
""".lstrip(b'\n')),
],
'KNOWN-INTERMITTENT': [
('mach', {}, b"""
0:00.00 SUITE_START: running 3 tests
@ -314,29 +262,6 @@ def test_fail(name, opts, expected):
logger.test_end('test_baz', 'PASS', 'FAIL')
logger.suite_end()
result = buf.getvalue()
print("Dumping result for copy/paste:")
print(result)
assert result == expected
@pytest.mark.parametrize("name,opts,expected", FORMATS['PRECONDITION_FAILED'],
ids=ids('PRECONDITION_FAILED'))
def test_precondition_failed(name, opts, expected):
buf = BytesIO()
fmt = formatters[name](**opts)
logger = StructuredLogger('test_logger')
logger.add_handler(StreamHandler(buf, fmt))
logger.suite_start(['test_foo', 'test_bar'])
logger.test_start('test_foo')
logger.test_end('test_foo', 'PRECONDITION_FAILED')
logger.test_start('test_bar')
logger.test_status('test_bar', 'a subtest', 'PASS')
logger.test_status('test_bar', 'another subtest', 'PRECONDITION_FAILED')
logger.test_end('test_bar', 'OK')
logger.suite_end()
result = buf.getvalue()
print("Dumping result for copy/paste:")
print(result)

Просмотреть файл

@ -101,18 +101,6 @@ class TestStatusHandler(BaseStructuredTest):
self.assertEqual(3, summary.action_counts['test_status'])
self.assertEqual(1, summary.action_counts['test_end'])
def test_precondition_failed_run(self):
self.logger.suite_start([])
self.logger.test_start("test1")
self.logger.test_end("test1", status='PRECONDITION_FAILED')
self.logger.test_start("test2")
self.logger.test_status("test2", "sub1", status='PRECONDITION_FAILED')
self.logger.test_end("test2", status='OK')
self.logger.suite_end()
summary = self.handler.summarize()
self.assertEqual(1, summary.expected_statuses['OK'])
self.assertEqual(2, summary.unexpected_statuses['PRECONDITION_FAILED'])
def test_error_run(self):
self.logger.suite_start([])
self.logger.test_start("test1")
@ -163,26 +151,6 @@ class TestSummaryHandler(BaseStructuredTest):
self.assertEqual(1, len(logs['test1']))
self.assertEqual('sub2', logs['test1'][0]['subtest'])
def test_precondition_failed_run(self):
self.logger.suite_start([])
self.logger.test_start("test1")
self.logger.test_status("test1", "sub1", status='PASS')
self.logger.test_end("test1", status='PRECONDITION_FAILED')
self.logger.test_start("test2")
self.logger.test_status("test2", "sub1", status='PRECONDITION_FAILED')
self.logger.test_status("test2", "sub2", status='PRECONDITION_FAILED')
self.logger.test_end("test2", status='OK')
self.logger.suite_end()
counts = self.handler.current['counts']
self.assertIn('precondition_failed', counts['test']['unexpected'])
self.assertEqual(1, counts['test']['unexpected']['precondition_failed'])
self.assertIn('pass', counts['subtest']['expected'])
self.assertEqual(1, counts['subtest']['expected']['pass'])
self.assertIn('ok', counts['test']['expected'])
self.assertEqual(1, counts['test']['expected']['ok'])
self.assertIn('precondition_failed', counts['subtest']['unexpected'])
self.assertEqual(2, counts['subtest']['unexpected']['precondition_failed'])
class TestStructuredLog(BaseStructuredTest):