@@ -107,108 +107,109 @@ groupCIOutput('Test Registry Setup', () => {
107
107
}
108
108
} ) ;
109
109
110
- groupCIOutput ( 'Run E2E Test Suites' , ( ) => {
111
- // TODO: Run e2e tests here
112
- const recipePaths = glob . sync ( `${ __dirname } /test-applications/*/test-recipe.json` , { absolute : true } ) ;
113
-
114
- const recipeResults = recipePaths . map ( recipePath => {
115
- type Recipe = {
116
- testApplicationName : string ;
117
- buildCommand ?: string ;
118
- tests : {
119
- testName : string ;
120
- testCommand : string ;
121
- timeoutSeconds ?: number ;
122
- } [ ] ;
123
- } ;
124
-
125
- const recipe : Recipe = JSON . parse ( fs . readFileSync ( recipePath , 'utf-8' ) ) ;
126
-
127
- if ( recipe . buildCommand ) {
128
- console . log ( `Running E2E test build command for test application "${ recipe . testApplicationName } "` ) ;
129
- const [ buildCommand , ...buildCommandArgs ] = recipe . buildCommand . split ( ' ' ) ;
130
- const buildCommandProcess = childProcess . spawnSync ( buildCommand , buildCommandArgs , {
131
- cwd : path . dirname ( recipePath ) ,
132
- encoding : 'utf8' ,
133
- stdio : 'inherit' ,
134
- } ) ;
135
-
136
- if ( buildCommandProcess . status !== 0 ) {
137
- process . exit ( 1 ) ;
138
- }
139
- }
110
+ const recipePaths = glob . sync ( `${ __dirname } /test-applications/*/test-recipe.json` , { absolute : true } ) ;
111
+
112
+ let someTestFailed = false ;
140
113
141
- type TestResult = {
114
+ const recipeResults = recipePaths . map ( recipePath => {
115
+ type Recipe = {
116
+ testApplicationName : string ;
117
+ buildCommand ?: string ;
118
+ tests : {
142
119
testName : string ;
143
- result : 'PASS' | 'FAIL' | 'TIMEOUT' ;
144
- } ;
120
+ testCommand : string ;
121
+ timeoutSeconds ?: number ;
122
+ } [ ] ;
123
+ } ;
124
+
125
+ const recipe : Recipe = JSON . parse ( fs . readFileSync ( recipePath , 'utf-8' ) ) ;
126
+
127
+ if ( recipe . buildCommand ) {
128
+ console . log ( `Running E2E test build command for test application "${ recipe . testApplicationName } "` ) ;
129
+ const [ buildCommand , ...buildCommandArgs ] = recipe . buildCommand . split ( ' ' ) ;
130
+ const buildCommandProcess = childProcess . spawnSync ( buildCommand , buildCommandArgs , {
131
+ cwd : path . dirname ( recipePath ) ,
132
+ encoding : 'utf8' ,
133
+ stdio : 'inherit' ,
134
+ } ) ;
145
135
146
- const testResults : TestResult [ ] = recipe . tests . map ( test => {
147
- console . log (
148
- `Running E2E test command for test application " ${ recipe . testApplicationName } ", test " ${ test . testName } "` ,
149
- ) ;
136
+ if ( buildCommandProcess . status !== 0 ) {
137
+ process . exit ( 1 ) ;
138
+ }
139
+ }
150
140
151
- const [ testCommand , ...testCommandArgs ] = test . testCommand . split ( ' ' ) ;
152
- const testProcessResult = childProcess . spawnSync ( testCommand , testCommandArgs , {
153
- cwd : path . dirname ( recipePath ) ,
154
- timeout : ( test . timeoutSeconds ?? DEFAULT_TEST_TIMEOUT_SECONDS ) * 1000 ,
155
- encoding : 'utf8' ,
156
- stdio : 'pipe' ,
157
- } ) ;
158
-
159
- console . log ( testProcessResult . stdout . replace ( / ^ / gm, '[TEST OUTPUT] ' ) ) ;
160
- console . log ( testProcessResult . stderr . replace ( / ^ / gm, '[TEST OUTPUT] ' ) ) ;
161
-
162
- const error : undefined | ( Error & { code ?: string } ) = testProcessResult . error ;
163
-
164
- if ( error ?. code === 'ETIMEDOUT' ) {
165
- printCIErrorMessage (
166
- `Test "${ test . testName } " in test application "${ recipe . testApplicationName } " (${ path . dirname (
167
- recipePath ,
168
- ) } ) timed out.`,
169
- ) ;
170
- return {
171
- testName : test . testName ,
172
- result : 'TIMEOUT' ,
173
- } ;
174
- } else if ( testProcessResult . status !== 0 ) {
175
- printCIErrorMessage (
176
- `Test "${ test . testName } " in test application "${ recipe . testApplicationName } " (${ path . dirname (
177
- recipePath ,
178
- ) } ) failed.`,
179
- ) ;
180
- return {
181
- testName : test . testName ,
182
- result : 'FAIL' ,
183
- } ;
184
- } else {
185
- console . log (
186
- `Test "${ test . testName } " in test application "${ recipe . testApplicationName } " (${ path . dirname (
187
- recipePath ,
188
- ) } ) succeeded.`,
189
- ) ;
190
- return {
191
- testName : test . testName ,
192
- result : 'PASS' ,
193
- } ;
194
- }
141
+ type TestResult = {
142
+ testName : string ;
143
+ result : 'PASS' | 'FAIL' | 'TIMEOUT' ;
144
+ } ;
145
+
146
+ const testResults : TestResult [ ] = recipe . tests . map ( test => {
147
+ console . log (
148
+ `Running E2E test command for test application "${ recipe . testApplicationName } ", test "${ test . testName } "` ,
149
+ ) ;
150
+
151
+ const [ testCommand , ...testCommandArgs ] = test . testCommand . split ( ' ' ) ;
152
+ const testProcessResult = childProcess . spawnSync ( testCommand , testCommandArgs , {
153
+ cwd : path . dirname ( recipePath ) ,
154
+ timeout : ( test . timeoutSeconds ?? DEFAULT_TEST_TIMEOUT_SECONDS ) * 1000 ,
155
+ encoding : 'utf8' ,
156
+ stdio : 'pipe' ,
195
157
} ) ;
196
158
197
- return {
198
- testApplicationName : recipe . testApplicationName ,
199
- testApplicationPath : recipePath ,
200
- testResults,
201
- } ;
159
+ console . log ( testProcessResult . stdout . replace ( / ^ / gm, '[TEST OUTPUT] ' ) ) ;
160
+ console . log ( testProcessResult . stderr . replace ( / ^ / gm, '[TEST OUTPUT] ' ) ) ;
161
+
162
+ const error : undefined | ( Error & { code ?: string } ) = testProcessResult . error ;
163
+
164
+ if ( error ?. code === 'ETIMEDOUT' ) {
165
+ printCIErrorMessage (
166
+ `Test "${ test . testName } " in test application "${ recipe . testApplicationName } " (${ path . dirname (
167
+ recipePath ,
168
+ ) } ) timed out.`,
169
+ ) ;
170
+ return {
171
+ testName : test . testName ,
172
+ result : 'TIMEOUT' ,
173
+ } ;
174
+ } else if ( testProcessResult . status !== 0 ) {
175
+ someTestFailed = true ;
176
+ printCIErrorMessage (
177
+ `Test "${ test . testName } " in test application "${ recipe . testApplicationName } " (${ path . dirname (
178
+ recipePath ,
179
+ ) } ) failed.`,
180
+ ) ;
181
+ return {
182
+ testName : test . testName ,
183
+ result : 'FAIL' ,
184
+ } ;
185
+ } else {
186
+ someTestFailed = true ;
187
+ console . log (
188
+ `Test "${ test . testName } " in test application "${ recipe . testApplicationName } " (${ path . dirname (
189
+ recipePath ,
190
+ ) } ) succeeded.`,
191
+ ) ;
192
+ return {
193
+ testName : test . testName ,
194
+ result : 'PASS' ,
195
+ } ;
196
+ }
202
197
} ) ;
203
198
204
- console . log ( '--------------------------------------' ) ;
205
- console . log ( 'Test Result Summary:' ) ;
199
+ return {
200
+ testApplicationName : recipe . testApplicationName ,
201
+ testApplicationPath : recipePath ,
202
+ testResults,
203
+ } ;
204
+ } ) ;
206
205
207
- recipeResults . forEach ( recipeResult => {
208
- console . log ( `● ${ recipeResult . testApplicationName } (${ path . dirname ( recipeResult . testApplicationPath ) } )` ) ;
209
- recipeResult . testResults . forEach ( testResult => {
210
- console . log ( ` ● ${ testResult . result . padEnd ( 7 , ' ' ) } ${ testResult . testName } ` ) ;
211
- } ) ;
206
+ console . log ( '--------------------------------------' ) ;
207
+ console . log ( 'Test Result Summary:' ) ;
208
+
209
+ recipeResults . forEach ( recipeResult => {
210
+ console . log ( `● ${ recipeResult . testApplicationName } (${ path . dirname ( recipeResult . testApplicationPath ) } )` ) ;
211
+ recipeResult . testResults . forEach ( testResult => {
212
+ console . log ( ` ● ${ testResult . result . padEnd ( 7 , ' ' ) } ${ testResult . testName } ` ) ;
212
213
} ) ;
213
214
} ) ;
214
215
@@ -217,3 +218,10 @@ groupCIOutput('Cleanup', () => {
217
218
childProcess . spawnSync ( `docker stop ${ TEST_REGISTRY_CONTAINER_NAME } ` , { encoding : 'utf8' , stdio : 'ignore' } ) ;
218
219
console . log ( 'Successfully stopped test registry container' ) ; // Output from command above is not good so we `ignore` it and emit our own
219
220
} ) ;
221
+
222
+ if ( someTestFailed ) {
223
+ console . log ( 'Not all tests succeeded.' ) ;
224
+ process . exit ( 1 ) ;
225
+ } else {
226
+ console . log ( 'All tests succeeded.' ) ;
227
+ }
0 commit comments