From c0e4433ea944cd103516f1b035462435c5189939 Mon Sep 17 00:00:00 2001 From: wellwelwel <46850407+wellwelwel@users.noreply.github.com> Date: Fri, 26 Apr 2024 03:45:28 -0300 Subject: [PATCH 1/7] ci: enable windows workflow --- .github/workflows/{ci-windows.yml.bak => ci-windows.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{ci-windows.yml.bak => ci-windows.yml} (100%) diff --git a/.github/workflows/ci-windows.yml.bak b/.github/workflows/ci-windows.yml similarity index 100% rename from .github/workflows/ci-windows.yml.bak rename to .github/workflows/ci-windows.yml From d5f4ab2819b2fd7a28791b3187464dcd69fcc3c9 Mon Sep 17 00:00:00 2001 From: wellwelwel <46850407+wellwelwel@users.noreply.github.com> Date: Fri, 26 Apr 2024 03:45:54 -0300 Subject: [PATCH 2/7] ci: use bin/index.ts directly --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 7893d624..2980a3e0 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,7 @@ "description": "🐷 Poku makes testing easy for Node.js, Bun & Deno at the same time.", "main": "./lib/index.js", "scripts": { - "test": "npx poku --parallel --debug test/unit,test/integration,test/e2e", - "pretest:c8": "npm run build", + "test": "tsx src/bin/index.ts --parallel --debug test/unit,test/integration,test/e2e", "test:c8": "c8 npm run test", "test:ci": "tsx ./test/ci.test.ts", "test:node": "FILTER='node-' npm run test:ci", From 6922fdb62b40e940e5659cf0a3244869095da786 Mon Sep 17 00:00:00 2001 From: wellwelwel <46850407+wellwelwel@users.noreply.github.com> Date: Fri, 26 Apr 2024 04:24:58 -0300 Subject: [PATCH 3/7] fix: adaptation for Node.js breaking change on Windows --- src/services/run-test-file.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/run-test-file.ts b/src/services/run-test-file.ts index 426f0e48..a3c7e680 100644 --- a/src/services/run-test-file.ts +++ b/src/services/run-test-file.ts @@ -2,7 +2,7 @@ import process from 'node:process'; import path from 'node:path'; import { EOL } from 'node:os'; import { spawn } from 'node:child_process'; -import { runner } from '../helpers/runner.js'; +import { isWindows, runner } from '../helpers/runner.js'; import { indentation } from '../helpers/indentation.js'; import { format } from '../helpers/format.js'; import { Configs } from '../@types/poku.js'; @@ -98,7 +98,7 @@ export const runTestFile = ( // Export spawn helper is not an option const child = spawn(runtime, runtimeArguments, { stdio: ['inherit', 'pipe', 'pipe'], - shell: false, + shell: isWindows, env: { ...process.env, FILE: configs?.parallel ? fileRelative : '', From 71bdd2b3c1765e07b222dc439abd107b7b8005e3 Mon Sep 17 00:00:00 2001 From: wellwelwel <46850407+wellwelwel@users.noreply.github.com> Date: Fri, 26 Apr 2024 04:28:13 -0300 Subject: [PATCH 4/7] fix: adaptation for Node.js breaking change on Windows --- src/modules/create-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/create-service.ts b/src/modules/create-service.ts index ea3a1612..f7691d7b 100644 --- a/src/modules/create-service.ts +++ b/src/modules/create-service.ts @@ -35,7 +35,7 @@ const backgroundProcess = ( const service = spawn(runtime, args, { stdio: ['inherit', 'pipe', 'pipe'], - shell: false, + shell: isWindows, cwd: options?.cwd ? sanitizePath(path.normalize(options.cwd)) : undefined, env: process.env, detached: !isWindows, From dee761a64c2f9746cb0a8375461af7082c44697c Mon Sep 17 00:00:00 2001 From: wellwelwel <46850407+wellwelwel@users.noreply.github.com> Date: Fri, 26 Apr 2024 04:30:58 -0300 Subject: [PATCH 5/7] ci: adaptation for Node.js breaking change on Windows --- test/helpers/capture-cli.test.ts | 4 ++-- test/helpers/check-node.test.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/helpers/capture-cli.test.ts b/test/helpers/capture-cli.test.ts index edb4c74a..4b3bcff7 100644 --- a/test/helpers/capture-cli.test.ts +++ b/test/helpers/capture-cli.test.ts @@ -1,6 +1,6 @@ import process from 'node:process'; import { spawn } from 'node:child_process'; -import { runner } from '../../src/helpers/runner.js'; +import { isWindows, runner } from '../../src/helpers/runner.js'; // `/_.ts`: Simulate TypeScript file for Deno const currentFile = typeof __filename === 'string' ? __filename : '/_.ts'; @@ -16,7 +16,7 @@ export const executeCLI = (args: string[]): Promise => const runtimeArguments = [...runtimeOptions, ...args]; const childProcess = spawn(runtime, runtimeArguments, { - shell: false, + shell: isWindows, }); let output: string = ''; diff --git a/test/helpers/check-node.test.ts b/test/helpers/check-node.test.ts index dcd8917a..0d377a33 100644 --- a/test/helpers/check-node.test.ts +++ b/test/helpers/check-node.test.ts @@ -1,5 +1,6 @@ import { spawn } from 'node:child_process'; import path from 'node:path'; +import { isWindows } from '../../src/helpers/runner.js'; export const executeDockerCompose = (serviceName: string): Promise => { const cwd = path.resolve('./test/docker'); @@ -25,6 +26,7 @@ export const executeDockerCompose = (serviceName: string): Promise => { const logsProcess = spawn(command, ['logs', '-f', serviceName], { cwd, stdio: 'inherit', + shell: isWindows, }); logsProcess.on('close', () => resolve(1)); From 9ab41f65f2108be0a6fd31ac507597a844e70455 Mon Sep 17 00:00:00 2001 From: wellwelwel <46850407+wellwelwel@users.noreply.github.com> Date: Fri, 26 Apr 2024 04:34:39 -0300 Subject: [PATCH 6/7] ci: fix c8 comments --- src/bin/index.ts | 2 +- src/helpers/find-file.ts | 2 +- src/helpers/pad.ts | 2 +- src/modules/create-service.ts | 9 ++++++--- src/services/run-test-file.ts | 1 + 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/bin/index.ts b/src/bin/index.ts index 2e48db73..48c44e28 100644 --- a/src/bin/index.ts +++ b/src/bin/index.ts @@ -22,7 +22,7 @@ if (hasArg('log-success')) console.log( `The flag ${format.bold('--log-success')} is deprecated. Use ${format.bold('--debug')} instead.` ); -/* c8 ignore end */ +/* c8 ignore stop */ poku(dirs, { platform: platformIsValid(platform) ? platform : undefined, diff --git a/src/helpers/find-file.ts b/src/helpers/find-file.ts index 18ff75ee..d55b3e57 100644 --- a/src/helpers/find-file.ts +++ b/src/helpers/find-file.ts @@ -30,4 +30,4 @@ export const findFile = (error: Error) => { return file; }; -/* c8 ignore end */ +/* c8 ignore stop */ diff --git a/src/helpers/pad.ts b/src/helpers/pad.ts index 81eaa1d9..f190ecef 100644 --- a/src/helpers/pad.ts +++ b/src/helpers/pad.ts @@ -21,4 +21,4 @@ export const padStart = ( return fullPadString + str; }; -/* c8 ignore end */ +/* c8 ignore stop */ diff --git a/src/modules/create-service.ts b/src/modules/create-service.ts index f7691d7b..7aa007b9 100644 --- a/src/modules/create-service.ts +++ b/src/modules/create-service.ts @@ -22,7 +22,7 @@ const killWindowsProcess = (PID: number) => process.once('SIGINT', () => { secureEnds(); }); -/* c8 ignore end */ +/* c8 ignore stop */ const backgroundProcess = ( runtime: string, @@ -35,10 +35,13 @@ const backgroundProcess = ( const service = spawn(runtime, args, { stdio: ['inherit', 'pipe', 'pipe'], + /* c8 ignore next */ shell: isWindows, cwd: options?.cwd ? sanitizePath(path.normalize(options.cwd)) : undefined, env: process.env, + /* c8 ignore next */ detached: !isWindows, + /* c8 ignore next */ windowsHide: isWindows, timeout: options?.timeout, }); @@ -69,7 +72,7 @@ const backgroundProcess = ( }; runningProcesses[PID] = end; - /* c8 ignore end */ + /* c8 ignore stop */ service.stdout.on('data', (data: Buffer) => { if (!isResolved && typeof options?.startAfter !== 'number') { @@ -187,7 +190,7 @@ export const startScript = async ( throw new Error( `${format.bold('startScript')} currently doesn't works for Bun and Deno.${EOL}See: https://github.com/wellwelwel/poku/issues/143` ); - /* c8 ignore end */ + /* c8 ignore stop */ return await backgroundProcess(runtime, runtimeArgs, script, { ...options, diff --git a/src/services/run-test-file.ts b/src/services/run-test-file.ts index a3c7e680..9e9c5b57 100644 --- a/src/services/run-test-file.ts +++ b/src/services/run-test-file.ts @@ -98,6 +98,7 @@ export const runTestFile = ( // Export spawn helper is not an option const child = spawn(runtime, runtimeArguments, { stdio: ['inherit', 'pipe', 'pipe'], + /* c8 ignore next */ shell: isWindows, env: { ...process.env, From 4407512e8f1b3c779d5f594832de142e2e549518 Mon Sep 17 00:00:00 2001 From: wellwelwel <46850407+wellwelwel@users.noreply.github.com> Date: Fri, 26 Apr 2024 04:53:30 -0300 Subject: [PATCH 7/7] ci: fix c8 comments --- src/bin/index.ts | 4 ++-- src/modules/assert-promise.ts | 8 ++++---- src/modules/assert.ts | 8 ++++---- src/modules/exit.ts | 4 ++++ src/services/run-test-file.ts | 4 ++++ 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/bin/index.ts b/src/bin/index.ts index 48c44e28..488bb881 100644 --- a/src/bin/index.ts +++ b/src/bin/index.ts @@ -1,12 +1,12 @@ #! /usr/bin/env node +/* c8 ignore start */ import { escapeRegExp } from '../modules/list-files.js'; import { getArg, getLastParam, hasArg } from '../helpers/get-arg.js'; import { poku } from '../index.js'; import { platformIsValid } from '../helpers/get-runtime.js'; import { format } from '../helpers/format.js'; -/* c8 ignore start */ const dirs = (hasArg('include') ? getArg('include')?.split(',') @@ -22,7 +22,6 @@ if (hasArg('log-success')) console.log( `The flag ${format.bold('--log-success')} is deprecated. Use ${format.bold('--debug')} instead.` ); -/* c8 ignore stop */ poku(dirs, { platform: platformIsValid(platform) ? platform : undefined, @@ -32,3 +31,4 @@ poku(dirs, { quiet, debug, }); +/* c8 ignore stop */ diff --git a/src/modules/assert-promise.ts b/src/modules/assert-promise.ts index 36db0f1e..a5154bbb 100644 --- a/src/modules/assert-promise.ts +++ b/src/modules/assert-promise.ts @@ -277,16 +277,15 @@ async function doesNotReject( ); } +/* c8 ignore start */ const match = async ( value: string, regExp: RegExp, message?: ParseAssertionOptions['message'] ): Promise => { - /* c8 ignore start */ if (typeof nodeVersion === 'number' && nodeVersion < 12) { throw new Error('match is available from Node.js 12 or higher'); } - /* c8 ignore stop */ await parseAssertion(() => nodeAssert?.match(value, regExp), { message, @@ -295,17 +294,17 @@ const match = async ( defaultMessage: 'Value should match regExp', }); }; +/* c8 ignore stop */ +/* c8 ignore start */ const doesNotMatch = async ( value: string, regExp: RegExp, message?: ParseAssertionOptions['message'] ): Promise => { - /* c8 ignore start */ if (typeof nodeVersion === 'number' && nodeVersion < 12) { throw new Error('doesNotMatch is available from Node.js 12 or higher'); } - /* c8 ignore stop */ await parseAssertion(() => nodeAssert.doesNotMatch(value, regExp), { message, @@ -314,6 +313,7 @@ const doesNotMatch = async ( defaultMessage: 'Value should not match regExp', }); }; +/* c8 ignore stop */ export const assertPromise = Object.assign( (value: unknown, message?: ParseAssertionOptions['message']) => diff --git a/src/modules/assert.ts b/src/modules/assert.ts index cac39a5f..a9e5e3a0 100644 --- a/src/modules/assert.ts +++ b/src/modules/assert.ts @@ -269,16 +269,15 @@ async function doesNotReject( ); } +/* c8 ignore start */ const match = ( value: string, regExp: RegExp, message?: ParseAssertionOptions['message'] ): void => { - /* c8 ignore start */ if (typeof nodeVersion === 'number' && nodeVersion < 12) { throw new Error('match is available from Node.js 12 or higher'); } - /* c8 ignore stop */ parseAssertion(() => nodeAssert?.match(value, regExp), { message, @@ -287,17 +286,17 @@ const match = ( defaultMessage: 'Value should match regExp', }); }; +/* c8 ignore stop */ +/* c8 ignore start */ const doesNotMatch = ( value: string, regExp: RegExp, message?: ParseAssertionOptions['message'] ): void => { - /* c8 ignore start */ if (typeof nodeVersion === 'number' && nodeVersion < 12) { throw new Error('doesNotMatch is available from Node.js 12 or higher'); } - /* c8 ignore stop */ parseAssertion(() => nodeAssert.doesNotMatch(value, regExp), { message, @@ -306,6 +305,7 @@ const doesNotMatch = ( defaultMessage: 'Value should not match regExp', }); }; +/* c8 ignore stop */ export const assert = Object.assign( (value: unknown, message?: ParseAssertionOptions['message']) => diff --git a/src/modules/exit.ts b/src/modules/exit.ts index 53123ab6..47a02e68 100644 --- a/src/modules/exit.ts +++ b/src/modules/exit.ts @@ -1,3 +1,5 @@ +/* c8 ignore start */ + import process from 'node:process'; import { hr } from '../helpers/hr.js'; import { Code } from '../@types/code.js'; @@ -38,3 +40,5 @@ process.on('uncaughtException', (err) => { console.log('uncaughtException', err); process.exit(1); }); + +/* c8 ignore stop */ diff --git a/src/services/run-test-file.ts b/src/services/run-test-file.ts index 9e9c5b57..ed2dc255 100644 --- a/src/services/run-test-file.ts +++ b/src/services/run-test-file.ts @@ -10,15 +10,19 @@ import { isDebug, isQuiet } from '../helpers/logs.js'; import { removeConsecutiveRepeats } from '../helpers/remove-repeats.js'; import { beforeEach, afterEach } from './each.js'; +/* c8 ignore start */ export type FileResults = { success: string[]; fail: string[]; }; +/* c8 ignore stop */ +/* c8 ignore start */ export const fileResults: FileResults = { success: [], fail: [], }; +/* c8 ignore stop */ export const runTestFile = ( filePath: string,