Skip to content

Commit 1b5e426

Browse files
committed
Include TEMPLATE_TEST_CASEs in test count
So that we can use catch's `TEMPLATE_TEST_CASE` without the test count failing when using make to run the tests. When using `TEMPLATE_TEST_CASE` the number of tests added to catch's count of test depends on the number of type arguments supplied. Therefore this update is needed to count the arguments to get the correct count.
1 parent 416d18a commit 1b5e426

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

unit/count_tests.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,39 @@
88
import sys
99

1010

11+
class argument_separator_countert:
12+
def __init__(self):
13+
self.bracket_depth = 0
14+
self.separators = 0
15+
16+
def read_text(self, text):
17+
for character in text:
18+
if character == '(' or character == '<':
19+
self.bracket_depth += 1
20+
elif character == ')' or character == '(':
21+
self.bracket_depth -= 1
22+
elif character == ',' and self.bracket_depth == 1:
23+
self.separators += 1
24+
25+
1126
def tests_in_file(file_path):
1227
file_test_count = 0
28+
template_counter = None
1329
with open(file_path, "rt") as file:
1430
for line in file:
15-
if line.startswith("TEST_CASE"):
16-
file_test_count += 1
17-
if line.startswith("SCENARIO"):
18-
file_test_count += 1
31+
if template_counter is None:
32+
if line.startswith("TEST_CASE"):
33+
file_test_count += 1
34+
if line.startswith("SCENARIO"):
35+
file_test_count += 1
36+
if line.startswith("TEMPLATE_TEST_CASE"):
37+
template_counter = argument_separator_countert()
38+
template_counter.read_text(line)
39+
else:
40+
template_counter.read_text(line)
41+
if template_counter is not None and template_counter.bracket_depth == 0:
42+
file_test_count += (template_counter.separators - 1)
43+
template_counter = None
1944
return file_test_count
2045

2146

0 commit comments

Comments
 (0)