Boyum.Portal.Tools/TestTimeSort.html
2022-07-26 13:55:56 +02:00

37 lines
1.4 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 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)) );
let trs = '';
for(let i=0;i<output.length;i++)
{
trs += `<tr><td>${output[i][0]}</td><td>${output[i][1]} ${output[i][2]}</td>`;
}
document.getElementById("output").innerHTML = '<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>