Skip to content

Commit

Permalink
feat(ava-xs): provide test script name to xsnap
Browse files Browse the repository at this point in the history
to make it visible via ps, for example
  • Loading branch information
dckc committed Apr 9, 2021
1 parent f686e58 commit 05f0637
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/xsnap/src/ava-xs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Promise.resolve()
osType,
readFile: fsp.readFile,
resolve: makeBundleResolve(path),
basename: path.basename,
dirname: path.dirname,
glob,
}),
Expand Down
9 changes: 6 additions & 3 deletions packages/xsnap/src/avaXS.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function isMatch(specimen, pattern) {
* bundleSource: (...args: [string, ...unknown[]]) => Promise<Bundle>,
* resolve: ResolveFn,
* dirname: typeof import('path').dirname,
* basename: typeof import('path').basename,
* }} io
* @returns {Promise<TestResults>}
*
Expand All @@ -96,7 +97,7 @@ async function runTestScript(
filename,
preamble,
{ verbose, titleMatch },
{ spawnXSnap, bundleSource, resolve, dirname },
{ spawnXSnap, bundleSource, resolve, dirname, basename },
) {
const testBundle = await bundleSource(filename, 'getExport', { externals });
let assertionStatus = { ok: 0, 'not ok': 0, SKIP: 0 };
Expand Down Expand Up @@ -159,7 +160,7 @@ async function runTestScript(
globalThis.__dirname = ${literal(dirname(testPath))};
`;

const worker = spawnXSnap({ handleCommand });
const worker = spawnXSnap({ handleCommand, name: basename(filename) });
try {
for (const script of preamble) {
await worker.evaluate(script);
Expand Down Expand Up @@ -308,12 +309,13 @@ async function avaConfig(args, options, { glob, readFile }) {
* readFile: typeof import('fs')['promises']['readFile'],
* resolve: typeof import('path').resolve,
* dirname: typeof import('path').dirname,
* basename: typeof import('path').basename,
* glob: typeof import('glob'),
* }} io
*/
export async function main(
args,
{ bundleSource, spawn, osType, readFile, resolve, dirname, glob },
{ bundleSource, spawn, osType, readFile, resolve, dirname, basename, glob },
) {
const {
files,
Expand Down Expand Up @@ -381,6 +383,7 @@ export async function main(
bundleSource,
resolve,
dirname,
basename,
},
);

Expand Down

0 comments on commit 05f0637

Please sign in to comment.