Some improvements

This commit is contained in:
Dirk Alders 2021-02-28 21:12:54 +01:00
parent a70a6c432b
commit 5e0b7e3e96
3 changed files with 22 additions and 24 deletions

View File

@ -4,10 +4,11 @@
import os
import json
import fstools
import re
import subprocess
from unittest.run import module_uid
from unittest.run import UNITTEST_KEY_TESTOBJECT_INFO
class termcolors:
HEADER = '\033[95m'
@ -92,7 +93,9 @@ def module_unittest_status(module_folder):
except IOError:
return STATUS_UNKNOWN
else:
if ut_ut['testobject_information'] != ut_lib['testobject_information'] or ut_ut['unittest_information'] != ut_lib['unittest_information']:
tested_version = ut_lib.get(UNITTEST_KEY_TESTOBJECT_INFO, {}).get('Version')
current_version = module_uid(os.path.join(module_folder, 'pylibs', os.path.basename(module_folder)))
if ut_ut['testobject_information'] != ut_lib['testobject_information'] or ut_ut['unittest_information'] != ut_lib['unittest_information'] or tested_version != current_version:
return STATUS_OLD
else:
ut_status = ut_lib.get('testobject_information', {}).get('State', 'unknown')

35
run.py
View File

@ -333,11 +333,11 @@ def unittest_finalise(unittest_folder):
#
print_action("Adding Lost Requirement Soul")
data_collection['lost_souls']['item_list'] = []
for req_id in data_collection['specification'].get('item_dict', {}):
item = data_collection['specification']['item_dict'][req_id]
for req_id in data_collection[UNITTEST_KEY_SPECIFICATION].get('item_dict', {}):
item = data_collection[UNITTEST_KEY_SPECIFICATION]['item_dict'][req_id]
if item['system_type_uid'] == '_MR7eNHYYEem_kd-7nxt1sg':
testcase_available = False
for testrun in data_collection['testrun_list']:
for testrun in data_collection[UNITTEST_KEY_TESTRUNS]:
if req_id in testrun['testcases']:
testcase_available = True
break
@ -347,9 +347,9 @@ def unittest_finalise(unittest_folder):
#
print_action("Adding Lost Testcase Soul")
data_collection['lost_souls']['testcase_list'] = []
for testrun in data_collection['testrun_list']:
for testrun in data_collection[UNITTEST_KEY_TESTRUNS]:
for tc_id in testrun.get('testcases', {}):
if tc_id not in data_collection['specification'].get('item_dict', {}) and tc_id not in data_collection['lost_souls']['testcase_list']:
if tc_id not in data_collection[UNITTEST_KEY_SPECIFICATION].get('item_dict', {}) and tc_id not in data_collection['lost_souls']['testcase_list']:
data_collection['lost_souls']['testcase_list'].append(tc_id)
print_info('"%s" has no corresponding testcase' % tc_id, FAIL)
#
@ -398,8 +398,6 @@ def unittest_publish(unittest_folder):
def unittest_status(unittest_folder):
config = imp.load_source('', os.path.join(unittest_folder, 'src', 'config.py'))
#
print_header('Checking status of all submodules')
print_action('Updating all submodules (fetch)')
process = subprocess.Popen("LANGUAGE='en_US.UTF-8 git' git submodule foreach git fetch", cwd=os.path.dirname(unittest_folder), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@ -427,7 +425,7 @@ def unittest_status(unittest_folder):
data[m] += line
for key in data:
if "working tree clean" not in data[key] and "working directory clean" not in data[key]:
data[key] = ("local changes", WARNING)
data[key] = ("local changes", FAIL)
elif "Your branch is behind" in data[key]:
data[key] = ("no up to date (try git pull)", FAIL)
elif "HEAD detached at" in data[key]:
@ -447,19 +445,16 @@ def unittest_status(unittest_folder):
with open(unittest_filename(unittest_folder, FILES['data-collection']), 'r') as fh:
data_collection = json.loads(fh.read())
print_action('Checking release state of this testrun... ')
if data_collection['testobject_information']['State'] != 'Released':
if data_collection[UNITTEST_KEY_TESTOBJECT_INFO]['State'] != 'Released':
print_info("FAILED", FAIL)
else:
print_info("SUCCESS", OKGREEN)
#
print_action('Checking up to dateness of testrults in library...')
try:
with open(os.path.join(unittest_folder, '..', 'pylibs', config.lib.__name__, '_testresults_', FILES['data-collection']), 'r') as fh:
lib_result = json.loads(fh.read())
except FileNotFoundError:
print_info("FAILED: Testresults not in library", FAIL)
else:
if data_collection['testobject_information'] != lib_result['testobject_information'] or data_collection['unittest_information'] != lib_result['unittest_information']:
print_info("FAILED", FAIL)
else:
print_info("SUCCESS", OKGREEN)
from unittest.module_status import module_unittest_status
print_action('Checking status of testrults in library...')
st = module_unittest_status(os.path.abspath(os.path.join(unittest_folder, '..')))
stc = {
'RELEASED': OKGREEN,
'IN_WORK': OKBLUE,
}.get(st, FAIL)
print_info(st, stc)

View File

@ -27,7 +27,7 @@ help:
@echo " - testrun_smoke: Run some testcases"
@echo " - testrun_single: Run one testcases"
release: release_testcases full publish
release: clean prepare testrun_full coverage_analysis finalise compile publish status
full: clean prepare testrun_full coverage_analysis finalise compile status
short: clean prepare testrun_short coverage_analysis finalise compile status
smoke: clean prepare testrun_smoke coverage_analysis finalise compile status