From 9bfebb4062ef776c475fefceb4d4439abf2b40db Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Wed, 8 Mar 2023 09:18:45 +0800 Subject: [PATCH] Fix perf test scripts (#14460) --- package.json | 4 ++-- src/cli/format.js | 11 +++++------ tests/integration/__tests__/performance-flags.js | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index c1e5d9110..4b5877b51 100644 --- a/package.json +++ b/package.json @@ -161,8 +161,8 @@ "test:dist": "cross-env NODE_ENV=production yarn test", "test:dist-standalone": "cross-env TEST_STANDALONE=1 yarn test:dist", "test:dist-lint": "eslint --no-eslintrc --no-ignore --no-inline-config --config=./scripts/bundle-eslint-config.cjs \"dist/**/*.{js,cjs,mjs}\"", - "perf": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js", - "perf:inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js", + "perf": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin/prettier.cjs", + "perf:inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin/prettier.cjs", "perf:benchmark": "yarn perf --debug-benchmark", "perf:compare": "./scripts/benchmark/compare.sh", "lint": "run-p \"lint:*\"", diff --git a/src/cli/format.js b/src/cli/format.js index 935dd82e3..fb285f7ed 100644 --- a/src/cli/format.js +++ b/src/cli/format.js @@ -204,11 +204,9 @@ async function format(context, input, opt) { JSON.stringify(result, null, 2) ); } else if (performanceTestFlag?.debugRepeat) { - const repeat = context.argv.debugRepeat; + const repeat = performanceTestFlag.debugRepeat; context.logger.debug( - "'--debug-repeat' option found, running formatWithCursor " + - repeat + - " times." + `'${performanceTestFlag.name}' found, running formatWithCursor ${repeat} times.` ); let totalMs = 0; for (let i = 0; i < repeat; ++i) { @@ -224,8 +222,9 @@ async function format(context, input, opt) { ms: averageMs, }; context.logger.debug( - "'--debug-repeat' measurements for formatWithCursor: " + - JSON.stringify(results, null, 2) + `'${ + performanceTestFlag.name + }' measurements for formatWithCursor: ${JSON.stringify(results, null, 2)}` ); } diff --git a/tests/integration/__tests__/performance-flags.js b/tests/integration/__tests__/performance-flags.js index 95539323b..7fbccd426 100644 --- a/tests/integration/__tests__/performance-flags.js +++ b/tests/integration/__tests__/performance-flags.js @@ -2,7 +2,7 @@ describe("should not write file or print code when `--debug-benchmark` or `--deb const assertStderr = (message) => { expect( message.includes( - "'--debug-repeat' option found, running formatWithCursor 2 times" + "'--debug-repeat' found, running formatWithCursor 2 times" ) ).toBe(true); };