Skip to content

Commit 44cbedd

Browse files
committed
fixup! test: use TEST_TMPDIR as fallback for E2E temporary directory
1 parent f88256d commit 44cbedd

3 files changed

Lines changed: 8 additions & 13 deletions

File tree

‎tests/e2e/tests/misc/create-angular.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { equal } from 'node:assert';
2-
import { join, resolve } from 'node:path';
2+
import { join } from 'node:path';
33
import { expectFileToExist, readFile, rimraf } from '../../utils/fs';
44
import { getActivePackageManager } from '../../utils/packages';
55
import { silentBun, silentNpm, silentPnpm, silentYarn } from '../../utils/process';
6+
import { mktempd } from '../../utils/utils';
67

78
export default async function () {
89
const currentDirectory = process.cwd();
9-
const newDirectory = resolve('../');
10+
const newDirectory = await mktempd('create-angular-test-');
1011
const projectName = 'test-project-create';
1112

1213
try {

‎tests/e2e/utils/process.ts‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -441,19 +441,13 @@ export function silentGit(...args: string[]) {
441441
* registry (not the test runner or standard global node_modules).
442442
*/
443443
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-
449444
const tempRoot: string = getGlobalVariable('tmp-root');
450-
const TEMP = process.env.TEMP ?? process.env.TMPDIR ?? tempRoot;
451445

452446
// Extract explicit environment variables for the test process.
453447
const env: NodeJS.ProcessEnv = {
454-
TEMP,
455-
TMPDIR: TEMP,
456-
HOME: TEMP,
448+
TEMP: tempRoot,
449+
TMPDIR: tempRoot,
450+
HOME: tempRoot,
457451

458452
// Use BAZEL_TARGET as a metadata variable to show it is a
459453
// process managed by bazel
@@ -469,7 +463,7 @@ export async function launchTestProcess(entry: string, ...args: any[]): Promise<
469463
// non angular-cli paths such as /usr/bin for generic commands.
470464
env.PATH = process.env
471465
.PATH!.split(delimiter)
472-
.filter((p) => p.startsWith(tempRoot) || p.startsWith(TEMP) || !p.includes('angular-cli'))
466+
.filter((p) => p.startsWith(tempRoot) || !p.includes('angular-cli'))
473467
.join(delimiter);
474468

475469
const testProcessArgs = [

‎tests/e2e/utils/utils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function expectToFail(fn: () => Promise<any>, errorMessage?: string): Pro
2121
export async function mktempd(prefix: string, tempRoot?: string): Promise<string> {
2222
return realpath(
2323
await mkdtemp(
24-
path.join(tempRoot ?? process.env.E2E_TEMP ?? process.env.TEST_TMPDIR ?? tmpdir(), prefix),
24+
path.join(tempRoot || process.env.E2E_TEMP || process.env.TEST_TMPDIR || tmpdir(), prefix),
2525
),
2626
);
2727
}

0 commit comments

Comments
 (0)