From cf3db0c2ed71136952cbfa0ddb05219b41094840 Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 11 Mar 2026 14:41:28 -0300 Subject: [PATCH 1/9] moving test second format into it's own file --- tests/config/run-test.js | 21 ++------------------- tests/config/test-second-format.js | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 tests/config/test-second-format.js diff --git a/tests/config/run-test.js b/tests/config/run-test.js index 8896019ed..1ed015445 100644 --- a/tests/config/run-test.js +++ b/tests/config/run-test.js @@ -6,6 +6,7 @@ import { format, parse } from "./run-prettier.js"; import consistentEndOfLine from "./utils/consistent-end-of-line.js"; import createSnapshot from "./utils/create-snapshot.js"; import visualizeEndOfLine from "./utils/visualize-end-of-line.js"; +import * as testSecondFormat from "./test-second-format.js"; import { shouldThrowOnFormat } from "./utilities.js"; import getPrettier from "./get-prettier.js"; import getCreateParser from "./get-create-parser.js"; @@ -125,25 +126,7 @@ async function runTest({ } } - const isUnstableTest = failedTests.isUnstable(filename, formatOptions); - if ( - (formatResult.changed || isUnstableTest) && - // No range and cursor - formatResult.input === code - ) { - const { eolVisualizedOutput: firstOutput, output } = formatResult; - const { eolVisualizedOutput: secondOutput } = await format( - output, - formatOptions, - ); - if (isUnstableTest) { - // To keep eye on failed tests, this assert never supposed to pass, - // if it fails, just remove the file from `unstableTests` - expect(secondOutput).not.toEqual(firstOutput); - } else { - expect(secondOutput).toEqual(firstOutput); - } - } + testSecondFormat.run(code, formatResult, filename, formatOptions); const isAstUnstableTest = failedTests.isAstUnstable(filename, formatOptions); // Some parsers skip parsing empty files diff --git a/tests/config/test-second-format.js b/tests/config/test-second-format.js new file mode 100644 index 000000000..fd6e0df9b --- /dev/null +++ b/tests/config/test-second-format.js @@ -0,0 +1,27 @@ +import * as failedTests from "./failed-format-tests.js"; +import { format } from "./run-prettier.js"; + +async function testSecondFormat(source, formatResult, filename, formatOptions) { + const isUnstableTest = failedTests.isUnstable(filename, formatOptions); + if ( + (formatResult.changed || isUnstableTest) && + // No range and cursor + formatResult.input === source + ) { + const { eolVisualizedOutput: firstOutput, output } = formatResult; + const { eolVisualizedOutput: secondOutput } = await format( + output, + formatOptions, + ); + // To keep eye on failed tests, this assert never supposed to pass, + // if it fails, just remove the file from `unstableTests` + if (isUnstableTest) { + expect(secondOutput).not.toEqual(firstOutput); + return; + } + + expect(secondOutput).toEqual(firstOutput); + } +} + +export { testSecondFormat as run }; From bbdd72daa6e7dcb4b4c774ef0e43d05fb58ac30e Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 11 Mar 2026 15:35:06 -0300 Subject: [PATCH 2/9] moving test ast compare into it's own file --- tests/config/run-test.js | 19 ++++--------------- tests/config/test-ast-compare.js | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 tests/config/test-ast-compare.js diff --git a/tests/config/run-test.js b/tests/config/run-test.js index 1ed015445..6c410534f 100644 --- a/tests/config/run-test.js +++ b/tests/config/run-test.js @@ -2,10 +2,11 @@ import path from "node:path"; import createEsmUtils from "esm-utils"; import { BOM, FULL_TEST } from "./constants.js"; import * as failedTests from "./failed-format-tests.js"; -import { format, parse } from "./run-prettier.js"; +import { format } from "./run-prettier.js"; import consistentEndOfLine from "./utils/consistent-end-of-line.js"; import createSnapshot from "./utils/create-snapshot.js"; import visualizeEndOfLine from "./utils/visualize-end-of-line.js"; +import * as testAstCompare from "./test-ast-compare.js"; import * as testSecondFormat from "./test-second-format.js"; import { shouldThrowOnFormat } from "./utilities.js"; import getPrettier from "./get-prettier.js"; @@ -126,20 +127,8 @@ async function runTest({ } } - testSecondFormat.run(code, formatResult, filename, formatOptions); - - const isAstUnstableTest = failedTests.isAstUnstable(filename, formatOptions); - // Some parsers skip parsing empty files - if (formatResult.changed && code.trim()) { - const { input, output } = formatResult; - const originalAst = await parse(input, formatOptions); - const formattedAst = await parse(output, formatOptions); - if (isAstUnstableTest) { - expect(formattedAst).not.toEqual(originalAst); - } else { - expect(formattedAst).toEqual(originalAst); - } - } + await testSecondFormat.run(code, formatResult, filename, formatOptions); + await testAstCompare.run(code, formatResult, filename, formatOptions); if (!shouldSkipEolTest(code, formatResult.options)) { for (const eol of ["\r\n", "\r"]) { diff --git a/tests/config/test-ast-compare.js b/tests/config/test-ast-compare.js new file mode 100644 index 000000000..c82d27b13 --- /dev/null +++ b/tests/config/test-ast-compare.js @@ -0,0 +1,21 @@ +import * as failedTests from "./failed-format-tests.js"; +import { parse } from "./run-prettier.js"; + +async function testAstCompare(source, formatResult, filename, formatOptions) { + const isAstUnstableTest = failedTests.isAstUnstable(filename, formatOptions); + // Some parsers skip parsing empty files + if (formatResult.changed && source.trim()) { + const [originalAst, formattedAst] = await Promise.all( + [formatResult.input, formatResult.output].map((code) => + parse(code, formatResult.options), + ), + ); + if (isAstUnstableTest) { + expect(formattedAst).not.toEqual(originalAst); + } else { + expect(formattedAst).toEqual(originalAst); + } + } +} + +export { testAstCompare as run }; From aa2e15e3ea72746b4a7898b05495e0fda588e778 Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 11 Mar 2026 15:52:21 -0300 Subject: [PATCH 3/9] moving test end of line to its own file --- tests/config/run-test.js | 40 ++------------------------- tests/config/test-end-of-line.js | 47 ++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 37 deletions(-) create mode 100644 tests/config/test-end-of-line.js diff --git a/tests/config/run-test.js b/tests/config/run-test.js index 6c410534f..190bacb30 100644 --- a/tests/config/run-test.js +++ b/tests/config/run-test.js @@ -7,6 +7,7 @@ import consistentEndOfLine from "./utils/consistent-end-of-line.js"; import createSnapshot from "./utils/create-snapshot.js"; import visualizeEndOfLine from "./utils/visualize-end-of-line.js"; import * as testAstCompare from "./test-ast-compare.js"; +import * as testEndOfLine from "./test-end-of-line.js"; import * as testSecondFormat from "./test-second-format.js"; import { shouldThrowOnFormat } from "./utilities.js"; import getPrettier from "./get-prettier.js"; @@ -129,24 +130,8 @@ async function runTest({ await testSecondFormat.run(code, formatResult, filename, formatOptions); await testAstCompare.run(code, formatResult, filename, formatOptions); - - if (!shouldSkipEolTest(code, formatResult.options)) { - for (const eol of ["\r\n", "\r"]) { - const { eolVisualizedOutput: output } = await format( - code.replace(/\n/gu, eol), - formatOptions, - ); - // Only if `endOfLine: "auto"` the result will be different - const expected = - formatOptions.endOfLine === "auto" - ? visualizeEndOfLine( - // All `code` use `LF`, so the `eol` of result is always `LF` - formatResult.outputWithCursor.replace(/\n/gu, eol), - ) - : formatResult.eolVisualizedOutput; - expect(output).toEqual(expected); - } - } + await testEndOfLine.run(code, formatResult, filename, formatOptions, "\r\n"); + await testEndOfLine.run(code, formatResult, filename, formatOptions, "\r"); if (code.charAt(0) !== BOM) { const { eolVisualizedOutput: output } = await format( @@ -164,23 +149,4 @@ async function runTest({ } } -function shouldSkipEolTest(code, options) { - if (code.includes("\r")) { - return true; - } - const { requirePragma, rangeStart, rangeEnd } = options; - if (requirePragma) { - return true; - } - - if ( - typeof rangeStart === "number" && - typeof rangeEnd === "number" && - rangeStart >= rangeEnd - ) { - return true; - } - return false; -} - export { runTest }; diff --git a/tests/config/test-end-of-line.js b/tests/config/test-end-of-line.js new file mode 100644 index 000000000..ae3cb165a --- /dev/null +++ b/tests/config/test-end-of-line.js @@ -0,0 +1,47 @@ +import { format } from "./run-prettier.js"; +import visualizeEndOfLine from "./utils/visualize-end-of-line.js"; + +async function testEndOfLine( + source, + formatResult, + _filename, + formatOptions, + eol, +) { + if (!shouldSkipEolTest(source, formatResult.options)) { + const { eolVisualizedOutput: output } = await format( + source.replace(/\n/gu, eol), + formatOptions, + ); + // Only if `endOfLine: "auto"` the result will be different + const expected = + formatOptions.endOfLine === "auto" + ? visualizeEndOfLine( + // All `code` use `LF`, so the `eol` of result is always `LF` + formatResult.outputWithCursor.replace(/\n/gu, eol), + ) + : formatResult.eolVisualizedOutput; + expect(output).toEqual(expected); + } +} + +function shouldSkipEolTest(source, options) { + if (source.includes("\r")) { + return true; + } + const { requirePragma, rangeStart, rangeEnd } = options; + if (requirePragma) { + return true; + } + + if ( + typeof rangeStart === "number" && + typeof rangeEnd === "number" && + rangeStart >= rangeEnd + ) { + return true; + } + return false; +} + +export { testEndOfLine as run }; From d6cddb8afa45650518f12f4a2e06f219fa2b89cd Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 11 Mar 2026 16:00:54 -0300 Subject: [PATCH 4/9] moving test BOM to its own file --- tests/config/run-test.js | 13 +++---------- tests/config/test-bom.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 tests/config/test-bom.js diff --git a/tests/config/run-test.js b/tests/config/run-test.js index 190bacb30..1341b6ce9 100644 --- a/tests/config/run-test.js +++ b/tests/config/run-test.js @@ -1,12 +1,13 @@ import path from "node:path"; import createEsmUtils from "esm-utils"; -import { BOM, FULL_TEST } from "./constants.js"; +import { FULL_TEST } from "./constants.js"; import * as failedTests from "./failed-format-tests.js"; import { format } from "./run-prettier.js"; import consistentEndOfLine from "./utils/consistent-end-of-line.js"; import createSnapshot from "./utils/create-snapshot.js"; import visualizeEndOfLine from "./utils/visualize-end-of-line.js"; import * as testAstCompare from "./test-ast-compare.js"; +import * as testBom from "./test-bom.js"; import * as testEndOfLine from "./test-end-of-line.js"; import * as testSecondFormat from "./test-second-format.js"; import { shouldThrowOnFormat } from "./utilities.js"; @@ -132,15 +133,7 @@ async function runTest({ await testAstCompare.run(code, formatResult, filename, formatOptions); await testEndOfLine.run(code, formatResult, filename, formatOptions, "\r\n"); await testEndOfLine.run(code, formatResult, filename, formatOptions, "\r"); - - if (code.charAt(0) !== BOM) { - const { eolVisualizedOutput: output } = await format( - BOM + code, - formatOptions, - ); - const expected = BOM + formatResult.eolVisualizedOutput; - expect(output).toEqual(expected); - } + await testBom.run(code, formatResult, filename, formatOptions); if (shouldCompareBytecode(filename, formatOptions)) { const output = compileContract(filename, formatResult.output); diff --git a/tests/config/test-bom.js b/tests/config/test-bom.js new file mode 100644 index 000000000..7c8f1ec2a --- /dev/null +++ b/tests/config/test-bom.js @@ -0,0 +1,15 @@ +import { BOM } from "./constants.js"; +import { format } from "./run-prettier.js"; + +async function testBom(source, formatResult, _filename, formatOptions) { + if (source.charAt(0) !== BOM) { + const { eolVisualizedOutput: output } = await format( + BOM + source, + formatOptions, + ); + const expected = BOM + formatResult.eolVisualizedOutput; + expect(output).toEqual(expected); + } +} + +export { testBom as run }; From 9f62fd5f19d6c0bbc5e7e2cc92945e0c8270faea Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 11 Mar 2026 16:11:17 -0300 Subject: [PATCH 5/9] moving text bytecode compare to its own file --- tests/config/run-test.js | 47 +---------------------- tests/config/test-bytecode-compare.js | 54 +++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 45 deletions(-) create mode 100644 tests/config/test-bytecode-compare.js diff --git a/tests/config/run-test.js b/tests/config/run-test.js index 1341b6ce9..658c46dfa 100644 --- a/tests/config/run-test.js +++ b/tests/config/run-test.js @@ -1,5 +1,3 @@ -import path from "node:path"; -import createEsmUtils from "esm-utils"; import { FULL_TEST } from "./constants.js"; import * as failedTests from "./failed-format-tests.js"; import { format } from "./run-prettier.js"; @@ -10,48 +8,12 @@ import * as testAstCompare from "./test-ast-compare.js"; import * as testBom from "./test-bom.js"; import * as testEndOfLine from "./test-end-of-line.js"; import * as testSecondFormat from "./test-second-format.js"; +import * as testBytecodeCompare from "./test-bytecode-compare.js"; import { shouldThrowOnFormat } from "./utilities.js"; import getPrettier from "./get-prettier.js"; import getCreateParser from "./get-create-parser.js"; import getVariantCoverage from "./get-variant-coverage.js"; import getPlugins from "./get-plugins.js"; -import compileContract from "./utils/compile-contract.js"; - -const { __dirname } = createEsmUtils(import.meta); - -const testsWithAstChanges = new Map( - [ - "Parentheses/AddNoParentheses.sol", - "Parentheses/SubNoParentheses.sol", - "Parentheses/MulNoParentheses.sol", - "Parentheses/DivNoParentheses.sol", - "Parentheses/ModNoParentheses.sol", - "Parentheses/ExpNoParentheses.sol", - "Parentheses/ShiftLNoParentheses.sol", - "Parentheses/ShiftRNoParentheses.sol", - "Parentheses/BitAndNoParentheses.sol", - "Parentheses/BitOrNoParentheses.sol", - "Parentheses/BitXorNoParentheses.sol", - "Parentheses/LogicNoParentheses.sol", - "HexLiteral/HexLiteral.sol", - "ModifierInvocations/ModifierInvocations.sol", - ].map((fixture) => { - const [file, compareBytecode = () => true] = Array.isArray(fixture) - ? fixture - : [fixture]; - return [path.join(__dirname, "../format/", file), compareBytecode]; - }), -); - -const shouldCompareBytecode = (filename, options) => { - const testFunction = testsWithAstChanges.get(filename); - - if (!testFunction) { - return false; - } - - return testFunction(options); -}; async function runTest({ parsers, @@ -134,12 +96,7 @@ async function runTest({ await testEndOfLine.run(code, formatResult, filename, formatOptions, "\r\n"); await testEndOfLine.run(code, formatResult, filename, formatOptions, "\r"); await testBom.run(code, formatResult, filename, formatOptions); - - if (shouldCompareBytecode(filename, formatOptions)) { - const output = compileContract(filename, formatResult.output); - const expected = compileContract(filename, formatResult.input); - expect(output).toEqual(expected); - } + await testBytecodeCompare.run(code, formatResult, filename, formatOptions); } export { runTest }; diff --git a/tests/config/test-bytecode-compare.js b/tests/config/test-bytecode-compare.js new file mode 100644 index 000000000..cdf0b0c65 --- /dev/null +++ b/tests/config/test-bytecode-compare.js @@ -0,0 +1,54 @@ +import path from "node:path"; +import createEsmUtils from "esm-utils"; +import compileContract from "./utils/compile-contract.js"; + +async function testBytecodeCompare( + _source, + formatResult, + filename, + formatOptions, +) { + if (shouldCompareBytecode(filename, formatOptions)) { + const output = compileContract(filename, formatResult.output); + const expected = compileContract(filename, formatResult.input); + expect(output).toEqual(expected); + } +} + +const { __dirname } = createEsmUtils(import.meta); + +const testsWithAstChanges = new Map( + [ + "Parentheses/AddNoParentheses.sol", + "Parentheses/SubNoParentheses.sol", + "Parentheses/MulNoParentheses.sol", + "Parentheses/DivNoParentheses.sol", + "Parentheses/ModNoParentheses.sol", + "Parentheses/ExpNoParentheses.sol", + "Parentheses/ShiftLNoParentheses.sol", + "Parentheses/ShiftRNoParentheses.sol", + "Parentheses/BitAndNoParentheses.sol", + "Parentheses/BitOrNoParentheses.sol", + "Parentheses/BitXorNoParentheses.sol", + "Parentheses/LogicNoParentheses.sol", + "HexLiteral/HexLiteral.sol", + "ModifierInvocations/ModifierInvocations.sol", + ].map((fixture) => { + const [file, compareBytecode = () => true] = Array.isArray(fixture) + ? fixture + : [fixture]; + return [path.join(__dirname, "../format/", file), compareBytecode]; + }), +); + +const shouldCompareBytecode = (filename, options) => { + const testFunction = testsWithAstChanges.get(filename); + + if (!testFunction) { + return false; + } + + return testFunction(options); +}; + +export { testBytecodeCompare as run }; From c079ab28ea87d3288f79de19603d07c50da52434 Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 11 Mar 2026 16:17:22 -0300 Subject: [PATCH 6/9] moving test variant coverage into its own file --- tests/config/run-test.js | 9 +++------ tests/config/test-variant-coverage.js | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 tests/config/test-variant-coverage.js diff --git a/tests/config/run-test.js b/tests/config/run-test.js index 658c46dfa..c21f325ee 100644 --- a/tests/config/run-test.js +++ b/tests/config/run-test.js @@ -9,10 +9,10 @@ import * as testBom from "./test-bom.js"; import * as testEndOfLine from "./test-end-of-line.js"; import * as testSecondFormat from "./test-second-format.js"; import * as testBytecodeCompare from "./test-bytecode-compare.js"; +import * as testVariantCoverage from "./test-variant-coverage.js"; import { shouldThrowOnFormat } from "./utilities.js"; import getPrettier from "./get-prettier.js"; import getCreateParser from "./get-create-parser.js"; -import getVariantCoverage from "./get-variant-coverage.js"; import getPlugins from "./get-plugins.js"; async function runTest({ @@ -70,11 +70,7 @@ async function runTest({ if (formatOptions.parser === "slang") { const createParser = await getCreateParser(); - const variantCoverage = await getVariantCoverage(); - const { parser, parseOutput } = createParser(code, formatOptions); - - // Check coverage - variantCoverage(parseOutput.tree.asNonterminalNode()); + const { parser } = createParser(code, formatOptions); if (!failedTests.isAntlrMismatch(filename, formatOptions)) { // Compare with ANTLR's format @@ -91,6 +87,7 @@ async function runTest({ } } + await testVariantCoverage.run(code, formatResult, filename, formatOptions); await testSecondFormat.run(code, formatResult, filename, formatOptions); await testAstCompare.run(code, formatResult, filename, formatOptions); await testEndOfLine.run(code, formatResult, filename, formatOptions, "\r\n"); diff --git a/tests/config/test-variant-coverage.js b/tests/config/test-variant-coverage.js new file mode 100644 index 000000000..477626421 --- /dev/null +++ b/tests/config/test-variant-coverage.js @@ -0,0 +1,20 @@ +import getCreateParser from "./get-create-parser.js"; +import getVariantCoverage from "./get-variant-coverage.js"; + +async function testVariantCoverage( + source, + _formatResult, + _filename, + formatOptions, +) { + if (formatOptions.parser === "slang") { + const createParser = await getCreateParser(); + const variantCoverage = await getVariantCoverage(); + const { parseOutput } = createParser(source, formatOptions); + + // Check coverage + variantCoverage(parseOutput.tree.asNonterminalNode()); + } +} + +export { testVariantCoverage as run }; From 73102a36f03d9e31486cb17f86a4a544a1c9f604 Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 11 Mar 2026 16:28:30 -0300 Subject: [PATCH 7/9] moving test antlr format to its own file --- tests/config/run-test.js | 26 ++------------------------ tests/config/test-antlr-format.js | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 24 deletions(-) create mode 100644 tests/config/test-antlr-format.js diff --git a/tests/config/run-test.js b/tests/config/run-test.js index c21f325ee..ac4f602a7 100644 --- a/tests/config/run-test.js +++ b/tests/config/run-test.js @@ -1,5 +1,4 @@ import { FULL_TEST } from "./constants.js"; -import * as failedTests from "./failed-format-tests.js"; import { format } from "./run-prettier.js"; import consistentEndOfLine from "./utils/consistent-end-of-line.js"; import createSnapshot from "./utils/create-snapshot.js"; @@ -9,11 +8,9 @@ import * as testBom from "./test-bom.js"; import * as testEndOfLine from "./test-end-of-line.js"; import * as testSecondFormat from "./test-second-format.js"; import * as testBytecodeCompare from "./test-bytecode-compare.js"; +import * as testAntlrFormat from "./test-antlr-format.js"; import * as testVariantCoverage from "./test-variant-coverage.js"; import { shouldThrowOnFormat } from "./utilities.js"; -import getPrettier from "./get-prettier.js"; -import getCreateParser from "./get-create-parser.js"; -import getPlugins from "./get-plugins.js"; async function runTest({ parsers, @@ -67,26 +64,7 @@ async function runTest({ if (!FULL_TEST) { return; } - - if (formatOptions.parser === "slang") { - const createParser = await getCreateParser(); - const { parser } = createParser(code, formatOptions); - - if (!failedTests.isAntlrMismatch(filename, formatOptions)) { - // Compare with ANTLR's format - const prettier = await getPrettier(); - const { formatted: antlrOutput } = await prettier.formatWithCursor(code, { - ...formatOptions, - // Since Slang forces us to decide on a compiler version, we need to do the - // same for ANTLR unless it was already given as an option. - compiler: formatOptions.compiler || parser.languageVersion, - parser: "antlr", - plugins: await getPlugins(), - }); - expect(antlrOutput).toEqual(formatResult.output); - } - } - + await testAntlrFormat.run(code, formatResult, filename, formatOptions); await testVariantCoverage.run(code, formatResult, filename, formatOptions); await testSecondFormat.run(code, formatResult, filename, formatOptions); await testAstCompare.run(code, formatResult, filename, formatOptions); diff --git a/tests/config/test-antlr-format.js b/tests/config/test-antlr-format.js new file mode 100644 index 000000000..2d76066d2 --- /dev/null +++ b/tests/config/test-antlr-format.js @@ -0,0 +1,27 @@ +import * as failedTests from "./failed-format-tests.js"; +import getPrettier from "./get-prettier.js"; +import getCreateParser from "./get-create-parser.js"; +import getPlugins from "./get-plugins.js"; + +async function testAntlrFormat(source, formatResult, filename, formatOptions) { + if ( + formatOptions.parser === "slang" && + !failedTests.isAntlrMismatch(filename, formatOptions) + ) { + // Compare with ANTLR's format + const createParser = await getCreateParser(); + const { parser } = createParser(source, formatOptions); + const prettier = await getPrettier(); + const { formatted: antlrOutput } = await prettier.formatWithCursor(source, { + ...formatOptions, + // Since Slang forces us to decide on a compiler version, we need to do the + // same for ANTLR unless it was already given as an option. + compiler: formatOptions.compiler || parser.languageVersion, + parser: "antlr", + plugins: await getPlugins(), + }); + expect(antlrOutput).toEqual(formatResult.output); + } +} + +export { testAntlrFormat as run }; From e141827ed8186b9ef28e6fa73679c52e67ad69b8 Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 11 Mar 2026 21:59:01 -0300 Subject: [PATCH 8/9] put all tests inside an `await Promise.all()` --- tests/config/run-test.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/config/run-test.js b/tests/config/run-test.js index ac4f602a7..c069946bf 100644 --- a/tests/config/run-test.js +++ b/tests/config/run-test.js @@ -64,14 +64,22 @@ async function runTest({ if (!FULL_TEST) { return; } - await testAntlrFormat.run(code, formatResult, filename, formatOptions); - await testVariantCoverage.run(code, formatResult, filename, formatOptions); - await testSecondFormat.run(code, formatResult, filename, formatOptions); - await testAstCompare.run(code, formatResult, filename, formatOptions); - await testEndOfLine.run(code, formatResult, filename, formatOptions, "\r\n"); - await testEndOfLine.run(code, formatResult, filename, formatOptions, "\r"); - await testBom.run(code, formatResult, filename, formatOptions); - await testBytecodeCompare.run(code, formatResult, filename, formatOptions); + await Promise.all( + [ + testAntlrFormat, + testVariantCoverage, + testSecondFormat, + testAstCompare, + testBom, + testBytecodeCompare, + ] + .map((test) => test.run(code, formatResult, filename, formatOptions)) + .join( + ["\r\n", "\r"].map((eol) => + testEndOfLine.run(code, formatResult, filename, formatOptions, eol), + ), + ), + ); } export { runTest }; From 723d09cfb5dd400b4df6e406b866bc4331031749 Mon Sep 17 00:00:00 2001 From: Klaus Date: Mon, 23 Mar 2026 11:53:42 -0300 Subject: [PATCH 9/9] passing knip --- tests/config/run-test.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/config/run-test.js b/tests/config/run-test.js index c069946bf..4186f1403 100644 --- a/tests/config/run-test.js +++ b/tests/config/run-test.js @@ -66,14 +66,14 @@ async function runTest({ } await Promise.all( [ - testAntlrFormat, - testVariantCoverage, - testSecondFormat, - testAstCompare, - testBom, - testBytecodeCompare, + testAntlrFormat.run, + testVariantCoverage.run, + testSecondFormat.run, + testAstCompare.run, + testBom.run, + testBytecodeCompare.run, ] - .map((test) => test.run(code, formatResult, filename, formatOptions)) + .map((run) => run(code, formatResult, filename, formatOptions)) .join( ["\r\n", "\r"].map((eol) => testEndOfLine.run(code, formatResult, filename, formatOptions, eol),