From 424c6b6f47d807ee83ea5750c3e8b18cdaa6bf01 Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Thu, 21 Aug 2025 10:05:11 +0300 Subject: [PATCH 1/2] test: check `ProcessPromise.id` is unique --- scripts/build-versions.mjs | 5 +++-- test/core.test.js | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/build-versions.mjs b/scripts/build-versions.mjs index 0c26d7e8b3..0959ed2ac4 100644 --- a/scripts/build-versions.mjs +++ b/scripts/build-versions.mjs @@ -23,6 +23,7 @@ const copyright = await fs.readFileSync( path.resolve(root, 'test/fixtures/copyright.txt'), 'utf8' ) +const license = copyright.replace('YEAR', new Date().getFullYear()) const deps = [ 'chalk', 'depseek', @@ -67,10 +68,10 @@ const list = JSON.stringify(argv, null, 2) .replaceAll('"', "'") .replace(/\n}$/, ',\n}') -const versionsTs = `${copyright.replace('YEAR', new Date().getFullYear())} +const versionsTs = `${license} export const versions: Record = ${list} ` -const versionsCjs = `${copyright.replace('YEAR', new Date().getFullYear())} +const versionsCjs = `${license} module.exports = { versions: ${list} ` diff --git a/test/core.test.js b/test/core.test.js index fee1e5fb49..7e7bc45e45 100644 --- a/test/core.test.js +++ b/test/core.test.js @@ -526,6 +526,14 @@ describe('core', () => { assert.ok(p.output instanceof ProcessOutput) }) + test('id is unique', () => { + const p1 = $({ halt: true })`echo foo` + const p2 = $({ halt: true })`echo bar` + assert.ok(p1.id !== p2.id) + assert.ok(p1.id.length === 11) + assert.ok(p2.id.length === 11) + }) + describe('state machine transitions', () => { it('running > fulfilled', async () => { const p = $`echo foo` From 60e2d9ab51009952075f330b1f67f47bed002edd Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Thu, 21 Aug 2025 11:50:22 +0300 Subject: [PATCH 2/2] ci: use nodejs 24 by default --- .github/workflows/dev-publish.yml | 6 +++--- .github/workflows/jsr-publish.yml | 4 ++-- .github/workflows/publish.yml | 6 +++--- .github/workflows/test.yml | 16 ++++++++-------- build/cli.js | 0 package.json | 2 +- test/cli.test.js | 2 +- test/core.test.js | 20 ++++++++++++-------- test/export.test.js | 6 ++---- test/fixtures/echo.http | 7 +++---- test/fixtures/server.mjs | 2 +- 11 files changed, 36 insertions(+), 35 deletions(-) mode change 100644 => 100755 build/cli.js diff --git a/.github/workflows/dev-publish.yml b/.github/workflows/dev-publish.yml index 9efd0f9837..63a6388804 100644 --- a/.github/workflows/dev-publish.yml +++ b/.github/workflows/dev-publish.yml @@ -18,7 +18,7 @@ jobs: persist-credentials: false - uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 24 cache: 'npm' - run: npm ci - run: npm test @@ -74,7 +74,7 @@ jobs: persist-credentials: false - uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 24 cache: 'npm' - name: Configure npmrc run: | @@ -116,7 +116,7 @@ jobs: persist-credentials: false - uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 24 cache: 'npm' - uses: actions/download-artifact@v5 with: diff --git a/.github/workflows/jsr-publish.yml b/.github/workflows/jsr-publish.yml index 02b3194da4..1d635a2810 100644 --- a/.github/workflows/jsr-publish.yml +++ b/.github/workflows/jsr-publish.yml @@ -14,7 +14,7 @@ jobs: persist-credentials: false - uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 24 cache: 'npm' - run: npm ci - run: npm test @@ -40,7 +40,7 @@ jobs: persist-credentials: false - uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 24 cache: 'npm' - uses: actions/download-artifact@v5 with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5b7cd4f77f..60eacfa17e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,7 +20,7 @@ jobs: persist-credentials: false - uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 24 cache: 'npm' - run: npm ci - run: npm test @@ -72,7 +72,7 @@ jobs: persist-credentials: false - uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 24 cache: 'npm' - name: Configure npmrc run: | @@ -109,7 +109,7 @@ jobs: persist-credentials: false - uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 24 cache: 'npm' - uses: actions/download-artifact@v5 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 86998ff05c..10c8d052a6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,10 +23,10 @@ jobs: with: persist-credentials: false - - name: Use Node.js 22.x + - name: Use Node.js 24 uses: actions/setup-node@v4 with: - node-version: 22.x + node-version: 24 cache: 'npm' - run: npm ci @@ -53,10 +53,10 @@ jobs: persist-credentials: false fetch-depth: ${{ github.event_name == 'pull_request' && '15' || '1' }} # to ensure we have enough history for commitlint - - name: Use Node.js 22.x + - name: Use Node.js 24 uses: actions/setup-node@v4 with: - node-version: 22.x + node-version: 24 cache: 'npm' - uses: actions/download-artifact@v5 @@ -104,10 +104,10 @@ jobs: with: persist-credentials: false - - name: Use Node.js 22.x + - name: Use Node.js 24 uses: actions/setup-node@v4 with: - node-version: 22.x + node-version: 24 cache: 'npm' - uses: actions/download-artifact@v5 @@ -268,10 +268,10 @@ jobs: - uses: actions/checkout@v5 with: persist-credentials: false - - name: Use Node.js 22.x + - name: Use Node.js 24 uses: actions/setup-node@v4 with: - node-version: 22.x + node-version: 24 cache: 'npm' - name: Install deps diff --git a/build/cli.js b/build/cli.js old mode 100644 new mode 100755 diff --git a/package.json b/package.json index 171e76abc5..ecaf818913 100644 --- a/package.json +++ b/package.json @@ -200,7 +200,7 @@ "author": "Anton Medvedev ", "license": "Apache-2.0", "volta": { - "node": "22.12.0" + "node": "24.6.0" }, "tsd": { "compilerOptions": { diff --git a/test/cli.test.js b/test/cli.test.js index 93fc3a5a69..b0d84b92ba 100644 --- a/test/cli.test.js +++ b/test/cli.test.js @@ -211,7 +211,7 @@ console.log(a); test('scripts from https 500', async () => { const port = await getPort() - const server = await fakeServer(['HTTP/1.1 500\n\n']).listen(port) + const server = await fakeServer([`HTTP/1.1 500\n\n500\n`]).listen(port) const out = await $`node build/cli.js http://127.0.0.1:${port}`.nothrow() assert.match(out.stderr, /Error: Can't get/) await server.stop() diff --git a/test/core.test.js b/test/core.test.js index 7e7bc45e45..f259da1efa 100644 --- a/test/core.test.js +++ b/test/core.test.js @@ -526,12 +526,16 @@ describe('core', () => { assert.ok(p.output instanceof ProcessOutput) }) - test('id is unique', () => { - const p1 = $({ halt: true })`echo foo` - const p2 = $({ halt: true })`echo bar` + test('id is unique', async () => { + const p1 = $`echo foo` + const p2 = $`echo bar` + assert.ok(p1.id !== p2.id) - assert.ok(p1.id.length === 11) - assert.ok(p2.id.length === 11) + assert.ok(p1.id.length > 5) + assert.ok(p2.id.length > 5) + + await p1 + await p2 }) describe('state machine transitions', () => { @@ -983,14 +987,14 @@ describe('core', () => { describe('unpipe()', () => { it('disables piping', async () => { - const p1 = $`echo foo && sleep 0.1 && echo bar && sleep 0.1 && echo baz && sleep 0.1 && echo qux` - const p2 = $`echo 1 && sleep 0.15 && echo 2 && sleep 0.1 && echo 3` + const p1 = $`echo foo && sleep 0.2 && echo bar && sleep 0.2 && echo baz && sleep 0.2 && echo qux` + const p2 = $`echo 1 && sleep 0.3 && echo 2 && sleep 0.2 && echo 3` const p3 = $`cat` p1.pipe(p3) p2.pipe(p3) - setTimeout(() => p1.unpipe(p3), 150) + setTimeout(() => p1.unpipe(p3), 300) const { stdout } = await p3 assert.equal(stdout, 'foo\n1\nbar\n2\n3\n') diff --git a/test/export.test.js b/test/export.test.js index 436e9d4588..afcf203984 100644 --- a/test/export.test.js +++ b/test/export.test.js @@ -230,15 +230,12 @@ describe('index', () => { assert.equal(typeof index.fs, 'object', 'index.fs') assert.equal(typeof index.fs.Dir, 'function', 'index.fs.Dir') assert.equal(typeof index.fs.Dirent, 'function', 'index.fs.Dirent') - assert.equal(typeof index.fs.F_OK, 'number', 'index.fs.F_OK') assert.equal(typeof index.fs.FileReadStream, 'function', 'index.fs.FileReadStream') assert.equal(typeof index.fs.FileWriteStream, 'function', 'index.fs.FileWriteStream') - assert.equal(typeof index.fs.R_OK, 'number', 'index.fs.R_OK') assert.equal(typeof index.fs.ReadStream, 'function', 'index.fs.ReadStream') assert.equal(typeof index.fs.Stats, 'function', 'index.fs.Stats') - assert.equal(typeof index.fs.W_OK, 'number', 'index.fs.W_OK') + assert.equal(typeof index.fs.Utf8Stream, 'function', 'index.fs.Utf8Stream') assert.equal(typeof index.fs.WriteStream, 'function', 'index.fs.WriteStream') - assert.equal(typeof index.fs.X_OK, 'number', 'index.fs.X_OK') assert.equal(typeof index.fs._toUnixTimestamp, 'function', 'index.fs._toUnixTimestamp') assert.equal(typeof index.fs.access, 'function', 'index.fs.access') assert.equal(typeof index.fs.accessSync, 'function', 'index.fs.accessSync') @@ -314,6 +311,7 @@ describe('index', () => { assert.equal(typeof index.fs.mkdirs, 'function', 'index.fs.mkdirs') assert.equal(typeof index.fs.mkdirsSync, 'function', 'index.fs.mkdirsSync') assert.equal(typeof index.fs.mkdtemp, 'function', 'index.fs.mkdtemp') + assert.equal(typeof index.fs.mkdtempDisposableSync, 'function', 'index.fs.mkdtempDisposableSync') assert.equal(typeof index.fs.mkdtempSync, 'function', 'index.fs.mkdtempSync') assert.equal(typeof index.fs.move, 'function', 'index.fs.move') assert.equal(typeof index.fs.moveSync, 'function', 'index.fs.moveSync') diff --git a/test/fixtures/echo.http b/test/fixtures/echo.http index de4a8b961b..85cc6dff61 100644 --- a/test/fixtures/echo.http +++ b/test/fixtures/echo.http @@ -1,6 +1,5 @@ HTTP/1.1 200 OK Content-Type: text/javascript; charset=UTF-8 -Content-Length: 15 -Server: netcat! - -$`echo 'test'` +Content-Length: 14 + +$`echo 'test'` diff --git a/test/fixtures/server.mjs b/test/fixtures/server.mjs index 1cb8aadd45..ffe413f12b 100644 --- a/test/fixtures/server.mjs +++ b/test/fixtures/server.mjs @@ -19,7 +19,7 @@ export const fakeServer = (data = []) => { server.on('connection', (conn) => { conn.on('data', () => { const d = data.shift() || 'pong' - const _d = typeof d === 'string' ? d.replace(/\r?\n/gm, '\r\n') : d + const _d = d.toString('utf-8').split(/\r?\n/).join('\r\n') conn.write(_d) }) })