From b291e0a7bb51513836d4dff500f64bc7968fca22 Mon Sep 17 00:00:00 2001 From: Silas Oettinghaus Date: Wed, 25 Mar 2026 09:38:48 +0100 Subject: [PATCH] Fix dashboard run metadata tracking per test --- Tests/test_dashboard.m | 44 +++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/Tests/test_dashboard.m b/Tests/test_dashboard.m index 75e6646..537896b 100644 --- a/Tests/test_dashboard.m +++ b/Tests/test_dashboard.m @@ -16,6 +16,7 @@ function app = test_dashboard(options) app = struct(); app.Inventory = table(); app.SelectedRow = []; + app.ActiveProfileRowIndices = []; app.LastRunStatusMap = containers.Map('KeyType', 'char', 'ValueType', 'char'); app.LastRunSummaryMap = containers.Map('KeyType', 'char', 'ValueType', 'char'); app.LastRunDateMap = containers.Map('KeyType', 'char', 'ValueType', 'char'); @@ -296,8 +297,10 @@ function app = test_dashboard(options) function runProfile(profile) titleText = sprintf("Running profile '%s'", profile); rowIndices = profileRowIndices(profile); + app.ActiveProfileRowIndices = rowIndices; markRowsAsRunning(rowIndices); runWithProgress(titleText, @() runProfileInternal(profile, rowIndices), table()); + app.ActiveProfileRowIndices = []; end function generateMissingTests(~, ~) @@ -320,7 +323,7 @@ function app = test_dashboard(options) appendLog(sprintf("[%s] %s", stamp(), titleText)); appendLog(output); updateRunStateFromResults(results, record); - writeRunArtifacts(titleText, results); + writeRunArtifacts(titleText, results, record); catch err appendLog(sprintf("[%s] %s failed.", stamp(), titleText)); appendLog(getReport(err, "extended", "hyperlinks", "off")); @@ -530,15 +533,18 @@ function app = test_dashboard(options) end end - function writeRunArtifacts(runLabel, results) + function writeRunArtifacts(runLabel, results, record) if ~isfolder(reportsRoot) mkdir(reportsRoot); end gitInfo = collectGitMetadata(repoRoot); + runTimestamp = char(datetime("now", "TimeZone", "local", "Format", "yyyy-MM-dd'T'HH:mm:ssXXX")); + updateMetadataMaps(results, record, runTimestamp, gitInfo.short_commit); + report = struct(); - report.timestamp = char(datetime("now", "TimeZone", "local", "Format", "yyyy-MM-dd'T'HH:mm:ssXXX")); - rowStates = inventoryRowStates(app.Inventory, report.timestamp, gitInfo.short_commit); + report.timestamp = runTimestamp; + rowStates = inventoryRowStates(app.Inventory); report.run_label = char(runLabel); report.repo_root = repoRoot; report.git = gitInfo; @@ -555,18 +561,24 @@ function app = test_dashboard(options) reportFile = fullfile(reportsRoot, sprintf('%s_%s.json', ... datestr(now, 'yyyy-mm-dd_HHMMSS'), sanitizeFileLabel(runLabel))); writeTextFile(reportFile, jsonText); - - updateMetadataMaps(report.timestamp, gitInfo.short_commit); appendLog(sprintf("[%s] Saved run report: %s", stamp(), reportFile)); end - function updateMetadataMaps(runDate, shortCommit) - for idx = 1:height(app.Inventory) - key = char(app.Inventory.TestFile(idx)); - if isempty(key) - continue - end - if isKey(app.LastRunStatusMap, key) + function updateMetadataMaps(results, record, runDate, shortCommit) + if ~isempty(record) && strlength(record.TestFile) > 0 + key = char(record.TestFile); + app.LastRunDateMap(key) = char(string(runDate)); + app.LastRunCommitMap(key) = char(string(shortCommit)); + applyStoredRunState(); + return + end + + if ~isempty(app.ActiveProfileRowIndices) + for rowIdx = app.ActiveProfileRowIndices(:)' + key = char(app.Inventory.TestFile(rowIdx)); + if isempty(key) + continue + end app.LastRunDateMap(key) = char(string(runDate)); app.LastRunCommitMap(key) = char(string(shortCommit)); end @@ -830,7 +842,7 @@ function out = stringOrEmpty(structValue, fieldName) end end -function rows = inventoryRowStates(inventory, lastRunDate, lastRunCommit) +function rows = inventoryRowStates(inventory) rows = repmat(struct( ... 'test_file', '', ... 'target', '', ... @@ -846,8 +858,8 @@ function rows = inventoryRowStates(inventory, lastRunDate, lastRunCommit) rows(idx).scope = char(inventory.Scope(idx)); rows(idx).last_run = char(inventory.LastRun(idx)); rows(idx).result_summary = char(inventory.ResultSummary(idx)); - rows(idx).last_run_date = char(string(lastRunDate)); - rows(idx).last_run_commit = char(string(lastRunCommit)); + rows(idx).last_run_date = char(inventory.LastRunDate(idx)); + rows(idx).last_run_commit = char(inventory.LastRunCommit(idx)); end end