Skip to content

Commit 569f85d

Browse files
author
Luca Forstner
committed
Exit on failure of commands
1 parent 908b2b9 commit 569f85d

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

packages/e2e-tests/run.ts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,12 @@ function printCIErrorMessage(message: string): void {
3636
}
3737

3838
groupCIOutput('Test Registry Setup', () => {
39-
try {
40-
// Stop test registry container (Verdaccio) if it was already running
41-
childProcess.spawnSync('docker', ['stop', TEST_REGISTRY_CONTAINER_NAME], { stdio: 'ignore' });
42-
console.log('Stopped previously running test registry');
43-
} catch (e) {
44-
// Don't throw if container wasn't running
45-
}
39+
// Stop test registry container (Verdaccio) if it was already running
40+
childProcess.spawnSync('docker', ['stop', TEST_REGISTRY_CONTAINER_NAME], { stdio: 'ignore' });
41+
console.log('Stopped previously running test registry');
4642

4743
// Start test registry (Verdaccio)
48-
childProcess.spawnSync(
44+
const startRegistryProcessResult = childProcess.spawnSync(
4945
'docker',
5046
[
5147
'run',
@@ -62,8 +58,12 @@ groupCIOutput('Test Registry Setup', () => {
6258
{ encoding: 'utf8', stdio: 'inherit' },
6359
);
6460

61+
if (startRegistryProcessResult.status !== 0) {
62+
process.exit(1);
63+
}
64+
6565
// Build container image that is uploading our packages to fake registry with specific Node.js/npm version
66-
childProcess.spawnSync(
66+
const buildPublishImageProcessResult = childProcess.spawnSync(
6767
'docker',
6868
[
6969
'build',
@@ -80,8 +80,12 @@ groupCIOutput('Test Registry Setup', () => {
8080
},
8181
);
8282

83+
if (buildPublishImageProcessResult.status !== 0) {
84+
process.exit(1);
85+
}
86+
8387
// Run container that uploads our packages to fake registry
84-
childProcess.spawnSync(
88+
const publishImageContainerRunProcess = childProcess.spawnSync(
8589
'docker',
8690
[
8791
'run',
@@ -97,6 +101,10 @@ groupCIOutput('Test Registry Setup', () => {
97101
stdio: 'inherit',
98102
},
99103
);
104+
105+
if (publishImageContainerRunProcess.status !== 0) {
106+
process.exit(1);
107+
}
100108
});
101109

102110
groupCIOutput('Run E2E Test Suites', () => {
@@ -119,11 +127,15 @@ groupCIOutput('Run E2E Test Suites', () => {
119127
if (recipe.buildCommand) {
120128
console.log(`Running E2E test build command for test application "${recipe.testApplicationName}"`);
121129
const [buildCommand, ...buildCommandArgs] = recipe.buildCommand.split(' ');
122-
childProcess.spawnSync(buildCommand, buildCommandArgs, {
130+
const buildCommandProcess = childProcess.spawnSync(buildCommand, buildCommandArgs, {
123131
cwd: path.dirname(recipePath),
124132
encoding: 'utf8',
125133
stdio: 'inherit',
126134
});
135+
136+
if (buildCommandProcess.status !== 0) {
137+
process.exit(1);
138+
}
127139
}
128140

129141
type TestResult = {

0 commit comments

Comments
 (0)