feat(tstest.classes.runtime.parser): Add support for all runtime token and update docs/tests; regenerate lockfile and add local settings

This commit is contained in:
2025-10-12 18:24:56 +00:00
parent d05ec21b73
commit ff6aae7159
6 changed files with 7328 additions and 4 deletions

View File

@@ -6,6 +6,7 @@
* - test.chromium.ts
* - test.node+chromium.ts
* - test.deno+bun.ts
* - test.all.ts (runs on all runtimes)
* - test.chromium.nonci.ts
*/
@@ -29,6 +30,7 @@ export interface ParserConfig {
const KNOWN_RUNTIMES: Set<string> = new Set(['node', 'chromium', 'deno', 'bun']);
const KNOWN_MODIFIERS: Set<string> = new Set(['nonci']);
const VALID_EXTENSIONS: Set<string> = new Set(['ts', 'tsx', 'mts', 'cts']);
const ALL_RUNTIMES: Runtime[] = ['node', 'chromium', 'deno', 'bun'];
// Legacy mappings for backwards compatibility
const LEGACY_RUNTIME_MAP: Record<string, Runtime[]> = {
@@ -102,9 +104,12 @@ export function parseTestFilename(
const runtimeCandidates = token.split('+').map(r => r.trim()).filter(Boolean);
const validRuntimes: Runtime[] = [];
const invalidRuntimes: string[] = [];
let hasAllKeyword = false;
for (const candidate of runtimeCandidates) {
if (KNOWN_RUNTIMES.has(candidate)) {
if (candidate === 'all') {
hasAllKeyword = true;
} else if (KNOWN_RUNTIMES.has(candidate)) {
// Dedupe: only add if not already in list
if (!validRuntimes.includes(candidate as Runtime)) {
validRuntimes.push(candidate as Runtime);
@@ -114,11 +119,18 @@ export function parseTestFilename(
}
}
// If 'all' keyword is present, expand to all runtimes
if (hasAllKeyword) {
runtimes = [...ALL_RUNTIMES];
runtimeTokenIndex = i;
break;
}
if (invalidRuntimes.length > 0) {
if (strictUnknownRuntime) {
throw new Error(
`Unknown runtime(s) in "${fileName}": ${invalidRuntimes.join(', ')}. ` +
`Valid runtimes: ${Array.from(KNOWN_RUNTIMES).join(', ')}`
`Valid runtimes: ${Array.from(KNOWN_RUNTIMES).join(', ')}, all`
);
} else {
console.warn(
@@ -138,6 +150,13 @@ export function parseTestFilename(
}
}
// Check if this is the 'all' keyword (expands to all runtimes)
if (token === 'all') {
runtimes = [...ALL_RUNTIMES];
runtimeTokenIndex = i;
break;
}
// Check if this is a single runtime token
if (KNOWN_RUNTIMES.has(token)) {
runtimes = [token as Runtime];