Skip to content

Commit b6706cd

Browse files
update python scripts
1 parent d2cbdb5 commit b6706cd

File tree

6 files changed

+29
-238
lines changed

6 files changed

+29
-238
lines changed

code/tests/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
if get_option('with_test').enabled()
2-
run_command(['python3', 'tools' / 'generate-runner.py'], check: true)
2+
run_command(['python3', 'tools' / 'runner.py'], check: true)
33
cards = run_command(['python3', 'tools' / 'wildcard.py'], check: true)
44

55
test_cases = ['unit_runner.c', cards.stdout().strip().split('\n')]

code/tests/tools/generate-note.py

Lines changed: 0 additions & 129 deletions
This file was deleted.

code/tests/tools/generate-runner.py renamed to code/tests/tools/runner.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
11
import os
22
import re
3+
import sys
34

45

56
class TestRunnerGenerator:
67
def __init__(self):
78
# Set the directory to a subdirectory named 'cases' within the current working directory
89
self.directory = os.path.join(os.getcwd(), "cases")
10+
# Detect if running on Apple (macOS)
11+
self.is_apple = sys.platform == "darwin"
912

1013
def find_test_groups(self):
11-
test_groups = set()
14+
c_cpp_groups = set()
15+
objc_groups = set()
16+
objcpp_groups = set()
1217
pattern = r"FOSSIL_TEST_GROUP\((\w+)\)"
1318

1419
# Walk through files in the specified directory, 'cases'
1520
for root, _, files in os.walk(self.directory):
1621
for file in files:
17-
# Search for C and C++ files
18-
if (file.startswith("test_") and file.endswith(".c")) or file.endswith(".cpp"):
19-
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:
2025
content = f.read()
2126
matches = re.findall(pattern, content)
22-
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)
2333

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

2636
def generate_c_runner(self, test_groups):
2737
# Prepare header content for the test runner
@@ -71,7 +81,12 @@ def generate_c_runner(self, test_groups):
7181

7282
# Instantiate the generator, find test groups, and generate the test runner
7383
generator = TestRunnerGenerator()
74-
test_groups = generator.find_test_groups()
84+
c_cpp_groups, objc_groups, objcpp_groups = generator.find_test_groups()
7585

76-
# Generate the test runner for C and C++ tests
77-
generator.generate_c_runner(test_groups)
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
90+
91+
# Generate the test runner for C and C++ (and Objective-C/Objective-C++ on Apple) tests
92+
generator.generate_c_runner(test_groups)

code/tests/tools/scan-code.py

Lines changed: 0 additions & 57 deletions
This file was deleted.

code/tests/tools/scan-todos.py

Lines changed: 0 additions & 40 deletions
This file was deleted.

code/tests/tools/wildcard.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import glob
2+
import sys
23

34
# Collect all .c and .cpp files directly in the cases directory (not subdirectories)
45
source_files = glob.glob("cases/*.c") + glob.glob("cases/*.cpp")
56

6-
# Sort files from a to z
7-
source_files.sort()
7+
# On Apple platforms, also include Objective-C and Objective-C++ files
8+
if sys.platform == "darwin":
9+
source_files += glob.glob("cases/*.m") + glob.glob("cases/*.mm")
810

911
# Print each file name with "cases/" prefix
1012
for file in source_files:

0 commit comments

Comments
 (0)