Skip to content

Commit 24939e8

Browse files
build: speedy tests on circle by splitting the test files into multiple jobs (electron#21015)
* build: let circleci divide our test suites in two * well our tests rely on side affects, thats cool I guess
1 parent bbfb32b commit 24939e8

18 files changed

+51
-80
lines changed

.circleci/config.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,8 @@ steps-tests: &steps-tests
12211221
command: |
12221222
cd src
12231223
export ELECTRON_OUT_DIR=Default
1224-
(cd electron && node script/yarn test -- --enable-logging)
1224+
(cd electron && node script/yarn test --runners=main --enable-logging --files $(circleci tests glob spec-main/*-spec.ts | circleci tests split))
1225+
(cd electron && node script/yarn test --runners=remote --enable-logging --files $(circleci tests glob spec/*-spec.js | circleci tests split))
12251226
- run:
12261227
name: Check test results existence
12271228
command: |
@@ -1766,6 +1767,7 @@ jobs:
17661767
<<: *env-linux-medium
17671768
<<: *env-headless-testing
17681769
<<: *env-stack-dumping
1770+
parallelism: 3
17691771
<<: *steps-tests
17701772

17711773
linux-x64-testing-nan:
@@ -1815,6 +1817,7 @@ jobs:
18151817
<<: *env-ia32
18161818
<<: *env-headless-testing
18171819
<<: *env-stack-dumping
1820+
parallelism: 3
18181821
<<: *steps-tests
18191822

18201823
linux-ia32-testing-nan:
@@ -1867,6 +1870,7 @@ jobs:
18671870
environment:
18681871
<<: *env-mac-large
18691872
<<: *env-stack-dumping
1873+
parallelism: 2
18701874
<<: *steps-tests
18711875

18721876
osx-release-tests:
@@ -1896,6 +1900,7 @@ jobs:
18961900
environment:
18971901
<<: *env-mac-large
18981902
<<: *env-stack-dumping
1903+
parallelism: 2
18991904
<<: *steps-tests
19001905

19011906
mas-release-tests:

spec-main/api-app-spec.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as chai from 'chai'
2-
import * as chaiAsPromised from 'chai-as-promised'
1+
import { expect } from 'chai'
32
import * as cp from 'child_process'
43
import * as https from 'https'
54
import * as net from 'net'
@@ -13,10 +12,6 @@ import split = require('split')
1312

1413
const features = process.electronBinding('features')
1514

16-
const { expect } = chai
17-
18-
chai.use(chaiAsPromised)
19-
2015
const fixturesPath = path.resolve(__dirname, '../spec/fixtures')
2116

2217
describe('electron module', () => {

spec-main/api-browser-view-spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import * as chai from 'chai'
1+
import { expect } from 'chai'
22
import * as ChildProcess from 'child_process'
33
import * as path from 'path'
44
import { emittedOnce } from './events-helpers'
55
import { BrowserView, BrowserWindow } from 'electron'
66
import { closeWindow } from './window-helpers'
7-
import dirtyChai = require('dirty-chai')
8-
9-
const { expect } = chai
10-
chai.use(dirtyChai)
117

128
describe('BrowserView module', () => {
139
const fixtures = path.resolve(__dirname, '..', 'spec', 'fixtures')

spec-main/api-browser-window-spec.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as chai from 'chai'
2-
import * as chaiAsPromised from 'chai-as-promised'
1+
import { expect } from 'chai'
32
import * as path from 'path'
43
import * as fs from 'fs'
54
import * as os from 'os'
@@ -11,12 +10,6 @@ import { app, BrowserWindow, BrowserView, ipcMain, OnBeforeSendHeadersListenerDe
1110
import { emittedOnce } from './events-helpers'
1211
import { ifit, ifdescribe } from './spec-helpers'
1312
import { closeWindow } from './window-helpers'
14-
import dirtyChai = require('dirty-chai')
15-
16-
const { expect } = chai
17-
18-
chai.use(chaiAsPromised)
19-
chai.use(dirtyChai)
2013

2114
const fixtures = path.resolve(__dirname, '..', 'spec', 'fixtures')
2215

spec-main/api-ipc-spec.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import * as chai from 'chai'
2-
import * as chaiAsPromised from 'chai-as-promised'
1+
import { expect } from 'chai'
32
import { BrowserWindow, ipcMain, IpcMainInvokeEvent } from 'electron'
43

5-
const { expect } = chai
6-
7-
chai.use(chaiAsPromised)
8-
94
describe('ipc module', () => {
105
describe('invoke', () => {
116
let w = (null as unknown as BrowserWindow)

spec-main/api-web-contents-spec.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import * as chai from 'chai'
1+
import { expect } from 'chai'
22
import { AddressInfo } from 'net'
3-
import * as chaiAsPromised from 'chai-as-promised'
43
import * as path from 'path'
54
import * as fs from 'fs'
65
import * as http from 'http'
@@ -10,10 +9,6 @@ import { emittedOnce } from './events-helpers'
109
import { closeAllWindows } from './window-helpers'
1110
import { ifdescribe, ifit } from './spec-helpers'
1211

13-
const { expect } = chai
14-
15-
chai.use(chaiAsPromised)
16-
1712
const fixturesPath = path.resolve(__dirname, '..', 'spec', 'fixtures')
1813
const features = process.electronBinding('features')
1914

spec-main/chromium-spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as chai from 'chai'
2-
import * as chaiAsPromised from 'chai-as-promised'
1+
import { expect } from 'chai'
32
import { BrowserWindow, WebContents, session, ipcMain, app, protocol, webContents } from 'electron'
43
import { emittedOnce } from './events-helpers'
54
import { closeAllWindows } from './window-helpers'
@@ -14,11 +13,8 @@ import { promisify } from 'util'
1413
import { ifit, ifdescribe } from './spec-helpers'
1514
import { AddressInfo } from 'net'
1615

17-
const { expect } = chai
18-
1916
const features = process.electronBinding('features')
2017

21-
chai.use(chaiAsPromised)
2218
const fixturesPath = path.resolve(__dirname, '..', 'spec', 'fixtures')
2319

2420
describe('reporting api', () => {

spec-main/index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ app.whenReady().then(() => {
4343

4444
const argv = require('yargs')
4545
.boolean('ci')
46+
.array('files')
4647
.string('g').alias('g', 'grep')
4748
.boolean('i').alias('i', 'invert')
4849
.argv
@@ -86,15 +87,27 @@ app.whenReady().then(() => {
8687
}
8788
})
8889

90+
const baseElectronDir = path.resolve(__dirname, '..')
91+
8992
walker.on('end', () => {
9093
testFiles.sort()
91-
sortToEnd(testFiles, f => f.includes('crash-reporter')).forEach((file) => mocha.addFile(file))
94+
sortToEnd(testFiles, f => f.includes('crash-reporter')).forEach((file) => {
95+
if (!argv.files || argv.files.includes(path.relative(baseElectronDir, file))) {
96+
mocha.addFile(file)
97+
}
98+
})
9299
const cb = () => {
93100
// Ensure the callback is called after runner is defined
94101
process.nextTick(() => {
95102
process.exit(runner.failures)
96103
})
97104
}
105+
106+
// Set up chai in the correct order
107+
const chai = require('chai')
108+
chai.use(require('chai-as-promised'))
109+
chai.use(require('dirty-chai'))
110+
98111
const runner = mocha.run(cb)
99112
})
100113
})

spec/api-native-image-spec.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
'use strict'
22

3-
const chai = require('chai')
4-
const dirtyChai = require('dirty-chai')
3+
const { expect } = require('chai')
54
const { nativeImage } = require('electron')
65
const path = require('path')
76

8-
const { expect } = chai
9-
chai.use(dirtyChai)
10-
117
describe('nativeImage module', () => {
128
const ImageFormat = {
139
PNG: 'png',

spec/api-remote-spec.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
'use strict'
22

3-
const chai = require('chai')
4-
const dirtyChai = require('dirty-chai')
3+
const { expect } = require('chai')
54
const path = require('path')
65
const { resolveGetters } = require('./expect-helpers')
76
const { ifdescribe } = require('./spec-helpers')
87

98
const { remote, ipcRenderer } = require('electron')
109
const { ipcMain, BrowserWindow } = remote
11-
const { expect } = chai
1210

1311
const features = process.electronBinding('features')
1412

15-
chai.use(dirtyChai)
16-
1713
const comparePaths = (path1, path2) => {
1814
if (process.platform === 'win32') {
1915
path1 = path1.toLowerCase()

0 commit comments

Comments
 (0)