Fix dashboard run metadata tracking per test

This commit is contained in:
Silas Oettinghaus
2026-03-25 09:38:48 +01:00
parent 69578b3c43
commit b291e0a7bb

View File

@@ -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));
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
if isKey(app.LastRunStatusMap, key)
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