@@ -49,18 +49,18 @@ const resourcePath = CONFIG.repositoryRootPath
4949let executablePath
5050if ( process . platform === 'darwin' ) {
5151 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 ( ',' ) } ` )
5353 executablePath = path . join ( executablePaths [ 0 ] , 'Contents' , 'MacOS' , path . basename ( executablePaths [ 0 ] , '.app' ) )
5454} else if ( process . platform === 'linux' ) {
5555 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 ( ',' ) } ` )
5757 executablePath = executablePaths [ 0 ]
5858} else if ( process . platform === 'win32' ) {
5959 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 ( ',' ) } ` )
6161 executablePath = executablePaths [ 0 ]
6262} 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.' )
6464}
6565
6666function prepareEnv ( suiteName ) {
@@ -91,24 +91,29 @@ function runCoreMainProcessTests (callback) {
9191
9292 const testEnv = Object . assign ( { } , prepareEnv ( 'core-main-process' ) , { ATOM_GITHUB_INLINE_GIT_EXEC : 'true' } )
9393
94- console . log ( 'Executing core main process tests' . bold . green )
94+ console . log ( '##[command] Executing core main process tests' . bold . green )
9595 const cp = childProcess . spawn ( executablePath , testArguments , { stdio : 'inherit' , env : testEnv } )
9696 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 ( ' ' ) } ` } ) } )
9898}
9999
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 ) {
107106
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+ } )
112117}
113118
114119// Build an array of functions, each running tests for a different bundled package
@@ -140,17 +145,17 @@ for (let packageName in CONFIG.appMetadata.packageDependencies) {
140145 const nodeModulesPath = path . join ( repositoryPackagePath , 'node_modules' )
141146 let finalize = ( ) => null
142147 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 )
144149 if ( fs . existsSync ( nodeModulesPath ) ) {
145150 const backup = backupNodeModules ( repositoryPackagePath )
146151 finalize = backup . restore
147152 } else {
148153 finalize = ( ) => fs . removeSync ( nodeModulesPath )
149154 }
150155 runApmInstall ( repositoryPackagePath )
151- console . log ( `Executing ${ packageName } tests` . green )
156+ console . log ( `##[command] Executing ${ packageName } tests` . green )
152157 } else {
153- console . log ( `Executing ${ packageName } tests` . bold . green )
158+ console . log ( `##[command] Executing ${ packageName } tests` . bold . green )
154159 }
155160 const cp = childProcess . spawn ( executablePath , testArguments , { env : testEnv } )
156161
@@ -164,11 +169,11 @@ for (let packageName in CONFIG.appMetadata.packageDependencies) {
164169 } )
165170 cp . on ( 'close' , exitCode => {
166171 if ( exitCode !== 0 ) {
167- console . log ( `Package tests failed for ${ packageName } :` . red )
172+ console . log ( `##[error] Package tests failed for ${ packageName } :` . red )
168173 console . log ( stderrOutput )
169174 }
170175 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 ( ' ' ) } `} )
172177 } )
173178 } )
174179}
@@ -178,75 +183,107 @@ function runBenchmarkTests (callback) {
178183 const testArguments = [ '--benchmark-test' , benchmarksPath ]
179184 const testEnv = prepareEnv ( 'benchmark' )
180185
181- console . log ( 'Executing benchmark tests' . bold . green )
186+ console . log ( '##[command] Executing benchmark tests' . bold . green )
182187 const cp = childProcess . spawn ( executablePath , testArguments , { stdio : 'inherit' , env : testEnv } )
183188 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 ( ' ' ) } ` } ) } )
185190}
186191
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+ }
188237
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 )
199238 }
200- if ( argv . package ) {
239+
240+ // Package tests
241+ if ( packageAll ) {
201242 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+ }
202251 }
203- return suites . length > 0 ? suites : null
204- }
205252
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 )
230256 }
231257
232258 if ( argv . skipMainProcessTests ) {
233259 suites = suites . filter ( suite => suite !== runCoreMainProcessTests )
234260 }
235261
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+
236269 return suites
237270}
238271
239- async . series ( testSuitesToRun , function ( err , results ) {
272+ async . parallel ( testSuitesToRun , function ( err , results ) {
240273 if ( err ) {
241274 console . error ( err )
242275 process . exit ( 1 )
243276 } else {
244277 const failedSteps = results . filter ( ( { exitCode} ) => exitCode !== 0 )
245278
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 )
248285 }
249286
250- process . exit ( failedSteps . length === 0 ? 0 : 1 )
287+ process . exit ( 0 )
251288 }
252289} )
0 commit comments