Skip to content

Commit ddc5a4b

Browse files
authored
Merge pull request #50 from atom-ide-community/windows_tests
2 parents 96e6b96 + 582b6d9 commit ddc5a4b

File tree

5 files changed

+167
-71
lines changed

5 files changed

+167
-71
lines changed

script/test

Lines changed: 103 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,18 @@ const resourcePath = CONFIG.repositoryRootPath
4949
let executablePath
5050
if (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

6666
function 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
})

script/vsts/platforms/macos.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ jobs:
88
ReleaseVersion: $[ dependencies.GetReleaseVersion.outputs['Version.ReleaseVersion'] ]
99
IsReleaseBranch: $[ dependencies.GetReleaseVersion.outputs['Version.IsReleaseBranch'] ]
1010
IsSignedZipBranch: $[ dependencies.GetReleaseVersion.outputs['Version.IsSignedZipBranch'] ]
11+
RunCoreMainTests: true
1112
pool:
1213
vmImage: macos-10.14
1314

@@ -25,6 +26,9 @@ jobs:
2526

2627
- template: templates/build.yml
2728

29+
# core main tests
30+
- template: templates/test.yml
31+
2832
- script: |
2933
cp $(Build.SourcesDirectory)/out/*.zip $(Build.ArtifactStagingDirectory)
3034
displayName: Stage Artifacts
@@ -51,8 +55,8 @@ jobs:
5155
strategy:
5256
maxParallel: 3
5357
matrix:
54-
core:
55-
RunCoreTests: true
58+
renderer:
59+
RunCoreRendererTests: true
5660
RunPackageTests: false
5761
packages-1:
5862
RunCoreTests: false

script/vsts/platforms/templates/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ steps:
2121
ATOM_JASMINE_REPORTER: list
2222
TEST_JUNIT_XML_ROOT: $(Common.TestResultsDirectory)/junit
2323
ATOM_RUN_CORE_TESTS: $(RunCoreTests)
24+
ATOM_RUN_CORE_MAIN_TESTS: $(RunCoreMainTests)
25+
ATOM_RUN_CORE_RENDER_TESTS: $(RunCoreRendererTests)
2426
ATOM_RUN_PACKAGE_TESTS: $(RunPackageTests)
2527
displayName: Run tests
2628
condition: and(succeeded(), ne(variables['Atom.SkipTests'], 'true'))

script/vsts/platforms/windows.yml

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
jobs:
2-
- job: Windows
2+
- job: Windows_Build
33
dependsOn: GetReleaseVersion
44
timeoutInMinutes: 180
55
strategy:
66
maxParallel: 2
77
matrix:
88
x64:
99
buildArch: x64
10+
RunCoreMainTests: true
1011
x86:
1112
buildArch: x86
13+
RunCoreMainTests: true
1214

1315
pool:
1416
vmImage: vs2017-win2016
@@ -53,7 +55,7 @@ jobs:
5355
artifacts:
5456
- filename: atom$(FileID)-windows.zip
5557
dir: $(Build.SourcesDirectory)/out
56-
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
58+
condition: and( succeeded(), or( eq(variables['BUILD_ARCH'], 'x64'), ne(variables['Build.Reason'], 'PullRequest') ) )
5759
- filename: AtomSetup$(FileID).exe
5860
dir: $(Build.SourcesDirectory)/out
5961
condition: and(succeeded(), eq(variables['IsReleaseBranch'], 'true'))
@@ -67,3 +69,54 @@ jobs:
6769
- filename: RELEASES$(FileID)
6870
dir: $(Build.SourcesDirectory)/out
6971
condition: and(succeeded(), eq(variables['IsReleaseBranch'], 'true'))
72+
73+
- job: Windows_RendererTests
74+
dependsOn: Windows_Build
75+
timeoutInMinutes: 180
76+
strategy:
77+
maxParallel: 2
78+
matrix:
79+
x64_Renderer_Test1:
80+
RunCoreMainTests: false
81+
RunCoreRendererTests: 1
82+
buildArch: x64
83+
x64_Renderer_Test2:
84+
RunCoreMainTests: false
85+
RunCoreRendererTests: 2
86+
buildArch: x64
87+
88+
pool:
89+
vmImage: vs2017-win2016
90+
91+
variables:
92+
AppName: $[ dependencies.GetReleaseVersion.outputs['Version.AppName'] ]
93+
ReleaseVersion: $[ dependencies.GetReleaseVersion.outputs['Version.ReleaseVersion'] ]
94+
IsReleaseBranch: $[ dependencies.GetReleaseVersion.outputs['Version.IsReleaseBranch'] ]
95+
IsSignedZipBranch: $[ dependencies.GetReleaseVersion.outputs['Version.IsSignedZipBranch'] ]
96+
97+
steps:
98+
- template: templates/preparation.yml
99+
100+
- template: templates/cache.yml
101+
parameters:
102+
OS: windows
103+
104+
- template: templates/bootstrap.yml
105+
106+
# Downloading the build artifacts
107+
- pwsh: |
108+
if ($env:BUILD_ARCH -eq "x64") {
109+
$env:FileID="-x64"
110+
echo "##vso[task.setvariable variable=FileID]$env:FileID" # Azure syntax
111+
}
112+
env:
113+
BUILD_ARCH: $(buildArch)
114+
displayName: Set FileID based on the arch
115+
116+
- template: templates/download-unzip.yml
117+
parameters:
118+
artifacts:
119+
- atom$(FileID)-windows.zip
120+
121+
# Core renderer tests
122+
- template: templates/test.yml

src/main-process/start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { app } = require('electron');
22
const nslog = require('nslog');
33
const path = require('path');
4-
const temp = require('temp').track();
4+
const temp = require('temp');
55
const parseCommandLine = require('./parse-command-line');
66
const startCrashReporter = require('../crash-reporter-start');
77
const getReleaseChannel = require('../get-release-channel');

0 commit comments

Comments
 (0)