adaptions for change to rspec instead of reqif

This commit is contained in:
Dirk Alders 2025-03-17 12:47:12 +01:00
parent 5ec5cda68a
commit 50f0174176
6 changed files with 68 additions and 63 deletions

34
run.py
View File

@ -5,7 +5,7 @@ import fstools
from unittest import jsonlog
from unittest import output
import report
import reqif
import rspec
import json
import os
@ -139,12 +139,15 @@ class coverage_info(list):
def __str__(self):
rv = ''
for module in self:
rv += '%s (%.1f%% - %s)\n' % (module.get(jsonlog.COVI_KEY_NAME), module.get(jsonlog.COVI_KEY_LINE_COVERAGE), module.get(jsonlog.COVI_KEY_FILEPATH))
rv += '%s (%.1f%% - %s)\n' % (module.get(jsonlog.COVI_KEY_NAME),
module.get(jsonlog.COVI_KEY_LINE_COVERAGE), module.get(jsonlog.COVI_KEY_FILEPATH))
for py_file in module.get(jsonlog.COVI_KEY_FILES):
rv += ' %s (%.1f%% - %s)\n' % (py_file.get(jsonlog.COVI_KEY_NAME), py_file.get(jsonlog.COVI_KEY_LINE_COVERAGE), py_file.get(jsonlog.COVI_KEY_FILEPATH))
rv += ' %s (%.1f%% - %s)\n' % (py_file.get(jsonlog.COVI_KEY_NAME),
py_file.get(jsonlog.COVI_KEY_LINE_COVERAGE), py_file.get(jsonlog.COVI_KEY_FILEPATH))
for fragment in py_file.get(self.KEY_FRAGMENTS):
if fragment.get(self.KEY_END_LINE) is not None:
rv += ' %d - %d: %s\n' % (fragment.get(self.KEY_START_LINE), fragment.get(self.KEY_END_LINE), repr(fragment.get(self.KEY_COVERAGE_STATE)))
rv += ' %d - %d: %s\n' % (fragment.get(self.KEY_START_LINE),
fragment.get(self.KEY_END_LINE), repr(fragment.get(self.KEY_COVERAGE_STATE)))
else:
rv += ' %d - : %s\n' % (fragment.get(self.KEY_START_LINE), repr(fragment.get(self.COVERAGE_STATE)))
return rv
@ -211,12 +214,13 @@ def unittest_prepare(ut_folder):
testobject_info[jsonlog.TOBI_STATE] = jsonlog.TOBI_STATE_RELEASED if config.release_unittest_version == unittest_info[jsonlog.UTEI_VERSION] else jsonlog.TOBI_STATE_IN_DEVELOPMENT
testobject_info[jsonlog.TOBI_DEPENDENCIES] = []
for dependency in config.lib.__DEPENDENCIES__:
testobject_info[jsonlog.TOBI_DEPENDENCIES].append((dependency, jsonlog.module_uid(os.path.join(jsonlog.get_ut_src_folder(ut_folder), dependency))))
testobject_info[jsonlog.TOBI_DEPENDENCIES].append(
(dependency, jsonlog.module_uid(os.path.join(jsonlog.get_ut_src_folder(ut_folder), dependency))))
#
spec_filename = os.path.join(ut_folder, 'requirements', 'specification.reqif')
spec_filename = os.path.join(config.lib_path, '_requirements_', 'specification.py')
output.print_action("Adding Requirement Specification from %s" % spec_filename)
try:
spec = reqif.reqif_dict(spec_filename, 'Heading', 'Software Specification')
spec = rspec.rs_by_spec_file(spec_filename)
except FileNotFoundError:
output.print_info(output.STATUS_FAILED)
spec = {}
@ -279,9 +283,9 @@ def unittest_finalise(ut_folder):
#
output.print_action("Adding Lost Requirement Soul")
data_collection[jsonlog.MAIN_KEY_LOST_SOULS][jsonlog.LOST_ITEMLIST] = []
for req_id in data_collection[jsonlog.MAIN_KEY_SPECIFICATION].get(jsonlog.SPEC_ITEM_DICT, {}):
item = data_collection[jsonlog.MAIN_KEY_SPECIFICATION][jsonlog.SPEC_ITEM_DICT][req_id]
if item['system_type_uid'] == '_MR7eNHYYEem_kd-7nxt1sg':
for req_id in data_collection[jsonlog.MAIN_KEY_SPECIFICATION].get(rspec.rspec.KEY_MAIN_ENTRIES, {}):
item = data_collection[jsonlog.MAIN_KEY_SPECIFICATION][rspec.rspec.KEY_MAIN_ENTRIES][req_id]
if not req_id.lower().startswith("sec-"):
testcase_available = False
for testrun in data_collection[jsonlog.MAIN_KEY_TESTRUNS]:
if req_id in testrun[jsonlog.TRUN_TESTCASES]:
@ -289,13 +293,13 @@ def unittest_finalise(ut_folder):
break
if not testcase_available:
data_collection[jsonlog.MAIN_KEY_LOST_SOULS][jsonlog.LOST_ITEMLIST].append(req_id)
output.print_info('%s - "%s" has no corresponding testcase' % (item['system_uid'], item['Heading']), output.termcolors.FAIL)
output.print_info('%s - "%s" has no corresponding testcase' % (req_id, item['heading']), output.termcolors.FAIL)
#
output.print_action("Adding Lost Testcase Soul")
data_collection[jsonlog.MAIN_KEY_LOST_SOULS][jsonlog.LOST_TESTCASELIST] = []
for testrun in data_collection[jsonlog.MAIN_KEY_TESTRUNS]:
for tc_id in testrun.get(jsonlog.TRUN_TESTCASES, {}):
if tc_id not in data_collection[jsonlog.MAIN_KEY_SPECIFICATION].get(jsonlog.SPEC_ITEM_DICT, {}) and tc_id not in data_collection[jsonlog.MAIN_KEY_LOST_SOULS][jsonlog.LOST_TESTCASELIST]:
if tc_id not in data_collection[jsonlog.MAIN_KEY_SPECIFICATION].get(rspec.rspec.KEY_MAIN_ENTRIES, {}) and tc_id not in data_collection[jsonlog.MAIN_KEY_LOST_SOULS][jsonlog.LOST_TESTCASELIST]:
data_collection[jsonlog.MAIN_KEY_LOST_SOULS][jsonlog.LOST_TESTCASELIST].append(tc_id)
output.print_info('"%s" has no corresponding testcase' % tc_id, output.termcolors.FAIL)
#
@ -363,7 +367,8 @@ def unittest_status(ut_folder):
output.print_header('Checking GIT repository status')
# GIT FETCH
output.print_action('Fetching repository from server...')
process = subprocess.Popen("LANGUAGE='en_US.UTF-8 git' git submodule foreach git fetch", cwd=ut_folder, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process = subprocess.Popen("LANGUAGE='en_US.UTF-8 git' git submodule foreach git fetch",
cwd=ut_folder, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stderroutput = process.communicate()[1]
if stderroutput == b'':
output.print_info(output.STATUS_SUCCESS)
@ -374,7 +379,8 @@ def unittest_status(ut_folder):
output.print_info(jsonlog.status_git(ut_folder))
# SUBMODULES
output.print_action('Analysing submodule status...')
process = subprocess.Popen("LANGUAGE='en_US.UTF-8 git' git submodule foreach git status", cwd=ut_folder, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process = subprocess.Popen("LANGUAGE='en_US.UTF-8 git' git submodule foreach git status",
cwd=ut_folder, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdoutput, stderroutput = process.communicate()
if stderroutput == b'':
module = None

View File

@ -1,5 +0,0 @@
{%- import 'macros.tex' as macros %}
{{ '\\%s{%s}' % (sectype, macros.latex_filter(item.Heading))}}
{%- if 'Description' in item and item.Description != '' %}
{{ item.Description }}
{%- endif %}

View File

@ -1,16 +0,0 @@
{%- import 'macros.tex' as macros %}
{{ '\\%s{%s}' % (sectype, macros.latex_filter(item.Heading))}}
{{ '\\label{%s%s}' % (labeltype, item.system_uid)}}
{%- if 'Description' in item and item.Description != '' %}
\paragraph{Description}\mbox{}\\
{{ item.Description }}
{%- endif %}
{%- if 'ReasonForImplementation' in item and item.ReasonForImplementation != '' %}
\paragraph{Reason for the implementation}\mbox{}\\
{{ item.ReasonForImplementation }}
{%- endif %}
{%- if 'Fitcriterion' in item and item.Fitcriterion != '' %}
\paragraph{Fitcriterion}\mbox{}\\
{{ item.Fitcriterion }}
{%- endif %}

View File

@ -0,0 +1,5 @@
{%- import 'macros.tex' as macros %}
{{ '\\%s{%s}' % (sectype, macros.latex_filter(item.heading))}}
{%- if 'description' in item and item.description != '' %}
{{ item.description }}
{%- endif %}

View File

@ -0,0 +1,16 @@
{%- import 'macros.tex' as macros %}
{{ '\\%s{%s}' % (sectype, macros.latex_filter(item.heading))}}
{{ '\\label{%s%s}' % (labeltype, item.system_uid)}}
{%- if 'description' in item and item.description != '' %}
\paragraph{Description}\mbox{}\\
{{ item.description }}
{%- endif %}
{%- if 'reason' in item and item.reason != '' %}
\paragraph{Reason for the implementation}\mbox{}\\
{{ item.reason }}
{%- endif %}
{%- if 'fitcriterion' in item and item.fitcriterion != '' %}
\paragraph{Fitcriterion}\mbox{}\\
{{ item.fitcriterion }}
{%- endif %}

View File

@ -29,44 +29,43 @@
{%- endwith %}
\newpage
{%- if data.specification.get('item_dict', {})|length >0 %}
{%- if data.specification.get('entries', {})|length >0 %}
\section{Tested Requirements}
{%- for item_id in data.specification.uid_list_sorted %}
{%- if item_id not in data.lost_souls.item_list %}
{%- with item = data.specification.item_dict[item_id] %}
{%- if item.system_type_uid == '_4-K5EHYYEem_kd-7nxt1sg' %}
{%- with sectype = 'subsection' %}
{%- include 'reqif/heading.tex' %}
{%- endwith %}
{%- elif item.system_type_uid == '_MR7eNHYYEem_kd-7nxt1sg' %}
{%- with sectype = 'subsubsection', labeltype = 'item:' %}
{%- include 'reqif/requirement.tex' %}
{%- endwith %}
{%- if item_id not in data.lost_souls.item_list %}
{%- for testrun in data.testrun_list %}
{%- if item.system_uid in testrun.testcases %}
{%- with testcase = testrun.testcases[item.system_uid] %}
{%- include 'test/case_short.tex' %}
{%- endwith %}
{%- else %}
{%- for item_id in data.specification.sections %}
{%- with item = data.specification.entries[item_id] %}
{%- with sectype = 'subsection' %}
{%- include 'rspec/heading.tex' %}
{%- endwith %}
{%- endwith %}
{%- for req_id in data.specification.entries[item_id].childs %}
{%- with item = data.specification.entries[req_id] %}
{%- if req_id not in data.lost_souls.item_list %}
{%- for testrun in data.testrun_list %}
{%- if req_id in testrun.testcases %}
{%- with sectype = 'subsubsection' %}
{%- include 'rspec/requirement.tex' %}
{%- endwith %}
{%- with testcase = testrun.testcases[req_id] %}
{%- include 'test/case_short.tex' %}
{%- endwith %}
{%- else %}
\textcolor{orange}{\bf No testresults available!}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endwith %}
{%- endif %}
{%- endfor %}
{%- endfor %}
{%- endif %}
{% if data.lost_souls.item_list|length > 0 %}
\newpage
\section{\textcolor{red}{Requirements with no corresponding Testcase}}
{% for item_id in data.specification.uid_list_sorted %}
{% with item = data.specification.item_dict[item_id] %}
{% if item.system_type_uid == '_MR7eNHYYEem_kd-7nxt1sg' and item_id in data.lost_souls.item_list %}
{% for item_id in data.specification.entries %}
{% with item = data.specification.entries[item_id] %}
{% if item_id in data.lost_souls.item_list %}
{%- with sectype = 'subsection', labeltype = 'lost_soul:' %}
{% include 'reqif/requirement.tex' %}
{% include 'rspec/requirement.tex' %}
{%- endwith %}
{% endif %}
{% endwith %}
@ -101,7 +100,7 @@
{%- if testcase.levelno >= max_level and testcase.levelno <= absmax_level%}
{%- if item %}
{%- with sectype = 'subsubsection', labeltype = 'testcase:' + testrun.testrun_id + '__' %}
{%- include 'reqif/requirement.tex' %}
{%- include 'rspec/requirement.tex' %}
{%- endwith %}
{%- else %}
\subsubsection{ {{ macros.latex_filter(testcase.message) }} }\label{testcase:{{testrun.testrun_id}}__{{testcase.message}}}