Skip to content

Commit 5321b3d

Browse files
alan-agius4clydin
authored andcommitted
test: remove redundant killAllProcesses call
`killAllProcesses` is called post test execution there it is not needed to be run after tests.
1 parent f6e8ce2 commit 5321b3d

File tree

6 files changed

+41
-56
lines changed

6 files changed

+41
-56
lines changed

tests/legacy-cli/e2e/setup/002-npm-sandbox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { mkdir, writeFile } from 'fs/promises';
22
import { join } from 'path';
3-
import { getGlobalVariable, setGlobalVariable } from '../utils/env';
3+
import { getGlobalVariable } from '../utils/env';
44

55
/**
66
* Configure npm to use a unique sandboxed environment.
Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
import { execAndWaitForOutputToMatch, killAllProcesses } from '../../utils/process';
22

33
export default async function () {
4-
try {
5-
// Execute a command with TTY force enabled and check that the prompt is shown.
6-
await execAndWaitForOutputToMatch(
7-
'ng',
8-
['deploy'],
9-
/Would you like to add a package with "deploy" capabilities/,
10-
{
11-
...process.env,
12-
NG_FORCE_TTY: '1',
13-
NG_CLI_ANALYTICS: 'false',
14-
},
15-
);
16-
17-
await killAllProcesses();
18-
19-
// Execute a command with TTY force enabled and check that the prompt is shown.
20-
await execAndWaitForOutputToMatch('ng', ['lint'], /Would you like to add ESLint now/, {
4+
// Execute a command with TTY force enabled and check that the prompt is shown.
5+
await execAndWaitForOutputToMatch(
6+
'ng',
7+
['deploy'],
8+
/Would you like to add a package with "deploy" capabilities/,
9+
{
2110
...process.env,
2211
NG_FORCE_TTY: '1',
2312
NG_CLI_ANALYTICS: 'false',
24-
});
25-
} finally {
26-
await killAllProcesses();
27-
}
13+
},
14+
);
15+
16+
await killAllProcesses();
17+
18+
// Execute a command with TTY force enabled and check that the prompt is shown.
19+
await execAndWaitForOutputToMatch('ng', ['lint'], /Would you like to add ESLint now/, {
20+
...process.env,
21+
NG_FORCE_TTY: '1',
22+
NG_CLI_ANALYTICS: 'false',
23+
});
2824
}
Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as os from 'os';
2-
import { killAllProcesses, ng } from '../../utils/process';
2+
import { ng } from '../../utils/process';
33
import { updateJsonFile } from '../../utils/project';
44

55
export default async function () {
@@ -12,18 +12,13 @@ export default async function () {
1212
}
1313
}
1414

15-
try {
16-
await updateJsonFile('angular.json', (workspaceJson) => {
17-
const appArchitect = workspaceJson.projects['test-project'].architect;
18-
appArchitect.serve.options = appArchitect.serve.options || {};
19-
appArchitect.serve.options.port = 8888;
20-
appArchitect.serve.options.host = host;
21-
});
15+
await updateJsonFile('angular.json', (workspaceJson) => {
16+
const appArchitect = workspaceJson.projects['test-project'].architect;
17+
appArchitect.serve.options = appArchitect.serve.options || {};
18+
appArchitect.serve.options.port = 8888;
19+
appArchitect.serve.options.host = host;
20+
});
2221

23-
await ng('e2e');
24-
25-
await ng('e2e', '--host', host);
26-
} finally {
27-
await killAllProcesses();
28-
}
22+
await ng('e2e');
23+
await ng('e2e', '--host', host);
2924
}

tests/legacy-cli/e2e/tests/misc/proxy-config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import { writeFile } from '../../utils/fs';
55
import fetch from 'node-fetch';
66
import { killAllProcesses, ng } from '../../utils/process';
77
import { ngServe } from '../../utils/project';
8-
import { updateJsonFile } from '../../utils/project';
9-
import { expectToFail } from '../../utils/utils';
108
import { AddressInfo } from 'net';
119
import * as assert from 'assert';
1210

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
1-
import { execAndWaitForOutputToMatch, execWithEnv, killAllProcesses } from '../../utils/process';
1+
import { execAndWaitForOutputToMatch, execWithEnv } from '../../utils/process';
22

33
export default async function () {
44
if (process.platform.startsWith('win')) {
55
// "On Windows, process.title affects the console title, but not the name of the process in the task manager."
66
// https://stackoverflow.com/questions/44756196/how-to-change-the-node-js-process-name-on-windows-10#comment96259375_44756196
7-
return Promise.resolve();
7+
return;
88
}
99

10-
try {
11-
await execAndWaitForOutputToMatch(
12-
'ng',
13-
['build', '--configuration=development', '--watch'],
14-
/./,
15-
);
10+
await execAndWaitForOutputToMatch('ng', ['build', '--configuration=development', '--watch'], /./);
1611

17-
const output = await execWithEnv('ps', ['x'], { COLUMNS: '200' });
12+
const output = await execWithEnv('ps', ['x'], { COLUMNS: '200' });
1813

19-
if (!output.stdout.match(/ng build --configuration=development --watch/)) {
20-
throw new Error('Title of the process was not properly set.');
21-
}
22-
} finally {
23-
await killAllProcesses();
14+
if (!output.stdout.match(/ng build --configuration=development --watch/)) {
15+
throw new Error('Title of the process was not properly set.');
2416
}
2517
}

tests/legacy-cli/e2e/utils/test_process.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ const testFunction: () => Promise<void> | void =
1111
throw new Error('Invalid test module.');
1212
};
1313

14-
(async () => Promise.resolve(testFunction()))()
15-
.finally(killAllProcesses)
16-
.catch((e) => {
14+
(async () => {
15+
try {
16+
await testFunction();
17+
} catch (e) {
1718
console.error(e);
1819
process.exitCode = -1;
19-
});
20+
} finally {
21+
await killAllProcesses();
22+
}
23+
})();

0 commit comments

Comments
 (0)