Skip to content

Commit 0390c53

Browse files
author
Luca Forstner
committed
Improve failed build reporting
1 parent 6bce0de commit 0390c53

File tree

1 file changed

+42
-15
lines changed

1 file changed

+42
-15
lines changed

packages/e2e-tests/run.ts

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,21 @@ groupCIOutput('Test Registry Setup', () => {
109109

110110
const recipePaths = glob.sync(`${__dirname}/test-applications/*/test-recipe.json`, { absolute: true });
111111

112-
let someTestFailed = false;
112+
let processShouldExitWithError = false;
113113

114-
const recipeResults = recipePaths.map(recipePath => {
114+
type TestResult = {
115+
testName: string;
116+
result: 'PASS' | 'FAIL' | 'TIMEOUT';
117+
};
118+
119+
type RecipeResult = {
120+
testApplicationName: string;
121+
testApplicationPath: string;
122+
buildFailed: boolean;
123+
testResults: TestResult[];
124+
};
125+
126+
const recipeResults: RecipeResult[] = recipePaths.map(recipePath => {
115127
type Recipe = {
116128
testApplicationName: string;
117129
buildCommand?: string;
@@ -137,15 +149,21 @@ const recipeResults = recipePaths.map(recipePath => {
137149
console.log(buildCommandProcess.stderr.replace(/^/gm, '[BUILD OUTPUT] '));
138150

139151
if (buildCommandProcess.status !== 0) {
140-
process.exit(1);
152+
processShouldExitWithError = true;
153+
154+
printCIErrorMessage(
155+
`Build command in test application "${recipe.testApplicationName}" (${path.dirname(recipePath)}) failed!`,
156+
);
157+
158+
return {
159+
testApplicationName: recipe.testApplicationName,
160+
testApplicationPath: recipePath,
161+
buildFailed: true,
162+
testResults: [],
163+
};
141164
}
142165
}
143166

144-
type TestResult = {
145-
testName: string;
146-
result: 'PASS' | 'FAIL' | 'TIMEOUT';
147-
};
148-
149167
const testResults: TestResult[] = recipe.tests.map(test => {
150168
console.log(
151169
`Running E2E test command for test application "${recipe.testApplicationName}", test "${test.testName}"`,
@@ -165,7 +183,7 @@ const recipeResults = recipePaths.map(recipePath => {
165183
const error: undefined | (Error & { code?: string }) = testProcessResult.error;
166184

167185
if (error?.code === 'ETIMEDOUT') {
168-
someTestFailed = true;
186+
processShouldExitWithError = true;
169187
printCIErrorMessage(
170188
`Test "${test.testName}" in test application "${recipe.testApplicationName}" (${path.dirname(
171189
recipePath,
@@ -176,7 +194,7 @@ const recipeResults = recipePaths.map(recipePath => {
176194
result: 'TIMEOUT',
177195
};
178196
} else if (testProcessResult.status !== 0) {
179-
someTestFailed = true;
197+
processShouldExitWithError = true;
180198
printCIErrorMessage(
181199
`Test "${test.testName}" in test application "${recipe.testApplicationName}" (${path.dirname(
182200
recipePath,
@@ -202,6 +220,7 @@ const recipeResults = recipePaths.map(recipePath => {
202220
return {
203221
testApplicationName: recipe.testApplicationName,
204222
testApplicationPath: recipePath,
223+
buildFailed: false,
205224
testResults,
206225
};
207226
});
@@ -210,10 +229,18 @@ console.log('--------------------------------------');
210229
console.log('Test Result Summary:');
211230

212231
recipeResults.forEach(recipeResult => {
213-
console.log(`● ${recipeResult.testApplicationName} (${path.dirname(recipeResult.testApplicationPath)})`);
214-
recipeResult.testResults.forEach(testResult => {
215-
console.log(` ● ${testResult.result.padEnd(7, ' ')} ${testResult.testName}`);
216-
});
232+
if (recipeResult.buildFailed) {
233+
console.log(
234+
`● BUILD FAILED - ${recipeResult.testApplicationName} (${path.dirname(recipeResult.testApplicationPath)})`,
235+
);
236+
} else {
237+
console.log(
238+
`● BUILD SUCCEEDED - ${recipeResult.testApplicationName} (${path.dirname(recipeResult.testApplicationPath)})`,
239+
);
240+
recipeResult.testResults.forEach(testResult => {
241+
console.log(` ● ${testResult.result.padEnd(7, ' ')} ${testResult.testName}`);
242+
});
243+
}
217244
});
218245

219246
groupCIOutput('Cleanup', () => {
@@ -222,7 +249,7 @@ groupCIOutput('Cleanup', () => {
222249
console.log('Successfully stopped test registry container'); // Output from command above is not good so we `ignore` it and emit our own
223250
});
224251

225-
if (someTestFailed) {
252+
if (processShouldExitWithError) {
226253
console.log('Not all tests succeeded.');
227254
process.exit(1);
228255
} else {

0 commit comments

Comments
 (0)