Skip to content

Commit 1fbc284

Browse files
committed
test(runtime-host): exercise Windows process ownership seam
1 parent 2a9511b commit 1fbc284

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

scripts/smoke-release-cli-package.mjs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ async function smokeRuntimeHostPeerProtocol({ packageRoot, cliEntrypoint, root }
264264
const addon = require(nativePath);
265265
await smokeWindowsTaskScheduler(
266266
windowsLifecycle.createWindowsRuntimeHostLifecycleProvider,
267-
peerArtifact.resolveRuntimeHostNativePath,
268267
cliEntrypoint,
269268
join(root, 'windows task & % 生命周期'),
270269
);
@@ -414,7 +413,7 @@ async function smokeRuntimeHostPeerProtocol({ packageRoot, cliEntrypoint, root }
414413
}
415414
}
416415

417-
async function smokeWindowsTaskScheduler(createProvider, resolveNativePath, cliEntrypoint, root) {
416+
async function smokeWindowsTaskScheduler(createProvider, cliEntrypoint, root) {
418417
if (process.platform !== 'win32') return;
419418
mkdirSync(root, { recursive: true });
420419
const rootId = createHash('sha256').update(root).digest('hex');
@@ -427,10 +426,9 @@ async function smokeWindowsTaskScheduler(createProvider, resolveNativePath, cliE
427426
recursive: true,
428427
});
429428
const managedCliEntrypoint = join(managedPackageRoot, 'dist', basename(cliEntrypoint));
430-
const managedNativePath = await resolveNativePath(managedCliEntrypoint);
431429
const scriptPath = join(
432430
dirname(managedCliEntrypoint),
433-
'runtime-host-windows-supervisor-smoke.cjs',
431+
'runtime-host-windows-supervisor-smoke.mjs',
434432
);
435433
const controllerRunnerPath = join(dirname(cliEntrypoint), 'runtime-host-windows-task-runner.js');
436434
const disabledControllerRunnerPath = `${controllerRunnerPath}.disabled`;
@@ -440,11 +438,13 @@ async function smokeWindowsTaskScheduler(createProvider, resolveNativePath, cliE
440438
writeFileSync(
441439
scriptPath,
442440
[
443-
"const { spawn } = require('node:child_process');",
444-
"const { writeFileSync } = require('node:fs');",
445-
'const [runtimeHost, serve, nativePath, expected, readyPath] = process.argv.slice(2);',
441+
"import { spawn } from 'node:child_process';",
442+
"import { writeFileSync } from 'node:fs';",
443+
"import { fileURLToPath } from 'node:url';",
444+
'const [runtimeHost, serve, expected, readyPath] = process.argv.slice(2);',
446445
'try {',
447-
' require(nativePath).ownCurrentProcessTree();',
446+
" const { ownWindowsRuntimeHostProcessTree } = await import('./runtime-host-windows-service.js');",
447+
' await ownWindowsRuntimeHostProcessTree(fileURLToPath(import.meta.url));',
448448
" if (runtimeHost !== 'runtime-host' || serve !== 'serve') process.exit(90);",
449449
` if (expected !== ${JSON.stringify(hostileArgument)}) process.exit(91);`,
450450
" const child = spawn(process.execPath, ['-e', 'setInterval(() => {}, 1000)'], { detached: true, stdio: 'ignore' });",
@@ -465,7 +465,6 @@ async function smokeWindowsTaskScheduler(createProvider, resolveNativePath, cliE
465465
scriptPath,
466466
'runtime-host',
467467
'serve',
468-
managedNativePath,
469468
hostileArgument,
470469
readyPath,
471470
];

0 commit comments

Comments
 (0)