Save failed results only (#4457)
* Save failed results only * add types to predicate * Make input element also typed * linter changes * typed predicate * Minor change in html style --------- Co-authored-by: Peter McNeeley <petermcneeley@google.com>
This commit is contained in:
parent
0e795dd1e5
commit
35ecea5948
3 changed files with 35 additions and 11 deletions
|
|
@ -23,7 +23,18 @@ export class Logger {
|
|||
];
|
||||
}
|
||||
|
||||
asJSON(space?: number): string {
|
||||
return JSON.stringify({ version, results: Array.from(this.results) }, undefined, space);
|
||||
asJSON(space?: number, predFunc?: (key: string, value: LiveTestCaseResult) => boolean): string {
|
||||
return JSON.stringify(
|
||||
{
|
||||
version,
|
||||
results: Array.from(
|
||||
new Map(
|
||||
[...this.results].filter(([key, value]) => (predFunc ? predFunc(key, value) : true))
|
||||
)
|
||||
),
|
||||
},
|
||||
undefined,
|
||||
space
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -697,12 +697,20 @@ void (async () => {
|
|||
setTreeCheckedRecursively();
|
||||
});
|
||||
|
||||
function getResultsText() {
|
||||
const saveOptionElement = document.getElementById('saveOnlyFailures') as HTMLInputElement;
|
||||
const onlyFailures = saveOptionElement.checked;
|
||||
const predFunc = (key: string, value: LiveTestCaseResult) =>
|
||||
value.status === 'fail' || !onlyFailures;
|
||||
return logger.asJSON(2, predFunc);
|
||||
}
|
||||
|
||||
document.getElementById('copyResultsJSON')!.addEventListener('click', () => {
|
||||
void navigator.clipboard.writeText(logger.asJSON(2));
|
||||
void navigator.clipboard.writeText(getResultsText());
|
||||
});
|
||||
|
||||
document.getElementById('saveResultsJSON')!.addEventListener('click', () => {
|
||||
const text = logger.asJSON(2);
|
||||
const text = getResultsText();
|
||||
const blob = new Blob([text], { type: 'text/plain' });
|
||||
const link = document.createElement('a');
|
||||
link.download = 'results-webgpu-cts.json';
|
||||
|
|
|
|||
|
|
@ -446,13 +446,18 @@
|
|||
<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">
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input type="button" id="saveResultsJSON" value="Save results to JSON file">
|
||||
</p>
|
||||
<fieldset>
|
||||
<legend>Serialize results:</legend>
|
||||
<p>
|
||||
<label><input type="checkbox" id="saveOnlyFailures">Only result failures</label>
|
||||
</p>
|
||||
<p>
|
||||
<input type="button" id="copyResultsJSON" value="Copy results as JSON">
|
||||
</p>
|
||||
<p>
|
||||
<input type="button" id="saveResultsJSON" value="Save results to JSON file">
|
||||
</p>
|
||||
</fieldset>
|
||||
|
||||
<script type="module" src="../out/common/runtime/standalone.js"></script>
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Reference in a new issue