Fix dashboard run metadata tracking per test
This commit is contained in:
@@ -16,6 +16,7 @@ function app = test_dashboard(options)
|
|||||||
app = struct();
|
app = struct();
|
||||||
app.Inventory = table();
|
app.Inventory = table();
|
||||||
app.SelectedRow = [];
|
app.SelectedRow = [];
|
||||||
|
app.ActiveProfileRowIndices = [];
|
||||||
app.LastRunStatusMap = containers.Map('KeyType', 'char', 'ValueType', 'char');
|
app.LastRunStatusMap = containers.Map('KeyType', 'char', 'ValueType', 'char');
|
||||||
app.LastRunSummaryMap = containers.Map('KeyType', 'char', 'ValueType', 'char');
|
app.LastRunSummaryMap = containers.Map('KeyType', 'char', 'ValueType', 'char');
|
||||||
app.LastRunDateMap = 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)
|
function runProfile(profile)
|
||||||
titleText = sprintf("Running profile '%s'", profile);
|
titleText = sprintf("Running profile '%s'", profile);
|
||||||
rowIndices = profileRowIndices(profile);
|
rowIndices = profileRowIndices(profile);
|
||||||
|
app.ActiveProfileRowIndices = rowIndices;
|
||||||
markRowsAsRunning(rowIndices);
|
markRowsAsRunning(rowIndices);
|
||||||
runWithProgress(titleText, @() runProfileInternal(profile, rowIndices), table());
|
runWithProgress(titleText, @() runProfileInternal(profile, rowIndices), table());
|
||||||
|
app.ActiveProfileRowIndices = [];
|
||||||
end
|
end
|
||||||
|
|
||||||
function generateMissingTests(~, ~)
|
function generateMissingTests(~, ~)
|
||||||
@@ -320,7 +323,7 @@ function app = test_dashboard(options)
|
|||||||
appendLog(sprintf("[%s] %s", stamp(), titleText));
|
appendLog(sprintf("[%s] %s", stamp(), titleText));
|
||||||
appendLog(output);
|
appendLog(output);
|
||||||
updateRunStateFromResults(results, record);
|
updateRunStateFromResults(results, record);
|
||||||
writeRunArtifacts(titleText, results);
|
writeRunArtifacts(titleText, results, record);
|
||||||
catch err
|
catch err
|
||||||
appendLog(sprintf("[%s] %s failed.", stamp(), titleText));
|
appendLog(sprintf("[%s] %s failed.", stamp(), titleText));
|
||||||
appendLog(getReport(err, "extended", "hyperlinks", "off"));
|
appendLog(getReport(err, "extended", "hyperlinks", "off"));
|
||||||
@@ -530,15 +533,18 @@ function app = test_dashboard(options)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function writeRunArtifacts(runLabel, results)
|
function writeRunArtifacts(runLabel, results, record)
|
||||||
if ~isfolder(reportsRoot)
|
if ~isfolder(reportsRoot)
|
||||||
mkdir(reportsRoot);
|
mkdir(reportsRoot);
|
||||||
end
|
end
|
||||||
|
|
||||||
gitInfo = collectGitMetadata(repoRoot);
|
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 = struct();
|
||||||
report.timestamp = char(datetime("now", "TimeZone", "local", "Format", "yyyy-MM-dd'T'HH:mm:ssXXX"));
|
report.timestamp = runTimestamp;
|
||||||
rowStates = inventoryRowStates(app.Inventory, report.timestamp, gitInfo.short_commit);
|
rowStates = inventoryRowStates(app.Inventory);
|
||||||
report.run_label = char(runLabel);
|
report.run_label = char(runLabel);
|
||||||
report.repo_root = repoRoot;
|
report.repo_root = repoRoot;
|
||||||
report.git = gitInfo;
|
report.git = gitInfo;
|
||||||
@@ -555,18 +561,24 @@ function app = test_dashboard(options)
|
|||||||
reportFile = fullfile(reportsRoot, sprintf('%s_%s.json', ...
|
reportFile = fullfile(reportsRoot, sprintf('%s_%s.json', ...
|
||||||
datestr(now, 'yyyy-mm-dd_HHMMSS'), sanitizeFileLabel(runLabel)));
|
datestr(now, 'yyyy-mm-dd_HHMMSS'), sanitizeFileLabel(runLabel)));
|
||||||
writeTextFile(reportFile, jsonText);
|
writeTextFile(reportFile, jsonText);
|
||||||
|
|
||||||
updateMetadataMaps(report.timestamp, gitInfo.short_commit);
|
|
||||||
appendLog(sprintf("[%s] Saved run report: %s", stamp(), reportFile));
|
appendLog(sprintf("[%s] Saved run report: %s", stamp(), reportFile));
|
||||||
end
|
end
|
||||||
|
|
||||||
function updateMetadataMaps(runDate, shortCommit)
|
function updateMetadataMaps(results, record, runDate, shortCommit)
|
||||||
for idx = 1:height(app.Inventory)
|
if ~isempty(record) && strlength(record.TestFile) > 0
|
||||||
key = char(app.Inventory.TestFile(idx));
|
key = char(record.TestFile);
|
||||||
if isempty(key)
|
app.LastRunDateMap(key) = char(string(runDate));
|
||||||
continue
|
app.LastRunCommitMap(key) = char(string(shortCommit));
|
||||||
end
|
applyStoredRunState();
|
||||||
if isKey(app.LastRunStatusMap, key)
|
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.LastRunDateMap(key) = char(string(runDate));
|
||||||
app.LastRunCommitMap(key) = char(string(shortCommit));
|
app.LastRunCommitMap(key) = char(string(shortCommit));
|
||||||
end
|
end
|
||||||
@@ -830,7 +842,7 @@ function out = stringOrEmpty(structValue, fieldName)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function rows = inventoryRowStates(inventory, lastRunDate, lastRunCommit)
|
function rows = inventoryRowStates(inventory)
|
||||||
rows = repmat(struct( ...
|
rows = repmat(struct( ...
|
||||||
'test_file', '', ...
|
'test_file', '', ...
|
||||||
'target', '', ...
|
'target', '', ...
|
||||||
@@ -846,8 +858,8 @@ function rows = inventoryRowStates(inventory, lastRunDate, lastRunCommit)
|
|||||||
rows(idx).scope = char(inventory.Scope(idx));
|
rows(idx).scope = char(inventory.Scope(idx));
|
||||||
rows(idx).last_run = char(inventory.LastRun(idx));
|
rows(idx).last_run = char(inventory.LastRun(idx));
|
||||||
rows(idx).result_summary = char(inventory.ResultSummary(idx));
|
rows(idx).result_summary = char(inventory.ResultSummary(idx));
|
||||||
rows(idx).last_run_date = char(string(lastRunDate));
|
rows(idx).last_run_date = char(inventory.LastRunDate(idx));
|
||||||
rows(idx).last_run_commit = char(string(lastRunCommit));
|
rows(idx).last_run_commit = char(inventory.LastRunCommit(idx));
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user