Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: drop platform option #894

Merged
merged 7 commits into from
Dec 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: remove --platform, --node, --bun and deno
wellwelwel committed Dec 11, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit e2f059fd099f6e65a0de5ca3ce066ccafb115e41
4 changes: 2 additions & 2 deletions benchmark/benchmark.sh
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ echo '```'
# Not included in results.json
hyperfine -i --warmup 3 \
--command-name 'Node.js' 'node --test "./test/node/**.spec.js"' \
--command-name "🐷 Poku ($SHORT_SHA)" '../lib/bin/index.js --node ./test/poku' |
--command-name "🐷 Poku ($SHORT_SHA)" '../lib/bin/index.js ./test/poku' |
awk '/Summary/ {flag=1} flag'

echo '```\n'
@@ -31,7 +31,7 @@ echo '```'
# Not included in results.json
hyperfine -i --warmup 3 \
--command-name 'Bun' 'bun test "test/bun/"' \
--command-name "🐷 Poku ($SHORT_SHA)" '../lib/bin/index.js --bun ./test/poku' |
--command-name "🐷 Poku ($SHORT_SHA)" 'bun ../lib/bin/index.js ./test/poku' |
awk '/Summary/ {flag=1} flag'

echo '```\n'
8 changes: 1 addition & 7 deletions src/@types/background-process.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Runner } from './runner.js';
import type { Configs } from './poku.js';

type BackgroundProcessOptions = {
/**
@@ -40,11 +39,6 @@ export type StartScriptOptions = {
readonly runner?: Runner;
} & BackgroundProcessOptions;

export type StartServiceOptions = {
/**
* By default, Poku will try to identify the actual platform, but you can specify it manually
*/
readonly platform?: Configs['platform'];
} & BackgroundProcessOptions;
export type StartServiceOptions = BackgroundProcessOptions;

