@@ -49,18 +49,18 @@ const resourcePath = CONFIG.repositoryRootPath
49
49
let executablePath
50
50
if ( process . platform === 'darwin' ) {
51
51
const executablePaths = glob . sync ( path . join ( CONFIG . buildOutputPath , '*.app' ) )
52
- assert ( executablePaths . length === 1 , `More than one application to run tests against was found. ${ executablePaths . join ( ',' ) } ` )
52
+ assert ( executablePaths . length === 1 , `A single application to run tests against was not found. ${ executablePaths . join ( ',' ) } ` )
53
53
executablePath = path . join ( executablePaths [ 0 ] , 'Contents' , 'MacOS' , path . basename ( executablePaths [ 0 ] , '.app' ) )
54
54
} else if ( process . platform === 'linux' ) {
55
55
const executablePaths = glob . sync ( path . join ( CONFIG . buildOutputPath , 'atom-*' , 'atom' ) )
56
- assert ( executablePaths . length === 1 , `More than one application to run tests against was found. ${ executablePaths . join ( ',' ) } ` )
56
+ assert ( executablePaths . length === 1 , `A single application to run tests against was not found. ${ executablePaths . join ( ',' ) } ` )
57
57
executablePath = executablePaths [ 0 ]
58
58
} else if ( process . platform === 'win32' ) {
59
59
const executablePaths = glob . sync ( path . join ( CONFIG . buildOutputPath , '**' , 'atom*.exe' ) )
60
- assert ( executablePaths . length === 1 , `More than one application to run tests against was found. ${ executablePaths . join ( ',' ) } ` )
60
+ assert ( executablePaths . length === 1 , `A single application to run tests against was not found. ${ executablePaths . join ( ',' ) } ` )
61
61
executablePath = executablePaths [ 0 ]
62
62
} else {
63
- throw new Error ( 'Running tests on this platform is not supported.' )
63
+ throw new Error ( '##[error] Running tests on this platform is not supported.' )
64
64
}
65
65
66
66
function prepareEnv ( suiteName ) {
@@ -91,24 +91,29 @@ function runCoreMainProcessTests (callback) {
91
91
92
92
const testEnv = Object . assign ( { } , prepareEnv ( 'core-main-process' ) , { ATOM_GITHUB_INLINE_GIT_EXEC : 'true' } )
93
93
94
- console . log ( 'Executing core main process tests' . bold . green )
94
+ console . log ( '##[command] Executing core main process tests' . bold . green )
95
95
const cp = childProcess . spawn ( executablePath , testArguments , { stdio : 'inherit' , env : testEnv } )
96
96
cp . on ( 'error' , error => { callback ( error ) } )
97
- cp . on ( 'close' , exitCode => { callback ( null , { exitCode, step : 'core-main-process' } ) } )
97
+ cp . on ( 'close' , exitCode => { callback ( null , { exitCode, step : 'core-main-process' , testCommand : `You can run the test again using: \n\t ${ executablePath } ${ testArguments . join ( ' ' ) } ` } ) } )
98
98
}
99
99
100
- function runCoreRenderProcessTests ( callback ) {
101
- const testPath = path . join ( CONFIG . repositoryRootPath , 'spec' )
102
- const testArguments = [
103
- '--resource-path' , resourcePath ,
104
- '--test' , testPath
105
- ]
106
- const testEnv = prepareEnv ( 'core-render-process' )
100
+ // Build an array of functions, each running tests for a different rendering test
101
+ const coreRenderProcessTestSuites = [ ]
102
+ const testPath = path . join ( CONFIG . repositoryRootPath , 'spec' )
103
+ let testFiles = glob . sync ( path . join ( testPath , '*-spec.+(js|coffee|ts|jsx|tsx|mjs)' ) )
104
+ for ( let testFile of testFiles ) {
105
+ coreRenderProcessTestSuites . push ( function ( callback ) {
107
106
108
- console . log ( 'Executing core render process tests' . bold . green )
109
- const cp = childProcess . spawn ( executablePath , testArguments , { stdio : 'inherit' , env : testEnv } )
110
- cp . on ( 'error' , error => { callback ( error ) } )
111
- cp . on ( 'close' , exitCode => { callback ( null , { exitCode, step : 'core-render-process' } ) } )
107
+ const testEnv = prepareEnv ( 'core-render-process' )
108
+ console . log ( `##[command] Executing core render process tests for ${ testFile } ` . bold . green )
109
+ const testArguments = [
110
+ '--resource-path' , resourcePath ,
111
+ '--test' , testFile
112
+ ]
113
+ const cp = childProcess . spawn ( executablePath , testArguments , { stdio : 'inherit' , env : testEnv } )
114
+ cp . on ( 'error' , error => { callback ( error ) } )
115
+ cp . on ( 'close' , exitCode => { callback ( null , { exitCode, step : `core-render-process for ${ testFile } .` , testCommand : `You can run the test again using: \n\t ${ executablePath } ${ testArguments . join ( ' ' ) } ` } ) } )
116
+ } )
112
117
}
113
118
114
119
// Build an array of functions, each running tests for a different bundled package
@@ -140,17 +145,17 @@ for (let packageName in CONFIG.appMetadata.packageDependencies) {
140
145
const nodeModulesPath = path . join ( repositoryPackagePath , 'node_modules' )
141
146
let finalize = ( ) => null
142
147
if ( require ( pkgJsonPath ) . atomTestRunner ) {
143
- console . log ( `Installing test runner dependencies for ${ packageName } ` . bold . green )
148
+ console . log ( `##[command] Installing test runner dependencies for ${ packageName } ` . bold . green )
144
149
if ( fs . existsSync ( nodeModulesPath ) ) {
145
150
const backup = backupNodeModules ( repositoryPackagePath )
146
151
finalize = backup . restore
147
152
} else {
148
153
finalize = ( ) => fs . removeSync ( nodeModulesPath )
149
154
}
150
155
runApmInstall ( repositoryPackagePath )
151
- console . log ( `Executing ${ packageName } tests` . green )
156
+ console . log ( `##[command] Executing ${ packageName } tests` . green )
152
157
} else {
153
- console . log ( `Executing ${ packageName } tests` . bold . green )
158
+ console . log ( `##[command] Executing ${ packageName } tests` . bold . green )
154
159
}
155
160
const cp = childProcess . spawn ( executablePath , testArguments , { env : testEnv } )
156
161
@@ -164,11 +169,11 @@ for (let packageName in CONFIG.appMetadata.packageDependencies) {
164
169
} )
165
170
cp . on ( 'close' , exitCode => {
166
171
if ( exitCode !== 0 ) {
167
- console . log ( `Package tests failed for ${ packageName } :` . red )
172
+ console . log ( `##[error] Package tests failed for ${ packageName } :` . red )
168
173
console . log ( stderrOutput )
169
174
}
170
175
finalize ( )
171
- callback ( null , { exitCode, step : `package-${ packageName } ` } )
176
+ callback ( null , { exitCode, step : `package-${ packageName } .` , testCommand : `You can run the test again using: \n\t ${ executablePath } ${ testArguments . join ( ' ' ) } `} )
172
177
} )
173
178
} )
174
179
}
@@ -178,75 +183,107 @@ function runBenchmarkTests (callback) {
178
183
const testArguments = [ '--benchmark-test' , benchmarksPath ]
179
184
const testEnv = prepareEnv ( 'benchmark' )
180
185
181
- console . log ( 'Executing benchmark tests' . bold . green )
186
+ console . log ( '##[command] Executing benchmark tests' . bold . green )
182
187
const cp = childProcess . spawn ( executablePath , testArguments , { stdio : 'inherit' , env : testEnv } )
183
188
cp . on ( 'error' , error => { callback ( error ) } )
184
- cp . on ( 'close' , exitCode => { callback ( null , { exitCode, step : 'core-benchmarks' } ) } )
189
+ cp . on ( 'close' , exitCode => { callback ( null , { exitCode, step : 'core-benchmarks' , testCommand : `You can run the test again using: \n\t ${ executablePath } ${ testArguments . join ( ' ' ) } ` } ) } )
185
190
}
186
191
187
- let testSuitesToRun = requestedTestSuites ( ) || testSuitesForPlatform ( process . platform )
192
+ let testSuitesToRun = requestedTestSuites ( process . platform )
193
+
194
+ function requestedTestSuites ( platform ) {
195
+ // env variable or argv options
196
+ let coreAll = process . env . ATOM_RUN_CORE_TESTS === 'true'
197
+ let coreMain = process . env . ATOM_RUN_CORE_MAIN_TESTS === 'true' || argv . coreMain
198
+ let coreRenderer = argv . coreRenderer || process . env . ATOM_RUN_CORE_RENDER_TESTS == 'true'
199
+ let coreRenderer1 = process . env . ATOM_RUN_CORE_RENDER_TESTS === '1'
200
+ let coreRenderer2 = process . env . ATOM_RUN_CORE_RENDER_TESTS === '2'
201
+ let packageAll = argv . package || process . env . ATOM_RUN_PACKAGE_TESTS == 'true'
202
+ let packages1 = process . env . ATOM_RUN_PACKAGE_TESTS === '1'
203
+ let packages2 = process . env . ATOM_RUN_PACKAGE_TESTS === '2'
204
+ let benchmark = argv . coreBenchmark
205
+
206
+ // Operating system overrides:
207
+ coreMain = coreMain || ( platform === 'linux' ) || ( platform === 'win32' && process . arch === 'x86' )
208
+
209
+ // split package tests (used for macos in CI)
210
+ const PACKAGES_TO_TEST_IN_PARALLEL = 23
211
+ // split core render test (used for windows x64 in CI)
212
+ const CORE_RENDER_TO_TEST_IN_PARALLEL = 45
213
+
214
+ let suites = [ ]
215
+ // Core tess
216
+ if ( coreAll ) {
217
+ suites . push ( ...[ runCoreMainProcessTests , ...coreRenderProcessTestSuites ] )
218
+ } else {
219
+
220
+ // Core main tests
221
+ if ( coreMain ) {
222
+ suites . push ( runCoreMainProcessTests )
223
+ }
224
+
225
+ // Core renderer tests
226
+ if ( coreRenderer ) {
227
+ suites . push ( ...coreRenderProcessTestSuites )
228
+ } else {
229
+ // split
230
+ if ( coreRenderer1 ) {
231
+ suites . push ( ...coreRenderProcessTestSuites . slice ( 0 , CORE_RENDER_TO_TEST_IN_PARALLEL ) )
232
+ }
233
+ if ( coreRenderer2 ) {
234
+ suites . push ( ...coreRenderProcessTestSuites . slice ( CORE_RENDER_TO_TEST_IN_PARALLEL ) )
235
+ }
236
+ }
188
237
189
- function requestedTestSuites ( ) {
190
- const suites = [ ]
191
- if ( argv . coreMain ) {
192
- suites . push ( runCoreMainProcessTests )
193
- }
194
- if ( argv . coreRenderer ) {
195
- suites . push ( runCoreRenderProcessTests )
196
- }
197
- if ( argv . coreBenchmark ) {
198
- suites . push ( runBenchmarkTests )
199
238
}
200
- if ( argv . package ) {
239
+
240
+ // Package tests
241
+ if ( packageAll ) {
201
242
suites . push ( ...packageTestSuites )
243
+ } else {
244
+ // split
245
+ if ( packages1 ) {
246
+ suites . push ( ...packageTestSuites . slice ( 0 , PACKAGES_TO_TEST_IN_PARALLEL ) )
247
+ }
248
+ if ( packages2 ) {
249
+ suites . push ( ...packageTestSuites . slice ( PACKAGES_TO_TEST_IN_PARALLEL ) )
250
+ }
202
251
}
203
- return suites . length > 0 ? suites : null
204
- }
205
252
206
- function testSuitesForPlatform ( platform ) {
207
- let suites = [ ]
208
- switch ( platform ) {
209
- case 'darwin' :
210
- const PACKAGES_TO_TEST_IN_PARALLEL = 23
211
-
212
- if ( process . env . ATOM_RUN_CORE_TESTS === 'true' ) {
213
- suites = [ runCoreMainProcessTests , runCoreRenderProcessTests ]
214
- } else if ( process . env . ATOM_RUN_PACKAGE_TESTS === '1' ) {
215
- suites = packageTestSuites . slice ( 0 , PACKAGES_TO_TEST_IN_PARALLEL )
216
- } else if ( process . env . ATOM_RUN_PACKAGE_TESTS === '2' ) {
217
- suites = packageTestSuites . slice ( PACKAGES_TO_TEST_IN_PARALLEL )
218
- } else {
219
- suites = [ runCoreMainProcessTests , runCoreRenderProcessTests ] . concat ( packageTestSuites )
220
- }
221
- break
222
- case 'win32' :
223
- suites = ( process . arch === 'x64' ) ? [ runCoreMainProcessTests , runCoreRenderProcessTests ] : [ runCoreMainProcessTests ]
224
- break
225
- case 'linux' :
226
- suites = [ runCoreMainProcessTests ]
227
- break
228
- default :
229
- console . log ( `Unrecognized platform: ${ platform } ` )
253
+ // Benchmark tests
254
+ if ( benchmark ) {
255
+ suites . push ( runBenchmarkTests )
230
256
}
231
257
232
258
if ( argv . skipMainProcessTests ) {
233
259
suites = suites . filter ( suite => suite !== runCoreMainProcessTests )
234
260
}
235
261
262
+ // Remove duplicates
263
+ suites = Array . from ( new Set ( suites ) )
264
+
265
+ if ( suites . length == 0 ) {
266
+ throw new Error ( "No tests was requested" )
267
+ }
268
+
236
269
return suites
237
270
}
238
271
239
- async . series ( testSuitesToRun , function ( err , results ) {
272
+ async . parallel ( testSuitesToRun , function ( err , results ) {
240
273
if ( err ) {
241
274
console . error ( err )
242
275
process . exit ( 1 )
243
276
} else {
244
277
const failedSteps = results . filter ( ( { exitCode} ) => exitCode !== 0 )
245
278
246
- for ( const { step} of failedSteps ) {
247
- console . error ( `Error! The '${ step } ' test step finished with a non-zero exit code` )
279
+ if ( failedSteps . length > 0 ) {
280
+ console . warn ( "##[error] \n \n *** Reporting the errors that happened in all of the tests: *** \n \n" )
281
+ for ( const { step, testCommand} of failedSteps ) {
282
+ console . error ( `##[error] The '${ step } ' test step finished with a non-zero exit code \n ${ testCommand } ` )
283
+ }
284
+ process . exit ( 1 )
248
285
}
249
286
250
- process . exit ( failedSteps . length === 0 ? 0 : 1 )
287
+ process . exit ( 0 )
251
288
}
252
289
} )
0 commit comments