Skip to content

Instantly share code, notes, and snippets.

@juliandescottes
Last active March 3, 2023 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliandescottes/69c92da088622e2742e51831a5eefe53 to your computer and use it in GitHub Desktop.
Save juliandescottes/69c92da088622e2742e51831a5eefe53 to your computer and use it in GitHub Desktop.
// 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