Skip to content

Commit

Permalink
chore: remove --platform, --node, --bun and deno
Browse files Browse the repository at this point in the history
  • Loading branch information
wellwelwel committed Dec 11, 2024
1 parent 17ea351 commit e2f059f
Show file tree
Hide file tree
Showing 24 changed files with 509 additions and 642 deletions.
4 changes: 2 additions & 2 deletions benchmark/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down
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 = {
/**
Expand Down Expand Up @@ -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
Expand Up @@ -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.
*
Expand Down
4 changes: 0 additions & 4 deletions src/bin/enforce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -20,9 +18,7 @@ export const checkFlags = () => {
'--killPid',
'--killPort',
'--killRange',
'--node',
'--only',
'--platform',
'--quiet',
'--sequential',
'--watch',
Expand Down
10 changes: 0 additions & 10 deletions src/bin/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.'],
Expand All @@ -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."],
Expand All @@ -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')}).
Expand Down
11 changes: 0 additions & 11 deletions src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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:
Expand Down
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) => {
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/modules/helpers/create-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
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' ||
Expand All @@ -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;
};
Expand Down
12 changes: 2 additions & 10 deletions src/parsers/get-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
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
Expand Up @@ -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);
Expand All @@ -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' },
});

Expand All @@ -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);
Expand All @@ -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,
});

Expand All @@ -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,
});
Expand All @@ -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,
Expand All @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions test/ci.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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 () => {
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/runners.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
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();
}

Expand Down
Loading

0 comments on commit e2f059f

Please sign in to comment.