Skip to content

Commit 1485296

Browse files
try to resolve generator for test runner
1 parent 7b4d904 commit 1485296

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

code/tests/tools/generate-runner.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@ def __init__(self):
1111
self.is_apple = sys.platform == "darwin"
1212

1313
def find_test_groups(self):
14-
test_groups = set()
14+
c_cpp_groups = set()
15+
objc_groups = set()
16+
objcpp_groups = set()
1517
pattern = r"FOSSIL_TEST_GROUP\((\w+)\)"
1618

17-
# File extensions to include
18-
extensions = [".c", ".cpp"]
19-
if self.is_apple:
20-
extensions += [".m", ".mm"] # Objective-C and Objective-C++
21-
2219
# Walk through files in the specified directory, 'cases'
2320
for root, _, files in os.walk(self.directory):
2421
for file in files:
25-
# Search for test files with the allowed extensions
26-
if file.startswith("test_") and any(
27-
file.endswith(ext) for ext in extensions
28-
):
29-
with open(os.path.join(root, file), "r") as f:
22+
if file.startswith("test_"):
23+
file_path = os.path.join(root, file)
24+
with open(file_path, "r") as f:
3025
content = f.read()
3126
matches = re.findall(pattern, content)
32-
test_groups.update(matches)
27+
if file.endswith(".c") or file.endswith(".cpp"):
28+
c_cpp_groups.update(matches)
29+
elif self.is_apple and file.endswith(".m"):
30+
objc_groups.update(matches)
31+
elif self.is_apple and file.endswith(".mm"):
32+
objcpp_groups.update(matches)
3333

34-
return list(test_groups)
34+
return list(c_cpp_groups), list(objc_groups), list(objcpp_groups)
3535

3636
def generate_c_runner(self, test_groups):
3737
# Prepare header content for the test runner
@@ -81,7 +81,12 @@ def generate_c_runner(self, test_groups):
8181

8282
# Instantiate the generator, find test groups, and generate the test runner
8383
generator = TestRunnerGenerator()
84-
test_groups = generator.find_test_groups()
84+
c_cpp_groups, objc_groups, objcpp_groups = generator.find_test_groups()
85+
86+
# Only include Objective-C/Objective-C++ groups if on Apple
87+
test_groups = c_cpp_groups
88+
if generator.is_apple:
89+
test_groups += objc_groups + objcpp_groups
8590

8691
# Generate the test runner for C and C++ (and Objective-C/Objective-C++ on Apple) tests
8792
generator.generate_c_runner(test_groups)

0 commit comments

Comments
 (0)