提交 95098498 编写于 作者: L Lukáš Doktor

replay: Include non-executed tests in replay map

The "results.json" includes only executed tests in "tests" while the
non-executed tests are only included in the overall info like "total".
Let's append "UNKNOWN" tests at the end of the "tests" to represent
those non-executed tests and mark them as "INTERRUPTED".

According to our meanings they'd be "SKIP" tests, but this is local
representation for Replay only and we would not be able to distinguish
between SKIP and SKIP-AFTER-INTERRUPTION, which is super handy. To avoid
introducing new/artifical status, let's use INTERRUPTED which works for
our scenario and in the future we might expand it if needed.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 ebe788dd
......@@ -103,9 +103,12 @@ class Replay(CLI):
with open(json_results, 'r') as json_file:
results = json.loads(json_file.read())
tests = results["tests"]
for _ in xrange(results["total"] + 1 - len(tests)):
tests.append({"test": "UNKNOWN", "status": "INTERRUPTED"})
replay_map = []
for test in results['tests']:
for test in tests:
if test['status'] not in replay_filter:
replay_map.append(ReplaySkipTest)
else:
......
import os
import shutil
import tempfile
import unittest
from avocado.core import test
from avocado.plugins import replay
class Replay(unittest.TestCase):
"""
avocado.plugins.Replay unittests
"""
def setUp(self):
self.tmpdir = tempfile.mkdtemp(prefix='avocado_' + __name__)
def tearDown(self):
shutil.rmtree(self.tmpdir)
def test_replay_map_interrupted_json(self):
"""
Make sure unexecuted tests are appended
"""
with open(os.path.join(self.tmpdir, "results.json"), "w") as res:
res.write('{"skip": 3, "tests": [{"test": "executed", "status":'
'"PASS"}], "total": 4}')
rep = replay.Replay()
act = rep._create_replay_map(self.tmpdir, ["PASS"])
exp = [None, test.ReplaySkipTest, test.ReplaySkipTest, test.ReplaySkipTest, test.ReplaySkipTest]
self.assertEqual(act, exp)
act = rep._create_replay_map(self.tmpdir, ["INTERRUPTED"])
exp = [test.ReplaySkipTest, None, None, None, None]
self.assertEqual(act, exp)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册