Skip to content

Commit b304575

Browse files
pillo79Copilot
andcommitted
extra: ci_shared: deduplicate TestEntry in JSON via composite key
TestEntry gains a key property: '{artifact}|{board}|{sketch}|{link_mode}'. This uniquely identifies each test; '|' cannot appear in any component. JSON schema change: - New top-level 'all_tests' dict: { key: TestEntry } - TestGroup 'tests' field: [key, ...] instead of [{...full entry...}, ...] TestGroup.to_dict() stores keys; TestGroup.from_dict(d, all_tests) looks up TestEntry objects from the shared dict. Each test is serialised once instead of once per group it belongs to (previously 3x). ci_collect_data: maintains ALL_TESTS dict, included in JSON output. ci_generate_report: reconstructs ALL_TESTS first, passes to from_dict. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent aff2118 commit b304575

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

extra/ci_collect_data.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
# Loader build results, one per board
5050
BOARD_LOADERS = {} # { board: LoaderEntry() }
5151

52+
# All test entries, keyed by (artifact, board, sketch, link_mode) composite key
53+
ALL_TESTS = {} # { key: TestEntry() }
54+
5255
# Test results grouped by artifact, board, and artifact/sketch
5356
# (grouping sketch results across different artifacts is really confusing)
5457
ARTIFACT_TESTS = defaultdict(TestGroup) # { artifact: TestGroup() }
@@ -73,6 +76,7 @@ def log_test(artifact, board, sketch, link_mode, exceptions, status, issues, job
7376
ARTIFACT_TESTS[artifact].track(test_entry)
7477
BOARD_TESTS[board].track(test_entry)
7578
SKETCH_TESTS[artifact][sketch].track(test_entry)
79+
ALL_TESTS[test_entry.key] = test_entry
7680

7781
# ---------------------------------------------------------------------------
7882
# Main Logic
@@ -194,6 +198,7 @@ def log_test(artifact, board, sketch, link_mode, exceptions, status, issues, job
194198
'all_board_data': ALL_BOARD_DATA,
195199
'regions_by_soc': {soc: list(regions) for soc, regions in REGIONS_BY_SOC.items()},
196200
'board_loaders': {board: loader.to_dict() for board, loader in BOARD_LOADERS.items()},
201+
'all_tests': {key: t.to_dict() for key, t in ALL_TESTS.items()},
197202
'artifact_tests': {artifact: tg.to_dict() for artifact, tg in ARTIFACT_TESTS.items()},
198203
'board_tests': {board: tg.to_dict() for board, tg in BOARD_TESTS.items()},
199204
'sketch_tests': {

extra/ci_generate_report.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import ci_shared
2323
from ci_shared import (
2424
TestStatus, SKIP, PASS, WARNING, EXPECTED_ERROR, INVALID_EXCEPTION, ERROR, FAILURE,
25-
LoaderEntry, TestGroup,
25+
LoaderEntry, TestEntry, TestGroup,
2626
)
2727

2828
BASE_COLOR = 0x20 # darkest tone
@@ -372,11 +372,14 @@ def print_mem_report(artifact, artifact_boards):
372372
for board, loader in data['board_loaders'].items()
373373
}
374374

375+
# Reconstruct all test entries first (needed by TestGroup.from_dict)
376+
ALL_TESTS = {key: TestEntry.from_dict(t) for key, t in data['all_tests'].items()}
377+
375378
# Reconstruct test group data structures
376-
ARTIFACT_TESTS = {artifact: TestGroup.from_dict(tg) for artifact, tg in data['artifact_tests'].items()}
377-
BOARD_TESTS = {board: TestGroup.from_dict(tg) for board, tg in data['board_tests'].items()}
379+
ARTIFACT_TESTS = {artifact: TestGroup.from_dict(tg, ALL_TESTS) for artifact, tg in data['artifact_tests'].items()}
380+
BOARD_TESTS = {board: TestGroup.from_dict(tg, ALL_TESTS) for board, tg in data['board_tests'].items()}
378381
SKETCH_TESTS = {
379-
artifact: {sketch: TestGroup.from_dict(tg) for sketch, tg in sketches.items()}
382+
artifact: {sketch: TestGroup.from_dict(tg, ALL_TESTS) for sketch, tg in sketches.items()}
380383
for artifact, sketches in data['sketch_tests'].items()
381384
}
382385

extra/ci_shared.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ def __init__(self, artifact, board, sketch, link_mode, excepted, status, issues,
159159
self.group = ""
160160
self.name = sketch
161161

162+
@property
163+
def key(self):
164+
return f"{self.artifact}|{self.board}|{self.sketch}|{self.link_mode}"
165+
162166
def to_dict(self):
163167
return {
164168
'artifact': self.artifact,
@@ -225,17 +229,17 @@ def to_dict(self):
225229
'group_names': [list(gn) for gn in self.group_names],
226230
'counts': {str(int(k)): v for k, v in self.counts.items()},
227231
'status': int(self.status),
228-
'tests': [t.to_dict() for t in self.tests],
232+
'tests': [t.key for t in self.tests],
229233
}
230234

231235
@classmethod
232-
def from_dict(cls, d):
236+
def from_dict(cls, d, all_tests):
233237
tg = cls.__new__(cls)
234238
tg.boards = set(d['boards'])
235239
tg.sketches = set(d['sketches'])
236240
tg.group_names = set(tuple(gn) for gn in d['group_names'])
237241
tg.counts = {TestStatus(int(k)): v for k, v in d['counts'].items()}
238242
tg.status = TestStatus(d['status'])
239-
tg.tests = [TestEntry.from_dict(t) for t in d['tests']]
243+
tg.tests = [all_tests[k] for k in d['tests']]
240244
tg.tests_with_issues = [t for t in tg.tests if t.issues]
241245
return tg

0 commit comments

Comments
 (0)