pass extra metadata (repo refs, timestamps) to test results

This commit is contained in:
Ivan Avdeev
2026-04-09 15:24:54 -04:00
parent c6edc9f3fe
commit 75fa9cae18
5 changed files with 127 additions and 47 deletions
+40 -32
View File
@@ -114,7 +114,7 @@ function isPassed(value) {
];
}
function makeTable(fields, data, attrs_func) {
function makeTable(fields, tests, attrs_func) {
const table = Tag('table', null, null, [
Tag('tr', null, null, (() => {
let tds = [];
@@ -126,8 +126,8 @@ function makeTable(fields, data, attrs_func) {
]);
for (const di in data) {
let d = data[di];
for (const di in tests) {
let d = tests[di];
const attrs = attrs_func ? attrs_func(d) : null;
table.appendChild(Tag('tr', attrs, null, (() => {
let ret = [];
@@ -159,7 +159,7 @@ function makeTable(fields, data, attrs_func) {
return table;
}
function buildTestResultsTable(data) {
function buildTestResultsTable(tests) {
const fields = [
{label: 'Test', field: 'test', tags_func: sectionLink},
{label: 'Channel', field: 'channel', tags_func: channelWithEmoji},
@@ -167,27 +167,37 @@ function buildTestResultsTable(data) {
{label: 'Passed', field: 'fail', tags_func: isPassed},
];
return [makeTable(fields, data, rowAttribs)];
return [makeTable(fields, tests, rowAttribs)];
}
// Filter out all success
function filterData(data) {
return data
.filter((d) => { return d.diff_pct !== 0; })
.sort((l, r) => {
return l.diff_pct < r.diff_pct ? 1 : -1; // RTFM
});
function filterTests(tests) {
return tests
.filter((t) => { return t.diff_pct !== 0; })
.sort((l, r) => {
return l.diff_pct < r.diff_pct ? 1 : -1; // RTFM
});
}
function buildSummary(data) {
const total = data.length;
const fails = data.filter((d) => { return !!d.fail; }).length;
function buildSummary(test_results) {
const tests = test_results.tests
const total = tests.length;
const fails = tests.filter((d) => { return !!d.fail; }).length;
const fails_pct = fails * 100.0 / total;
return emojiToTag(`🧪 Tests 💥: ${fails}/${total}🏁 (⚠${fails_pct.toFixed(3)}%)`);
const meta = test_results.metadata;
return [
Tag('ul', null, null, [
Tag('li', null, `Test date: ${meta.time}`),
// TODO add links to repos at specified revisions
Tag('li', null, `Xash3D-FWGS revision: ${meta.revisions.xash3d}`),
Tag('li', null, `Half-Life-PBR revision: ${meta.revisions.pbr}`),
Tag('li', null, `HLRTest revision: ${meta.revisions.tests}`),
Tag('li', null, `Rendering took: ${meta.phase_render_time_sec.toFixed(1)} seconds`)
])].concat(emojiToTag(`🧪 Tests 💥: ${fails}/${total}🏁 (⚠${fails_pct.toFixed(3)}%)`));
}
function buildTestResultImages(data) {
return data.flatMap((d) => {
function buildTestResultImages(tests) {
return tests.flatMap((d) => {
//return Tag('details', {id: makeId(d)}, null, [
return Tag('div', {id: makeId(d), "class": "meta-block"}, null, [
//Tag('summary', null, `${d.test}/${d.channel} δ=${d.diff_pct}`),
@@ -207,10 +217,8 @@ function buildTestResultImages(data) {
function buildData(table, images, data, sort, filter, exact_match) {
if (sort) {
data = filterData(data);
}
function buildData(table, images, test_results, sort, filter, exact_match) {
let tests = sort ? filterTests(test_results.tests) : test_results.tests
if (filter) {
let test = "", channel = "";
const args = filter.split(" ");
@@ -221,7 +229,7 @@ function buildData(table, images, data, sort, filter, exact_match) {
test = filter;
channel = filter;
}
data = data.filter((d) => {
tests = tests.filter((d) => {
const test_result = exact_match ? d.test === test : d.test.includes(test);
const channel_result = exact_match ? d.channel === channel : d.channel.includes(channel);
if (args.length > 1) {
@@ -232,8 +240,8 @@ function buildData(table, images, data, sort, filter, exact_match) {
});
}
table.replaceChildren(...buildTestResultsTable(data));
images.replaceChildren(...buildTestResultImages(data));
table.replaceChildren(...buildTestResultsTable(tests));
images.replaceChildren(...buildTestResultImages(tests));
for (let block of images.querySelectorAll(".image-container")) {
block.addEventListener("click", function() {
@@ -255,8 +263,8 @@ function buildData(table, images, data, sort, filter, exact_match) {
saveToLocalStorage("rendertest_tablesort", sort);
}
const buildDataSlowMode = debounce((table, images, data, sort, filter, exact_match) => {
buildData(table, images, data, sort, filter, exact_match);
const buildDataSlowMode = debounce((table, images, test_results, sort, filter, exact_match) => {
buildData(table, images, test_results, sort, filter, exact_match);
}, ()=>{}, 250);
@@ -550,7 +558,7 @@ window.onload = () => {
]),
Tag("label", null, null, [
Tag("input", {"type": "radio", "name": "sort_table", "value": "yes", ...uglyChecked(tableSort)}, null, null, "input", (e) => {
buildData(table, images, data, true, filter.value, exactmatch_input.checked);
buildData(table, images, TEST_RESULTS, true, filter.value, exactmatch_input.checked);
// TODO: rewrite use reactive programming
tableSort = true;
}),
@@ -558,7 +566,7 @@ window.onload = () => {
]),
Tag("label", null, null, [
Tag("input", {"type": "radio", "name": "sort_table", "value": "no", ...uglyChecked(!tableSort)}, null, null, "input", (e) => {
buildData(table, images, data, false, filter.value, exactmatch_input.checked);
buildData(table, images, TEST_RESULTS, false, filter.value, exactmatch_input.checked);
tableSort = false;
}),
Text(" no")
@@ -570,12 +578,12 @@ window.onload = () => {
Tag("label", {"class": "filter sticky"}, "Filter", [
filter = Tag("input", {"type": "input", "title": "Hotkey: ALT+F", "name": "filter", "value": filter_value}, null, null, "input", (e) => {
saveToLocalStorage("rendertest_filter", e.target.value);
buildDataSlowMode(table, images, data, tableSort, e.target.value, exactmatch_input.checked);
buildDataSlowMode(table, images, TEST_RESULTS, tableSort, e.target.value, exactmatch_input.checked);
}),
Tag("label", null, null, [
exactmatch_input = Tag("input", {"type": "checkbox", "name": "exactmatch", ...uglyChecked(exactMatch)}, null, null, "change", (e) => {
saveToLocalStorage("rendertest_exactmatch", e.target.checked);
buildDataSlowMode(table, images, data, tableSort, filter.value, exactmatch_input.checked);
buildDataSlowMode(table, images, TEST_RESULTS, tableSort, filter.value, exactmatch_input.checked);
}),
Text("exact match")
])
@@ -586,7 +594,7 @@ window.onload = () => {
Tag("div", {"class": "content"}, null, [
Tag("h1", null, "Rendertest report"),
Tag("h2", null, "Summary"),
Tag("div", {"id": "summary"}, null, [...buildSummary(data)]),
Tag("div", {"id": "summary"}, null, buildSummary(TEST_RESULTS)),
Tag("h2", null, "Images of things that are not perfect ", [
Tag("span", {"class": "emoji"}, "⤵")
]),
@@ -595,7 +603,7 @@ window.onload = () => {
])
document.body.appendChild(gridContainer);
buildData(table, images, data, tableSort, filter_value, exactmatch_input.checked);
buildData(table, images, TEST_RESULTS, tableSort, filter_value, exactmatch_input.checked);
// TODO: remove this
if (sidebarPos === "right") {