From 7fedca6c4836dccc8b78fb14b5708059d5930549 Mon Sep 17 00:00:00 2001 From: Matt Weber <1062734+mweberxyz@users.noreply.github.com> Date: Thu, 28 Mar 2024 19:48:45 -0400 Subject: [PATCH 1/7] =?UTF-8?q?chore:=20add=20automated=20CI=20testing=20w?= =?UTF-8?q?ith=20=E2=80=94no-intl=20node?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/test/action.yml | 28 ++++++++++++++++++ .github/workflows/nodejs.yml | 51 +++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 20 +------------ 3 files changed, 80 insertions(+), 19 deletions(-) create mode 100644 .github/actions/test/action.yml diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml new file mode 100644 index 00000000000..be8e84e92e7 --- /dev/null +++ b/.github/actions/test/action.yml @@ -0,0 +1,28 @@ +name: Run tests +runs: + using: "composite" + steps: + - name: Print version information + shell: bash + run: | + echo OS: $(node -p "os.version()") + echo Node.js: $(node --version) + echo npm: $(npm --version) + echo git: $(git --version) + echo icu config: $(node -e "console.log(process.config)" | grep icu) + + - name: Install dependencies + shell: bash + run: npm install + + - name: Print installed dependencies + shell: bash + run: npm ls --all + continue-on-error: true + + - name: Run tests + shell: bash + run: npm run coverage:ci + env: + CI: true + NODE_V8_COVERAGE: ./coverage/tmp diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 6373d4ac7e7..f1823d32776 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -69,6 +69,56 @@ jobs: runs-on: ${{ matrix.runs-on }} secrets: inherit + test-without-intl: + name: Test with Node.js ${{ matrix.version }} compiled --without-intl + strategy: + fail-fast: false + max-parallel: 0 + matrix: + version: [20, 21] + runs-on: ubuntu-latest + timeout-minutes: 120 + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + persist-credentials: false + + - name: Determine latest release + id: release + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + result-encoding: string + script: | + const req = await fetch('https://nodejs.org/download/release/index.json') + const releases = await req.json() + + const latest = releases.find((r) => r.version.startsWith('v${{ matrix.version }}')) + return latest.version + + - name: Download and extract source + run: curl https://nodejs.org/download/release/${{ steps.release.outputs.result }}/node-${{ steps.release.outputs.result }}.tar.xz | tar xfJ - + + - name: Install ninja + run: sudo apt-get install ninja-build + + - name: ccache + uses: hendrikmuhs/ccache-action@faf867a11c028c0b483fb2ae72b6fc8f7d842714 #v1.2.12 + with: + key: node${{ matrix.version }} + + - name: Build + working-directory: ./node-${{ steps.release.outputs.result }} + run: | + export CC="ccache gcc" + export CXX="ccache g++" + ./configure --without-intl --ninja --prefix=./final + make + make install + echo "$(pwd)/final/bin" >> $GITHUB_PATH + + - uses: ./.github/actions/test + test-types: name: Test TypeScript types timeout-minutes: 15 @@ -97,6 +147,7 @@ jobs: - dependency-review - test - test-types + - test-without-intl - lint runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 530a10cbb57..20e4a1266e0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,25 +29,7 @@ jobs: with: node-version: ${{ inputs.node-version }} - - name: Print version information - run: | - echo OS: $(node -p "os.version()") - echo Node.js: $(node --version) - echo npm: $(npm --version) - echo git: $(git --version) - - - name: Install dependencies - run: npm install - - - name: Print installed dependencies - run: npm ls --all - continue-on-error: true - - - name: Run tests - run: npm run coverage:ci - env: - CI: true - NODE_V8_COVERAGE: ./coverage/tmp + - uses: ./.github/actions/test - name: Coverage Report if: inputs.runs-on == 'ubuntu-latest' && inputs.node-version == 20 From 380b857009188ac57c081908d3180e33f8836fd2 Mon Sep 17 00:00:00 2001 From: Matt Weber <1062734+mweberxyz@users.noreply.github.com> Date: Fri, 29 Mar 2024 01:37:02 -0400 Subject: [PATCH 2/7] remove re-usable action and inline without intl tests --- .github/actions/test/action.yml | 28 ---------------------------- .github/workflows/nodejs.yml | 28 ++++++++++++++++++++++++++-- .github/workflows/test.yml | 20 +++++++++++++++++++- 3 files changed, 45 insertions(+), 31 deletions(-) delete mode 100644 .github/actions/test/action.yml diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml deleted file mode 100644 index be8e84e92e7..00000000000 --- a/.github/actions/test/action.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Run tests -runs: - using: "composite" - steps: - - name: Print version information - shell: bash - run: | - echo OS: $(node -p "os.version()") - echo Node.js: $(node --version) - echo npm: $(npm --version) - echo git: $(git --version) - echo icu config: $(node -e "console.log(process.config)" | grep icu) - - - name: Install dependencies - shell: bash - run: npm install - - - name: Print installed dependencies - shell: bash - run: npm ls --all - continue-on-error: true - - - name: Run tests - shell: bash - run: npm run coverage:ci - env: - CI: true - NODE_V8_COVERAGE: ./coverage/tmp diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index f1823d32776..7dd5ae4d031 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -84,6 +84,18 @@ jobs: with: persist-credentials: false + # Setup node, install deps, and build undici prior to building icu-less node and testing + - name: Setup Node.js@${{ inputs.version }} + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version: ${{ inputs.version }} + + - name: Install dependencies + run: npm install + + - name: Build undici + run: npm run build:node + - name: Determine latest release id: release uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 @@ -107,7 +119,7 @@ jobs: with: key: node${{ matrix.version }} - - name: Build + - name: Build node working-directory: ./node-${{ steps.release.outputs.result }} run: | export CC="ccache gcc" @@ -117,7 +129,19 @@ jobs: make install echo "$(pwd)/final/bin" >> $GITHUB_PATH - - uses: ./.github/actions/test + - name: Print version information + run: | + echo OS: $(node -p "os.version()") + echo Node.js: $(node --version) + echo npm: $(npm --version) + echo git: $(git --version) + echo icu config: $(node -e "console.log(process.config)" | grep icu) + + - name: Run tests + run: npm run coverage:ci + env: + CI: true + NODE_V8_COVERAGE: ./coverage/tmp test-types: name: Test TypeScript types diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 20e4a1266e0..530a10cbb57 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,25 @@ jobs: with: node-version: ${{ inputs.node-version }} - - uses: ./.github/actions/test + - name: Print version information + run: | + echo OS: $(node -p "os.version()") + echo Node.js: $(node --version) + echo npm: $(npm --version) + echo git: $(git --version) + + - name: Install dependencies + run: npm install + + - name: Print installed dependencies + run: npm ls --all + continue-on-error: true + + - name: Run tests + run: npm run coverage:ci + env: + CI: true + NODE_V8_COVERAGE: ./coverage/tmp - name: Coverage Report if: inputs.runs-on == 'ubuntu-latest' && inputs.node-version == 20 From 1cd5c31fa4603a055e743ebdc04f2784e177102c Mon Sep 17 00:00:00 2001 From: Matt Weber <1062734+mweberxyz@users.noreply.github.com> Date: Fri, 29 Mar 2024 00:58:40 -0400 Subject: [PATCH 3/7] test-fix: emoji throws off console.table cell widths --- lib/mock/pending-interceptors-formatter.js | 5 ++- test/mock-interceptor-unused-assertions.js | 36 ++++++++++++---------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/lib/mock/pending-interceptors-formatter.js b/lib/mock/pending-interceptors-formatter.js index ba6e4ebce1b..83d3a9eb01b 100644 --- a/lib/mock/pending-interceptors-formatter.js +++ b/lib/mock/pending-interceptors-formatter.js @@ -7,6 +7,9 @@ const { Console } = require('node:console') * Gets the output of `console.table(…)` as a string. */ module.exports = class PendingInterceptorsFormatter { + static PERSISTENT = process.versions.icu ? '✅' : 'Y ' + static NOT_PERSISTENT = process.versions.icu ? '❌' : 'N ' + constructor ({ disableColors } = {}) { this.transform = new Transform({ transform (chunk, _enc, cb) { @@ -29,7 +32,7 @@ module.exports = class PendingInterceptorsFormatter { Origin: origin, Path: path, 'Status code': statusCode, - Persistent: persist ? '✅' : '❌', + Persistent: persist ? PendingInterceptorsFormatter.PERSISTENT : PendingInterceptorsFormatter.NOT_PERSISTENT, Invocations: timesInvoked, Remaining: persist ? Infinity : times - timesInvoked })) diff --git a/test/mock-interceptor-unused-assertions.js b/test/mock-interceptor-unused-assertions.js index e6f5360a3f9..f2fd9fa52be 100644 --- a/test/mock-interceptor-unused-assertions.js +++ b/test/mock-interceptor-unused-assertions.js @@ -10,6 +10,10 @@ const util = require('../lib/core/util') // https://github.com/nodejs/node/pull/50135 const tableRowsAlignedToLeft = util.nodeMajor >= 21 || (util.nodeMajor === 20 && util.nodeMinor >= 11) +// `console.table` treats emoji as two character widths for cell width determination +const Y = PendingInterceptorsFormatter.PERSISTENT +const N = PendingInterceptorsFormatter.NOT_PERSISTENT + // Avoid colors in the output for inline snapshots. const pendingInterceptorsFormatter = new PendingInterceptorsFormatter({ disableColors: true }) @@ -55,7 +59,7 @@ test('1 pending interceptor', t => { ┌─────────┬────────┬───────────────────────┬──────┬─────────────┬────────────┬─────────────┬───────────┐ │ (index) │ Method │ Origin │ Path │ Status code │ Persistent │ Invocations │ Remaining │ ├─────────┼────────┼───────────────────────┼──────┼─────────────┼────────────┼─────────────┼───────────┤ -│ 0 │ 'GET' │ 'https://example.com' │ '/' │ 200 │ '❌' │ 0 │ 1 │ +│ 0 │ 'GET' │ 'https://example.com' │ '/' │ 200 │ '${N}' │ 0 │ 1 │ └─────────┴────────┴───────────────────────┴──────┴─────────────┴────────────┴─────────────┴───────────┘ `.trim() : ` @@ -64,7 +68,7 @@ test('1 pending interceptor', t => { ┌─────────┬────────┬───────────────────────┬──────┬─────────────┬────────────┬─────────────┬───────────┐ │ (index) │ Method │ Origin │ Path │ Status code │ Persistent │ Invocations │ Remaining │ ├─────────┼────────┼───────────────────────┼──────┼─────────────┼────────────┼─────────────┼───────────┤ -│ 0 │ 'GET' │ 'https://example.com' │ '/' │ 200 │ '❌' │ 0 │ 1 │ +│ 0 │ 'GET' │ 'https://example.com' │ '/' │ 200 │ '${N}' │ 0 │ 1 │ └─────────┴────────┴───────────────────────┴──────┴─────────────┴────────────┴─────────────┴───────────┘ `.trim()) } @@ -88,8 +92,8 @@ test('2 pending interceptors', t => { ┌─────────┬────────┬──────────────────────────┬──────────────┬─────────────┬────────────┬─────────────┬───────────┐ │ (index) │ Method │ Origin │ Path │ Status code │ Persistent │ Invocations │ Remaining │ ├─────────┼────────┼──────────────────────────┼──────────────┼─────────────┼────────────┼─────────────┼───────────┤ -│ 0 │ 'GET' │ 'https://example.com' │ '/' │ 200 │ '❌' │ 0 │ 1 │ -│ 1 │ 'GET' │ 'https://localhost:9999' │ '/some/path' │ 204 │ '❌' │ 0 │ 1 │ +│ 0 │ 'GET' │ 'https://example.com' │ '/' │ 200 │ '${N}' │ 0 │ 1 │ +│ 1 │ 'GET' │ 'https://localhost:9999' │ '/some/path' │ 204 │ '${N}' │ 0 │ 1 │ └─────────┴────────┴──────────────────────────┴──────────────┴─────────────┴────────────┴─────────────┴───────────┘ `.trim() : ` @@ -98,8 +102,8 @@ test('2 pending interceptors', t => { ┌─────────┬────────┬──────────────────────────┬──────────────┬─────────────┬────────────┬─────────────┬───────────┐ │ (index) │ Method │ Origin │ Path │ Status code │ Persistent │ Invocations │ Remaining │ ├─────────┼────────┼──────────────────────────┼──────────────┼─────────────┼────────────┼─────────────┼───────────┤ -│ 0 │ 'GET' │ 'https://example.com' │ '/' │ 200 │ '❌' │ 0 │ 1 │ -│ 1 │ 'GET' │ 'https://localhost:9999' │ '/some/path' │ 204 │ '❌' │ 0 │ 1 │ +│ 0 │ 'GET' │ 'https://example.com' │ '/' │ 200 │ '${N}' │ 0 │ 1 │ +│ 1 │ 'GET' │ 'https://localhost:9999' │ '/some/path' │ 204 │ '${N}' │ 0 │ 1 │ └─────────┴────────┴──────────────────────────┴──────────────┴─────────────┴────────────┴─────────────┴───────────┘ `.trim()) } @@ -164,10 +168,10 @@ test('Variations of persist(), times(), and pending status', async t => { ┌─────────┬────────┬──────────────────────────┬──────────────────────┬─────────────┬────────────┬─────────────┬───────────┐ │ (index) │ Method │ Origin │ Path │ Status code │ Persistent │ Invocations │ Remaining │ ├─────────┼────────┼──────────────────────────┼──────────────────────┼─────────────┼────────────┼─────────────┼───────────┤ -│ 0 │ 'GET' │ 'https://example.com' │ '/' │ 200 │ '❌' │ 0 │ 1 │ -│ 1 │ 'GET' │ 'https://localhost:9999' │ '/persistent/unused' │ 200 │ '✅' │ 0 │ Infinity │ -│ 2 │ 'GET' │ 'https://localhost:9999' │ '/times/partial' │ 200 │ '❌' │ 1 │ 4 │ -│ 3 │ 'GET' │ 'https://localhost:9999' │ '/times/unused' │ 200 │ '❌' │ 0 │ 2 │ +│ 0 │ 'GET' │ 'https://example.com' │ '/' │ 200 │ '${N}' │ 0 │ 1 │ +│ 1 │ 'GET' │ 'https://localhost:9999' │ '/persistent/unused' │ 200 │ '${Y}' │ 0 │ Infinity │ +│ 2 │ 'GET' │ 'https://localhost:9999' │ '/times/partial' │ 200 │ '${N}' │ 1 │ 4 │ +│ 3 │ 'GET' │ 'https://localhost:9999' │ '/times/unused' │ 200 │ '${N}' │ 0 │ 2 │ └─────────┴────────┴──────────────────────────┴──────────────────────┴─────────────┴────────────┴─────────────┴───────────┘ `.trim() : ` @@ -176,10 +180,10 @@ test('Variations of persist(), times(), and pending status', async t => { ┌─────────┬────────┬──────────────────────────┬──────────────────────┬─────────────┬────────────┬─────────────┬───────────┐ │ (index) │ Method │ Origin │ Path │ Status code │ Persistent │ Invocations │ Remaining │ ├─────────┼────────┼──────────────────────────┼──────────────────────┼─────────────┼────────────┼─────────────┼───────────┤ -│ 0 │ 'GET' │ 'https://example.com' │ '/' │ 200 │ '❌' │ 0 │ 1 │ -│ 1 │ 'GET' │ 'https://localhost:9999' │ '/persistent/unused' │ 200 │ '✅' │ 0 │ Infinity │ -│ 2 │ 'GET' │ 'https://localhost:9999' │ '/times/partial' │ 200 │ '❌' │ 1 │ 4 │ -│ 3 │ 'GET' │ 'https://localhost:9999' │ '/times/unused' │ 200 │ '❌' │ 0 │ 2 │ +│ 0 │ 'GET' │ 'https://example.com' │ '/' │ 200 │ '${N}' │ 0 │ 1 │ +│ 1 │ 'GET' │ 'https://localhost:9999' │ '/persistent/unused' │ 200 │ '${Y}' │ 0 │ Infinity │ +│ 2 │ 'GET' │ 'https://localhost:9999' │ '/times/partial' │ 200 │ '${N}' │ 1 │ 4 │ +│ 3 │ 'GET' │ 'https://localhost:9999' │ '/times/unused' │ 200 │ '${N}' │ 0 │ 2 │ └─────────┴────────┴──────────────────────────┴──────────────────────┴─────────────┴────────────┴─────────────┴───────────┘ `.trim()) } @@ -229,7 +233,7 @@ test('defaults to rendering output with terminal color when process.env.CI is un ┌─────────┬────────┬───────────────────────┬──────┬─────────────┬────────────┬─────────────┬───────────┐ │ (index) │ Method │ Origin │ Path │ Status code │ Persistent │ Invocations │ Remaining │ ├─────────┼────────┼───────────────────────┼──────┼─────────────┼────────────┼─────────────┼───────────┤ -│ 0 │ \u001b[32m'GET'\u001b[39m │ \u001b[32m'https://example.com'\u001b[39m │ \u001b[32m'/'\u001b[39m │ \u001b[33m200\u001b[39m │ \u001b[32m'❌'\u001b[39m │ \u001b[33m0\u001b[39m │ \u001b[33m1\u001b[39m │ +│ 0 │ \u001b[32m'GET'\u001b[39m │ \u001b[32m'https://example.com'\u001b[39m │ \u001b[32m'/'\u001b[39m │ \u001b[33m200\u001b[39m │ \u001b[32m'${N}'\u001b[39m │ \u001b[33m0\u001b[39m │ \u001b[33m1\u001b[39m │ └─────────┴────────┴───────────────────────┴──────┴─────────────┴────────────┴─────────────┴───────────┘ `.trim() : ` @@ -238,7 +242,7 @@ test('defaults to rendering output with terminal color when process.env.CI is un ┌─────────┬────────┬───────────────────────┬──────┬─────────────┬────────────┬─────────────┬───────────┐ │ (index) │ Method │ Origin │ Path │ Status code │ Persistent │ Invocations │ Remaining │ ├─────────┼────────┼───────────────────────┼──────┼─────────────┼────────────┼─────────────┼───────────┤ -│ 0 │ \u001b[32m'GET'\u001b[39m │ \u001b[32m'https://example.com'\u001b[39m │ \u001b[32m'/'\u001b[39m │ \u001b[33m200\u001b[39m │ \u001b[32m'❌'\u001b[39m │ \u001b[33m0\u001b[39m │ \u001b[33m1\u001b[39m │ +│ 0 │ \u001b[32m'GET'\u001b[39m │ \u001b[32m'https://example.com'\u001b[39m │ \u001b[32m'/'\u001b[39m │ \u001b[33m200\u001b[39m │ \u001b[32m'${N}'\u001b[39m │ \u001b[33m0\u001b[39m │ \u001b[33m1\u001b[39m │ └─────────┴────────┴───────────────────────┴──────┴─────────────┴────────────┴─────────────┴───────────┘ `.trim()) From c7f9f626c49ed6644b951ab64af194abc1b6c742 Mon Sep 17 00:00:00 2001 From: Matt Weber <1062734+mweberxyz@users.noreply.github.com> Date: Fri, 29 Mar 2024 01:22:39 -0400 Subject: [PATCH 4/7] test: enable as much as possible for non-icu --- .github/workflows/nodejs.yml | 5 +---- package.json | 8 ++++++-- test/node-test/debug.js | 3 +++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 7dd5ae4d031..ba8b8fdeb6f 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -138,10 +138,7 @@ jobs: echo icu config: $(node -e "console.log(process.config)" | grep icu) - name: Run tests - run: npm run coverage:ci - env: - CI: true - NODE_V8_COVERAGE: ./coverage/tmp + run: npm run test:javascript:withoutintl test-types: name: Test TypeScript types diff --git a/package.json b/package.json index f7d7bfd5b9a..2f1cfa0ebaf 100644 --- a/package.json +++ b/package.json @@ -69,10 +69,13 @@ "lint:fix": "standard --fix | snazzy", "test": "npm run test:javascript && cross-env NODE_V8_COVERAGE= npm run test:typescript", "test:javascript": "node scripts/generate-pem && npm run test:unit && npm run test:node-fetch && npm run test:fetch && npm run test:cookies && npm run test:eventsource && npm run test:wpt && npm run test:websocket && npm run test:node-test && npm run test:jest", + "test:javascript:withoutintl": "node scripts/generate-pem && npm run test:unit && npm run test:node-fetch && npm run test:fetch:nobuild && npm run test:cookies && npm run test:eventsource:nobuild && npm run test:wpt:withoutintl && npm run test:node-test", "test:cookies": "borp -p \"test/cookie/*.js\"", "test:node-fetch": "borp -p \"test/node-fetch/**/*.js\"", - "test:eventsource": "npm run build:node && borp --expose-gc -p \"test/eventsource/*.js\"", - "test:fetch": "npm run build:node && borp --expose-gc -p \"test/fetch/*.js\" && borp -p \"test/webidl/*.js\" && borp -p \"test/busboy/*.js\"", + "test:eventsource": "npm run build:node && npm run test:eventsource:nobuild", + "test:eventsource:nobuild": "borp --expose-gc -p \"test/eventsource/*.js\"", + "test:fetch": "npm run build:node && npm run test:fetch:nobuild", + "test:fetch:nobuild": "borp --expose-gc -p \"test/fetch/*.js\" && borp -p \"test/webidl/*.js\" && borp -p \"test/busboy/*.js\"", "test:jest": "cross-env NODE_V8_COVERAGE= jest", "test:unit": "borp --expose-gc -p \"test/*.js\"", "test:node-test": "borp -p \"test/node-test/**/*.js\"", @@ -81,6 +84,7 @@ "test:typescript": "tsd && tsc --skipLibCheck test/imports/undici-import.ts", "test:websocket": "borp -p \"test/websocket/*.js\"", "test:wpt": "node test/wpt/start-fetch.mjs && node test/wpt/start-FileAPI.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs && node test/wpt/start-websockets.mjs && node test/wpt/start-cacheStorage.mjs && node test/wpt/start-eventsource.mjs", + "test:wpt:withoutintl": "node test/wpt/start-fetch.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs && node test/wpt/start-cacheStorage.mjs && node test/wpt/start-eventsource.mjs", "coverage": "npm run coverage:clean && cross-env NODE_V8_COVERAGE=./coverage/tmp npm run test:javascript && npm run coverage:report", "coverage:ci": "npm run coverage:clean && cross-env NODE_V8_COVERAGE=./coverage/tmp npm run test:javascript && npm run coverage:report:ci", "coverage:clean": "node ./scripts/clean-coverage.js", diff --git a/test/node-test/debug.js b/test/node-test/debug.js index 3e6ca0bc0ef..a408a801e8f 100644 --- a/test/node-test/debug.js +++ b/test/node-test/debug.js @@ -9,6 +9,9 @@ const { tspl } = require('@matteo.collina/tspl') const removeEscapeColorsRE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g test('debug#websocket', async t => { + if (!process.versions.icu) { + return + } const assert = tspl(t, { plan: 8 }) const child = spawn( process.execPath, From bcaa5482ebe773cef86a3d252a7f2caa475f9250 Mon Sep 17 00:00:00 2001 From: Matt Weber <1062734+mweberxyz@users.noreply.github.com> Date: Fri, 29 Mar 2024 09:51:07 -0400 Subject: [PATCH 5/7] Update test/node-test/debug.js Co-authored-by: Carlos Fuentes --- test/node-test/debug.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/node-test/debug.js b/test/node-test/debug.js index a408a801e8f..d7c462f57ae 100644 --- a/test/node-test/debug.js +++ b/test/node-test/debug.js @@ -8,10 +8,7 @@ const { tspl } = require('@matteo.collina/tspl') // eslint-disable-next-line no-control-regex const removeEscapeColorsRE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g -test('debug#websocket', async t => { - if (!process.versions.icu) { - return - } +test('debug#websocket', { skip: !process.versions.icu }, async t => { const assert = tspl(t, { plan: 8 }) const child = spawn( process.execPath, From 391d4f86911628c4aa1568c5efa6a8a48fac5404 Mon Sep 17 00:00:00 2001 From: Matt Weber <1062734+mweberxyz@users.noreply.github.com> Date: Fri, 29 Mar 2024 14:10:51 -0400 Subject: [PATCH 6/7] flakey test fix .bar is a valid, though unpopular, TLD. should be safer to use a domain in .invalid as specified in proposed RFC6761. --- test/connect-timeout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/connect-timeout.js b/test/connect-timeout.js index 98f7c466bbf..0a28e1f250d 100644 --- a/test/connect-timeout.js +++ b/test/connect-timeout.js @@ -9,7 +9,7 @@ const assert = require('node:assert') // Using describe instead of test to avoid the timeout describe('prioritize socket errors over timeouts', async () => { const t = tspl({ ...assert, after: () => {} }, { plan: 1 }) - const client = new Pool('http://foobar.bar:1234', { connectTimeout: 1 }) + const client = new Pool('http://foorbar.invalid:1234', { connectTimeout: 1 }) client.request({ method: 'GET', path: '/foobar' }) .then(() => t.fail()) From bd4273eb379b3df03d6d7ae49a11ddc4f1882dd8 Mon Sep 17 00:00:00 2001 From: Matt Weber <1062734+mweberxyz@users.noreply.github.com> Date: Fri, 29 Mar 2024 14:50:20 -0400 Subject: [PATCH 7/7] re-define constants in test instead of static members --- lib/mock/pending-interceptors-formatter.js | 8 ++++---- test/mock-interceptor-unused-assertions.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/mock/pending-interceptors-formatter.js b/lib/mock/pending-interceptors-formatter.js index 83d3a9eb01b..ccca951195a 100644 --- a/lib/mock/pending-interceptors-formatter.js +++ b/lib/mock/pending-interceptors-formatter.js @@ -3,13 +3,13 @@ const { Transform } = require('node:stream') const { Console } = require('node:console') +const PERSISTENT = process.versions.icu ? '✅' : 'Y ' +const NOT_PERSISTENT = process.versions.icu ? '❌' : 'N ' + /** * Gets the output of `console.table(…)` as a string. */ module.exports = class PendingInterceptorsFormatter { - static PERSISTENT = process.versions.icu ? '✅' : 'Y ' - static NOT_PERSISTENT = process.versions.icu ? '❌' : 'N ' - constructor ({ disableColors } = {}) { this.transform = new Transform({ transform (chunk, _enc, cb) { @@ -32,7 +32,7 @@ module.exports = class PendingInterceptorsFormatter { Origin: origin, Path: path, 'Status code': statusCode, - Persistent: persist ? PendingInterceptorsFormatter.PERSISTENT : PendingInterceptorsFormatter.NOT_PERSISTENT, + Persistent: persist ? PERSISTENT : NOT_PERSISTENT, Invocations: timesInvoked, Remaining: persist ? Infinity : times - timesInvoked })) diff --git a/test/mock-interceptor-unused-assertions.js b/test/mock-interceptor-unused-assertions.js index f2fd9fa52be..5be3942d3db 100644 --- a/test/mock-interceptor-unused-assertions.js +++ b/test/mock-interceptor-unused-assertions.js @@ -11,8 +11,8 @@ const util = require('../lib/core/util') const tableRowsAlignedToLeft = util.nodeMajor >= 21 || (util.nodeMajor === 20 && util.nodeMinor >= 11) // `console.table` treats emoji as two character widths for cell width determination -const Y = PendingInterceptorsFormatter.PERSISTENT -const N = PendingInterceptorsFormatter.NOT_PERSISTENT +const Y = process.versions.icu ? '✅' : 'Y ' +const N = process.versions.icu ? '❌' : 'N ' // Avoid colors in the output for inline snapshots. const pendingInterceptorsFormatter = new PendingInterceptorsFormatter({ disableColors: true })