@@ -1705,13 +1705,15 @@ def __eq__(self, other):
1705
1705
sorted (other .ztest_suite_names )))
1706
1706
1707
1707
class TestCase (DisablePyTestCollectionMixin ):
1708
+
1708
1709
def __init__ (self , name = None , testsuite = None ):
1709
1710
self .duration = 0
1710
1711
self .name = name
1711
1712
self .status = None
1712
1713
self .reason = None
1713
1714
self .testsuite = testsuite
1714
1715
self .output = ""
1716
+ self .freeform = False
1715
1717
1716
1718
def __lt__ (self , other ):
1717
1719
return self .name < other .name
@@ -1781,8 +1783,9 @@ def __init__(self, testsuite_root, workdir, name):
1781
1783
self .ztest_suite_names = []
1782
1784
1783
1785
1784
- def add_testcase (self , name ):
1786
+ def add_testcase (self , name , freeform = False ):
1785
1787
tc = TestCase (name = name , testsuite = self )
1788
+ tc .freeform = freeform
1786
1789
self .testcases .append (tc )
1787
1790
1788
1791
@staticmethod
@@ -2058,7 +2061,7 @@ def parse_subcases(self, test_path):
2058
2061
self .add_testcase (name )
2059
2062
2060
2063
if not subcases :
2061
- self .add_testcase (self .id )
2064
+ self .add_testcase (self .id , freeform = True )
2062
2065
2063
2066
self .ztest_suite_names = ztest_suite_names
2064
2067
@@ -2113,7 +2116,7 @@ def __init__(self, testsuite, platform, outdir):
2113
2116
# Fix an issue with copying objects from testsuite, need better solution.
2114
2117
def init_cases (self ):
2115
2118
for c in self .testsuite .testcases :
2116
- self .add_testcase (c .name )
2119
+ self .add_testcase (c .name , freeform = c . freeform )
2117
2120
2118
2121
def _get_run_id (self ):
2119
2122
""" generate run id from instance unique identifier and a random
@@ -2150,8 +2153,9 @@ def set_case_status_by_name(self, name, status, reason=None):
2150
2153
tc .reason = reason
2151
2154
return tc
2152
2155
2153
- def add_testcase (self , name ):
2156
+ def add_testcase (self , name , freeform = False ):
2154
2157
tc = TestCase (name = name )
2158
+ tc .freeform = freeform
2155
2159
self .testcases .append (tc )
2156
2160
return tc
2157
2161
@@ -4124,7 +4128,6 @@ def json_report(self, filename, version="NA"):
4124
4128
if instance .status is not None :
4125
4129
suite ["execution_time" ] = f"{ float (handler_time ):.2f} "
4126
4130
4127
-
4128
4131
testcases = []
4129
4132
4130
4133
if len (instance .testcases ) == 1 :
@@ -4133,6 +4136,12 @@ def json_report(self, filename, version="NA"):
4133
4136
single_case_duration = 0
4134
4137
4135
4138
for case in instance .testcases :
4139
+ # freeform was set when no sub testcases were parsed, however,
4140
+ # if we discover those at runtime, the fallback testcase wont be
4141
+ # needed anymore and can be removed from the output, it does
4142
+ # not have a status and would otherwise be reported as skipped.
4143
+ if case .freeform and case .status is None and len (instance .testcases ) > 1 :
4144
+ continue
4136
4145
testcase = {}
4137
4146
testcase ['identifier' ] = case .name
4138
4147
if instance .status :
0 commit comments