Last active
May 14, 2024 11:00
-
-
Save juliandescottes/69c92da088622e2742e51831a5eefe53 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Here goes the list of tests from the manifest, with the skip-if etc... | |
const tests = ``; | |
// JS and python don't follow the same alphabetical order for special characters | |
// the safest is to take the output from the linter and add it here. | |
const expectedOrder = ``.split("\n"); | |
const sortTests = str => { | |
const lines = str.split("\n"); | |
const tests = []; | |
for (const line of lines) { | |
if (line.startsWith("[")) { | |
tests.push({ | |
name: line.substring(1, line.length - 1), | |
lines: [], | |
}); | |
} | |
tests.at(-1).lines.push(line); | |
} | |
const sortedTests = tests.sort( | |
(testA, testB) => | |
expectedOrder.indexOf(testA.name) - expectedOrder.indexOf(testB.name) | |
); | |
return sortedTests | |
.map(test => test.lines) | |
.flat() | |
.join("\n"); | |
}; | |
console.log(sortTests(tests)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment