Skip to content

Commit

Permalink
Add some progress
Browse files Browse the repository at this point in the history
This is a first attempt at providing some progress, at least something
that shows that things are running. Often I click play and I can't
tell.
  • Loading branch information
greggman committed Dec 28, 2022
1 parent 62dbcc5 commit 030f44d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/common/runtime/standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ const worker = optionEnabled('worker') ? new TestWorker(debug) : undefined;

const autoCloseOnPass = document.getElementById('autoCloseOnPass') as HTMLInputElement;
const resultsVis = document.getElementById('resultsVis')!;
const progressElem = document.getElementById('progress')!;
const progressTestNameElem = progressElem.querySelector('.progress-test-name')!;
const stopButtonElem = progressElem.querySelector('button')!;
let runDepth = 0;
let stopRequested = false;

stopButtonElem.addEventListener('click', () => {
stopRequested = true;
});

dataCache.setStore({
load: async (path: string) => {
Expand Down Expand Up @@ -119,6 +128,7 @@ function makeCaseHTML(t: TestTreeLeaf): VisualizedSubtree {
if (clearRenderedResult) clearRenderedResult();

const result: SubtreeResult = emptySubtreeResult();
progressTestNameElem.textContent = name;

haveSomeResults = true;
const [rec, res] = logger.record(name);
Expand Down Expand Up @@ -212,9 +222,28 @@ function makeSubtreeHTML(n: TestSubtree, parentLevel: TestQueryLevel): Visualize
);

const runMySubtree = async () => {
if (runDepth === 0) {
stopRequested = false;
progressElem.style.display = '';
}
if (stopRequested) {
const result = emptySubtreeResult();
result.skip = 1;
result.total = 1;
return result;
}

++runDepth;

if (clearRenderedResult) clearRenderedResult();
subtreeResult = await runSubtree();
if (updateRenderedResult) updateRenderedResult();

--runDepth;
if (runDepth === 0) {
progressElem.style.display = 'none';
}

return subtreeResult;
};

Expand Down
19 changes: 19 additions & 0 deletions standalone/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@
#info {
font-family: monospace;
}
#progress {
position: fixed;
display: flex;
width: 100%;
left: 0;
top: 0;
background-color: #000;
color: #fff;
align-items: center;
}
#progress .progress-test-name {
flex: 1 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
direction: rtl;
white-space: nowrap;
}
#resultsJSON {
font-family: monospace;
width: 100%;
Expand Down Expand Up @@ -356,6 +374,7 @@ <h1><img class="logo" src="webgpu-logo-notext.svg">WebGPU Conformance Test Suite

<div id="info"></div>
<div id="resultsVis"></div>
<div id="progress" style="display: none;"><button type="button">stop</button><div class="progress-test-name"></div></div>

<p>
<input type="button" id="copyResultsJSON" value="Copy results as JSON">
Expand Down

0 comments on commit 030f44d

Please sign in to comment.