feat(testfile-directives): Add per-test file directives to control runtime permissions and flags (Deno, Node, Bun, Chromium)
This commit is contained in:
@@ -10,6 +10,20 @@ import { TapParser } from './tstest.classes.tap.parser.js';
|
||||
import { TsTestLogger } from './tstest.logging.js';
|
||||
import type { Runtime } from './tstest.classes.runtime.parser.js';
|
||||
|
||||
/**
|
||||
* Default Deno permissions used when no directives override them.
|
||||
*/
|
||||
export const DENO_DEFAULT_PERMISSIONS = [
|
||||
'--allow-read',
|
||||
'--allow-env',
|
||||
'--allow-net',
|
||||
'--allow-write',
|
||||
'--allow-sys',
|
||||
'--allow-import',
|
||||
'--node-modules-dir',
|
||||
'--sloppy-imports',
|
||||
];
|
||||
|
||||
/**
|
||||
* Deno runtime adapter
|
||||
* Executes tests using the Deno runtime
|
||||
@@ -45,16 +59,7 @@ export class DenoRuntimeAdapter extends RuntimeAdapter {
|
||||
return {
|
||||
...super.getDefaultOptions(),
|
||||
configPath,
|
||||
permissions: [
|
||||
'--allow-read',
|
||||
'--allow-env',
|
||||
'--allow-net',
|
||||
'--allow-write',
|
||||
'--allow-sys', // Allow system info access
|
||||
'--allow-import', // Allow npm/node imports
|
||||
'--node-modules-dir', // Enable Node.js compatibility mode
|
||||
'--sloppy-imports', // Allow .js imports to resolve to .ts files
|
||||
],
|
||||
permissions: [...DENO_DEFAULT_PERMISSIONS],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -102,16 +107,7 @@ export class DenoRuntimeAdapter extends RuntimeAdapter {
|
||||
const args: string[] = ['run'];
|
||||
|
||||
// Add permissions
|
||||
const permissions = mergedOptions.permissions || [
|
||||
'--allow-read',
|
||||
'--allow-env',
|
||||
'--allow-net',
|
||||
'--allow-write',
|
||||
'--allow-sys',
|
||||
'--allow-import',
|
||||
'--node-modules-dir',
|
||||
'--sloppy-imports',
|
||||
];
|
||||
const permissions = mergedOptions.permissions || [...DENO_DEFAULT_PERMISSIONS];
|
||||
args.push(...permissions);
|
||||
|
||||
// Add config file if specified
|
||||
|
||||
Reference in New Issue
Block a user