56 lines
2.0 KiB
HTML
56 lines
2.0 KiB
HTML
<html>
|
|
<head>
|
|
<title>Test Time Sort</title>
|
|
<style>textarea {width: 100%;height: 240px};</style>
|
|
<script>
|
|
window.onload = init;
|
|
function init() {
|
|
document.getElementById("input").addEventListener("change", processTestResults);
|
|
}
|
|
function processTestResults(e) {
|
|
const txt = e.target.value;
|
|
const output = getTestTimes(txt);
|
|
|
|
let html = '';
|
|
html+= getHtmlStats(output);
|
|
html+= getHtmlTestTimes(output);
|
|
document.getElementById("output").innerHTML = html;
|
|
}
|
|
|
|
function getTestTimes(txt) {
|
|
const regex1 = /Passed (?<testName>(.)+) \[(?<testTime>(\d)+) (?<testTimeUnit>(m?s))\]/g;
|
|
txt.match(regex1);
|
|
|
|
let matches, output = [];
|
|
while (matches = regex1.exec(txt)) {
|
|
output.push([matches.groups.testName, +matches.groups.testTime, matches.groups.testTimeUnit]);
|
|
}
|
|
|
|
output.sort( (a,b)=>(b[1]*(b[2]=='s'?1000:1)-a[1]*(a[2]=='s'?1000:1)) );
|
|
return output;
|
|
}
|
|
|
|
function getHtmlStats(tests) {
|
|
let stats = '<table><tbody>';
|
|
stats += `<tr><td>Total Tests</td><td>${tests.length}</td></tr>`;
|
|
stats += '</table>';
|
|
return stats;
|
|
}
|
|
|
|
function getHtmlTestTimes(tests) {
|
|
let trs = '';
|
|
for(let i=0;i<tests.length;i++)
|
|
{
|
|
trs += `<tr><td>${tests[i][0]}</td><td>${tests[i][1]} ${tests[i][2]}</td></tr>`;
|
|
}
|
|
return '<table><thead><tr><th>Test Name</th><th>Time</th><tbody>'+trs+'</table>';
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<h1>Test Time Sort</h1>
|
|
<p>Paste here the "Test Assemblies" result to sort the test by time</p>
|
|
<textarea id="input"></textarea>
|
|
<div id="output"></div>
|
|
</body>
|
|
</html> |