export type End = (port?: number | number[]) => Promise<void>;
6 changes: 0 additions & 6 deletions src/@types/poku.ts
Original file line number Diff line number Diff line change
@@ -35,12 +35,6 @@ export type Configs = {
* @default false
*/
sequential?: boolean;
/**
* Determines the platform for test execution.
*
* @default 'node'
*/
platform?: Runtime;
/**
* Stops the tests at the first failure.
*
4 changes: 0 additions & 4 deletions src/bin/enforce.ts
Original file line number Diff line number Diff line change
@@ -4,11 +4,9 @@ import { format } from '../services/format.js';

export const checkFlags = () => {
const allowedFlags = new Set([
'--bun',
'--concurrency',
'--config',
'--debug',
'--deno',
'--denoAllow',
'--denoCjs',
'--denoDeny',
@@ -20,9 +18,7 @@ export const checkFlags = () => {
'--killPid',
'--killPort',
'--killRange',
'--node',
'--only',
'--platform',
'--quiet',
'--sequential',
'--watch',
10 changes: 0 additions & 10 deletions src/bin/help.ts
Original file line number Diff line number Diff line change
@@ -10,11 +10,9 @@ const options = i('[--options]');
const paths = i('[paths]');
const bullet = d('●');
const summary: [string, string][] = [
['--bun', 'Enforce tests to run through Bun.'],
['--concurrency', 'Limit the number of tests running concurrently.'],
['--config, -c', 'Specify a configuration file.'],
['--debug, -d', 'Show detailed logs.'],
['--deno', 'Enforce tests to run through Deno.'],
['--denoAllow', 'Allow permissions for Deno.'],
['--denoCjs', 'Support CommonJS in Deno.'],
['--denoDeny', 'Deny permissions for Deno.'],
@@ -28,9 +26,7 @@ const summary: [string, string][] = [
['--killPort', 'Terminate the specified ports.'],
['--killRange', 'Terminate the specified port ranges.'],
['--listFiles', 'Display all the files returned in the terminal.'],
['--node', 'Enforce tests to run through Node.js.'],
['--only', 'Enable selective execution of tests.'],
['--platform', 'Enforce tests to run through a platform.'],
['--quiet, -q', 'Run tests with no logs.'],
['--sequential', 'Run tests files sequentially.'],
['--version, -v', "Show Poku's installed version."],
@@ -49,12 +45,6 @@ const header = `
poku ${options} ${paths}
poku ${paths} ${options}

› ${u(b('Ensuring platforms:'))}

poku ${b('--node')} ${options} ${paths}
poku ${b('--bun')} ${options} ${paths}
poku ${b('--deno')} ${options} ${paths}

› ${u(b('Tips:'))}

${bullet} All CLI options use camel case pattern (e.g.: ${b('--failFast')}).
11 changes: 0 additions & 11 deletions src/bin/index.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ import type { Configs } from '../@types/poku.js';
import { escapeRegExp } from '../modules/helpers/list-files.js';
import { getArg, getPaths, hasArg, argToArray } from '../parsers/get-arg.js';
import { states } from '../configs/files.js';
import { platformIsValid } from '../parsers/get-runtime.js';
import { format } from '../services/format.js';
import { kill } from '../modules/helpers/kill.js';
import { envFile } from '../modules/helpers/env.js';
@@ -36,7 +35,6 @@ import { getConfigs } from '../parsers/options.js';
(defaultConfigs?.include
? Array.prototype.concat(defaultConfigs?.include)
: ['.']);
const platform = getArg('platform');
const filter = getArg('filter') ?? defaultConfigs?.filter;
const exclude = getArg('exclude') ?? defaultConfigs?.exclude;
const killPort = getArg('killPort');
@@ -144,15 +142,6 @@ import { getConfigs } from '../parsers/options.js';
}

const options: Configs = {
/* c8 ignore next 8 */ // Varies Platform
platform: (() => {
if (platformIsValid(platform)) return platform;
if (hasArg('node')) return 'node';
if (hasArg('bun')) return 'bun';
if (hasArg('deno')) return 'deno';
if (platformIsValid(defaultConfigs?.platform))
return defaultConfigs.platform;
})(),
filter:
typeof filter === 'string' ? new RegExp(escapeRegExp(filter)) : filter,
exclude:
9 changes: 0 additions & 9 deletions src/builders/assert.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { ProcessAssertionOptions } from '../@types/assert.js';
import type assert from 'node:assert';
import type { AssertPredicate } from 'node:assert';
import { nodeVersion } from '../parsers/get-runtime.js';
import { processAssert, processAsyncAssert } from '../services/assert.js';

export const createAssert = (nodeAssert: typeof assert) => {
@@ -244,10 +243,6 @@ export const createAssert = (nodeAssert: typeof assert) => {
regExp: RegExp,
message?: ProcessAssertionOptions['message']
): void => {
/* c8 ignore next 2 */ // Platform version
if (typeof nodeVersion === 'number' && nodeVersion < 12)
throw new Error('match is available from Node.js 12 or higher');

processAssert(() => nodeAssert?.match(value, regExp), {
message,
actual: 'Value',
@@ -261,10 +256,6 @@ export const createAssert = (nodeAssert: typeof assert) => {
regExp: RegExp,
message?: ProcessAssertionOptions['message']
): void => {
/* c8 ignore next 2 */ // Platform version
if (typeof nodeVersion === 'number' && nodeVersion < 12)
throw new Error('doesNotMatch is available from Node.js 12 or higher');

processAssert(() => nodeAssert.doesNotMatch(value, regExp), {
message,
actual: 'Value',
2 changes: 1 addition & 1 deletion src/modules/helpers/create-service.ts
Original file line number Diff line number Diff line change
@@ -147,7 +147,7 @@ export const startService = async (
file: string,
options?: StartServiceOptions
): Promise<{ end: End }> => {
const runtimeOptions = runner(file, { platform: options?.platform });
const runtimeOptions = runner(file);
const runtime = runtimeOptions.shift()!;
const runtimeArgs = [...runtimeOptions, file];

8 changes: 4 additions & 4 deletions src/parsers/assert.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { fromEntries, entries } from '../polyfills/object.js';

const recurse = (value: unknown): unknown => {
if (
typeof value === 'undefined' ||
@@ -11,9 +9,11 @@ const recurse = (value: unknown): unknown => {
return String(value);
if (Array.isArray(value)) return value.map(recurse);
if (value instanceof Set) return Array.from(value).map(recurse);
if (value instanceof Map) return recurse(fromEntries(value));
if (value instanceof Map) return recurse(Object.fromEntries(value));
if (value !== null && typeof value === 'object')
return fromEntries(entries(value).map(([key, val]) => [key, recurse(val)]));
return Object.fromEntries(
Object.entries(value).map(([key, val]) => [key, recurse(val)])
);

return value;
};
12 changes: 2 additions & 10 deletions src/parsers/get-runtime.ts
Original file line number Diff line number Diff line change
@@ -6,16 +6,8 @@ declare const Bun: unknown;

const regex = /v(\d+)\./;

export const supportedPlatforms: readonly Runtime[] = ['node', 'bun', 'deno'];

export const platformIsValid = (
platform: unknown
): platform is (typeof supportedPlatforms)[number] =>
typeof platform === 'string' &&
supportedPlatforms.indexOf(platform as Runtime) > -1;

export const getRuntime = (): (typeof supportedPlatforms)[number] => {
if (platformIsValid(env.POKU_RUNTIME)) return env.POKU_RUNTIME;
export const getRuntime = (): Runtime => {
if (env.POKU_RUNTIME) return env.POKU_RUNTIME as Runtime;
if (typeof Deno !== 'undefined') return 'deno';
if (typeof Bun !== 'undefined') return 'bun';

32 changes: 0 additions & 32 deletions src/polyfills/object.ts

This file was deleted.

14 changes: 4 additions & 10 deletions test/c8.test.ts
Original file line number Diff line number Diff line change
@@ -14,9 +14,7 @@ test(async () => {

await describe('CLI', async () => {
await it('Just Touch', async () => {
const results = await inspectPoku(
'--platform=node test/integration/import.test.ts'
);
const results = await inspectPoku('test/integration/import.test.ts');

console.log(results.stdout);
console.log(results.stderr);
@@ -25,7 +23,7 @@ test(async () => {
});

await it('FILTER Env', async () => {
const results = await inspectPoku('--platform=node test/integration', {
const results = await inspectPoku('test/integration', {
env: { ...process.env, FILTER: 'import' },
});

@@ -38,8 +36,8 @@ test(async () => {
await it('Options (Just Touch)', async () => {
const results = await inspectPoku(
isWindows
? '--concurrency=4 --platform=node --failFast --debug --exclude=".bak" --killPort=4000 --killRange="4000-4001" test/integration/import.test.ts --filter=".test.|.spec."'
: '--concurrency=4 --platform=node --failFast --debug --exclude=.bak --killPort=4000 --killRange=4000-4001 test/integration/import.test.ts --filter=.test.|.spec.'
? '--concurrency=4 --failFast --debug --exclude=".bak" --killPort=4000 --killRange="4000-4001" test/integration/import.test.ts --filter=".test.|.spec."'
: '--concurrency=4 --failFast --debug --exclude=.bak --killPort=4000 --killRange=4000-4001 test/integration/import.test.ts --filter=.test.|.spec.'
);

console.log(results.stdout);
@@ -52,7 +50,6 @@ test(async () => {
await describe('API', async () => {
await it('Single Input', async () => {
const exitCode = await poku('test/integration/import.test.ts', {
platform: 'node',
noExit: true,
});

@@ -61,7 +58,6 @@ test(async () => {

await it('Unit (Exclude as Regex)', async () => {
const exitCode = await poku('test/unit', {
platform: 'node',
exclude: /watch|map-tests/,
noExit: true,
});
@@ -71,7 +67,6 @@ test(async () => {

await it('Unit (Exclude as Array of Regex)', async () => {
const exitCode = await poku('test/unit', {
platform: 'node',
concurrency: 4,
exclude: [/watch/, /map-tests/],
noExit: true,
@@ -84,7 +79,6 @@ test(async () => {
const exitCode = await poku(
['test/unit', 'test/integration', 'test/e2e'],
{
platform: 'node',
debug: true,
filter: /\.(test|spec)\./,
failFast: true,
5 changes: 1 addition & 4 deletions test/ci.test.ts
Original file line number Diff line number Diff line change
@@ -11,12 +11,9 @@ test(async () => {
const result = await poku(['./test/compatibility'], {
debug: true,
noExit: true,
platform: 'bun',
});

if (result === 0) {
await compose.down();
}
if (result === 0) await compose.down();

exit(result);
});
6 changes: 0 additions & 6 deletions test/e2e/final-results.test.ts
Original file line number Diff line number Diff line change
@@ -2,12 +2,6 @@ import { describe } from '../../src/modules/helpers/describe.js';
import { it } from '../../src/modules/helpers/it/core.js';
import { assert } from '../../src/modules/essentials/assert.js';
import { inspectPoku } from '../__utils__/capture-cli.test.js';
import { nodeVersion } from '../../src/parsers/get-runtime.js';
import { skip } from '../../src/modules/helpers/skip.js';

if (nodeVersion && nodeVersion < 12) {
skip();
}

describe('Final Results', async () => {
await it('Skip', async () => {
6 changes: 3 additions & 3 deletions test/e2e/runners.test.ts
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ describe('Test Runtimes/Platforms + Extensions', async () => {
hasNode &&
(await it('Node.js', async () => {
const output = await inspectCLI(
'npx tsx src/bin/index.ts --platform=node test/__fixtures__/e2e/extensions -d'
'npx tsx src/bin/index.ts test/__fixtures__/e2e/extensions -d'
);

if (output.exitCode !== 0) {
@@ -56,7 +56,7 @@ describe('Test Runtimes/Platforms + Extensions', async () => {
hasBun &&
(await it('Bun', async () => {
const output = await inspectCLI(
'bun src/bin/index.ts --platform=bun test/__fixtures__/e2e/extensions -d'
'bun src/bin/index.ts test/__fixtures__/e2e/extensions -d'
);

if (output.exitCode !== 0) {
@@ -72,7 +72,7 @@ describe('Test Runtimes/Platforms + Extensions', async () => {
hasDeno &&
(await it('Deno', async () => {
const output = await inspectCLI(
'deno run --unstable-sloppy-imports --allow-read --allow-env --allow-run src/bin/index.ts --platform=deno test/__fixtures__/e2e/extensions -d --exclude=.cts'
'deno run --unstable-sloppy-imports --allow-read --allow-env --allow-run src/bin/index.ts test/__fixtures__/e2e/extensions -d --exclude=.cts'
);

if (output.exitCode !== 0) {
9 changes: 2 additions & 7 deletions test/e2e/watch.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { getRuntime, nodeVersion } from '../../src/parsers/get-runtime.js';
import { getRuntime } from '../../src/parsers/get-runtime.js';
import { isBuild, watchCLI } from '../__utils__/capture-cli.test.js';
import { isWindows } from '../../src/parsers/get-runner.js';
import { skip } from '../../src/modules/helpers/skip.js';

if (
isBuild ||
(nodeVersion && nodeVersion < 10) ||
getRuntime() !== 'node' ||
isWindows
) {
if (isBuild || getRuntime() !== 'node' || isWindows) {
skip();
}

Loading