(entry: string, ...args: any[])
| 441 | * registry (not the test runner or standard global node_modules). |
| 442 | */ |
| 443 | export async function launchTestProcess(entry: string, ...args: any[]): Promise<void> { |
| 444 | // NOTE: do NOT use the bazel TEST_TMPDIR. When sandboxing is not enabled the |
| 445 | // TEST_TMPDIR is not sandboxed and has symlinks into the src dir in a |
| 446 | // parent directory. Symlinks into the src dir will include package.json, |
| 447 | // .git and other files/folders that may effect e2e tests. |
| 448 | |
| 449 | const tempRoot: string = getGlobalVariable('tmp-root'); |
| 450 | const TEMP = process.env.TEMP ?? process.env.TMPDIR ?? tempRoot; |
| 451 | |
| 452 | // Extract explicit environment variables for the test process. |
| 453 | const env: NodeJS.ProcessEnv = { |
| 454 | TEMP, |
| 455 | TMPDIR: TEMP, |
| 456 | HOME: TEMP, |
| 457 | |
| 458 | // Use BAZEL_TARGET as a metadata variable to show it is a |
| 459 | // process managed by bazel |
| 460 | BAZEL_TARGET: process.env.BAZEL_TARGET, |
| 461 | |
| 462 | ...extractNpmEnv(), |
| 463 | ...extractCIAndInfraEnv(), |
| 464 | ...extractNgEnv(), |
| 465 | ...getGlobalVariablesEnv(), |
| 466 | }; |
| 467 | |
| 468 | // Only include paths within the sandboxed test environment or external |
| 469 | // non angular-cli paths such as /usr/bin for generic commands. |
| 470 | env.PATH = process.env |
| 471 | .PATH!.split(delimiter) |
| 472 | .filter((p) => p.startsWith(tempRoot) || p.startsWith(TEMP) || !p.includes('angular-cli')) |
| 473 | .join(delimiter); |
| 474 | |
| 475 | const testProcessArgs = [ |
| 476 | // Note: `__dirname` is the bundle directory here. |
| 477 | resolve(__dirname, 'e2e/utils/test_process.js'), |
| 478 | entry, |
| 479 | ...args, |
| 480 | ]; |
| 481 | |
| 482 | return new Promise<void>((resolve, reject) => { |
| 483 | spawn(process.execPath, testProcessArgs, { |
| 484 | stdio: 'inherit', |
| 485 | env, |
| 486 | }) |
| 487 | .on('close', (code) => { |
| 488 | if (!code) { |
| 489 | resolve(); |
| 490 | return; |
| 491 | } |
| 492 | |
| 493 | reject(`Process error - "${testProcessArgs}`); |
| 494 | }) |
| 495 | .on('error', (err) => { |
| 496 | reject(`Process exit error - "${testProcessArgs}]\n\n${err}`); |
| 497 | }); |
| 498 | }); |
| 499 | } |
no test coverage detected