Skip to content
Permalink
Browse files

test: there is only --ci (#20794)

  • Loading branch information...
nornagon committed Oct 30, 2019
1 parent b275273 commit 6781d5e3c82681336c73631ed1f480e228070108
@@ -1178,7 +1178,7 @@ steps-tests: &steps-tests
command: |
cd src
export ELECTRON_OUT_DIR=Default
(cd electron && node script/yarn test -- --ci --enable-logging)
(cd electron && node script/yarn test -- --enable-logging)
- run:
name: Check test results existence
command: |
@@ -133,7 +133,7 @@ test_script:
echo "Skipping tests for $env:GN_CONFIG build"
}
- cd electron
- if "%RUN_TESTS%"=="true" ( echo Running test suite & node script/yarn test -- --ci --enable-logging)
- if "%RUN_TESTS%"=="true" ( echo Running test suite & node script/yarn test -- --enable-logging)
- cd ..
- if "%RUN_TESTS%"=="true" ( echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg )
- echo "About to verify mksnapshot"
@@ -63,7 +63,7 @@ steps:
set npm_config_nodedir=%cd%\out\Default\gen\node_headers
set npm_config_arch=arm64
cd electron
node script/yarn test -- --ci --enable-logging --verbose
node script/yarn test -- --enable-logging --verbose
displayName: 'Run Electron tests'
env:
ELECTRON_OUT_DIR: Default
@@ -89,4 +89,4 @@ steps:
Get-Process | Where Name –Like "electron*" | Stop-Process
Get-Process | Where Name –Like "MicrosoftEdge*" | Stop-Process
displayName: 'Kill processes left running from last test run'
condition: always()
condition: always()
@@ -236,7 +236,7 @@ the Electron binary:

```sh
$ ./out/Debug/Electron.app/Contents/MacOS/Electron electron/spec \
--ci --enable-logging -g 'BrowserWindow module'
--enable-logging -g 'BrowserWindow module'
```

## Sharing the git cache between multiple machines
@@ -102,18 +102,8 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {

#ifdef _DEBUG
// Don't display assert dialog boxes in CI test runs
static const char* kCI = "ELECTRON_CI";
bool is_ci = IsEnvSet(kCI);
if (!is_ci) {
for (int i = 0; i < arguments.argc; ++i) {
if (!_wcsicmp(arguments.argv[i], L"--ci")) {
is_ci = true;
_putenv_s(kCI, "1"); // set flag for child processes
break;
}
}
}
if (is_ci) {
static const char* kCI = "CI";
if (IsEnvSet(kCI)) {
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);

@@ -1,4 +1,3 @@
declare var isCI: boolean;
declare var standardScheme: string;

declare namespace Electron {
@@ -5,7 +5,6 @@ import * as https from 'https'
import * as net from 'net'
import * as fs from 'fs'
import * as path from 'path'
import { homedir } from 'os'
import split = require('split')
import { app, BrowserWindow, Menu } from 'electron'
import { emittedOnce } from './events-helpers';
@@ -129,7 +128,7 @@ describe('app module', () => {
describe('app.getLocaleCountryCode()', () => {
it('should be empty or have length of two', () => {
let expectedLength = 2
if (isCI && process.platform === 'linux') {
if (process.platform === 'linux') {
// Linux CI machines have no locale.
expectedLength = 0
}
@@ -143,13 +142,7 @@ describe('app module', () => {
})
})

describe('app.isInApplicationsFolder()', () => {
before(function () {
if (process.platform !== 'darwin') {
this.skip()
}
})

ifdescribe(process.platform === 'darwin')('app.isInApplicationsFolder()', () => {
it('should be false during tests', () => {
expect(app.isInApplicationsFolder()).to.equal(false)
})
@@ -679,30 +672,6 @@ describe('app module', () => {
})
})

describe('getPath("logs")', () => {
const logsPaths = {
'darwin': path.resolve(homedir(), 'Library', 'Logs'),
'linux': path.resolve(homedir(), 'AppData', app.name),
'win32': path.resolve(homedir(), 'AppData', app.name),
}

it('has no logs directory by default', () => {
// this won't be deterministic except on CI since
// users may or may not have this dir
if (!isCI) return

const osLogPath = (logsPaths as any)[process.platform]
expect(fs.existsSync(osLogPath)).to.be.false
})

it('creates a new logs directory if one does not exist', () => {
expect(() => { app.getPath('logs') }).to.not.throw()

const osLogPath = (logsPaths as any)[process.platform]
expect(fs.existsSync(osLogPath)).to.be.true
})
})

describe('getPath(name)', () => {
it('returns paths that exist', () => {
const paths = [
@@ -729,9 +698,9 @@ describe('app module', () => {
it('does not create a new directory by default', () => {
const badPath = path.join(__dirname, 'music')

expect(fs.existsSync(badPath)).to.be.false
expect(fs.existsSync(badPath)).to.be.false()
app.setPath('music', badPath)
expect(fs.existsSync(badPath)).to.be.false
expect(fs.existsSync(badPath)).to.be.false()

expect(() => { app.getPath(badPath as any) }).to.throw()
})
@@ -923,23 +892,15 @@ describe('app module', () => {
})
})

describe('getFileIcon() API', () => {
// FIXME Get these specs running on Linux CI
ifdescribe(process.platform !== 'linux')('getFileIcon() API', () => {
const iconPath = path.join(__dirname, 'fixtures/assets/icon.ico')
const sizes = {
small: 16,
normal: 32,
large: process.platform === 'win32' ? 32 : 48
}

// (alexeykuzmin): `.skip()` called in `before`
// doesn't affect nested `describe`s.
beforeEach(function () {
// FIXME Get these specs running on Linux CI
if (process.platform === 'linux' && isCI) {
this.skip()
}
})

it('fetches a non-empty icon', async () => {
const icon = await app.getFileIcon(iconPath)
expect(icon.isEmpty()).to.equal(false)
@@ -24,7 +24,7 @@ describeFn('autoUpdater behavior', function () {
if (result.status !== 0 || result.stdout.toString().trim().length === 0) {
// Per https://circleci.com/docs/2.0/env-vars:
// CIRCLE_PR_NUMBER is only present on forked PRs
if (isCI && !process.env.CIRCLE_PR_NUMBER) {
if (process.env.CI && !process.env.CIRCLE_PR_NUMBER) {
throw new Error('No valid signing identity available to run autoUpdater specs')
}
this.skip()
@@ -535,14 +535,7 @@ describe('BrowserWindow module', () => {
describe('BrowserWindow.show()', () => {
it('should focus on window', () => {
w.show()
if (process.platform === 'darwin' && !isCI) {
// on CI, the Electron window will be the only one open, so it'll get
// focus. on not-CI, some other window will have focus, and we don't
// steal focus any more, so we expect isFocused to be false.
expect(w.isFocused()).to.equal(false)
} else {
expect(w.isFocused()).to.equal(true)
}
expect(w.isFocused()).to.equal(true)
})
it('should make the window visible', () => {
w.show()
@@ -2514,7 +2507,7 @@ describe('BrowserWindow module', () => {
expect(visibilityState).to.equal('visible')
})

ifit(!(isCI && process.platform === 'win32'))('visibilityState changes when window is shown inactive', async () => {
ifit(process.platform !== 'win32')('visibilityState changes when window is shown inactive', async () => {
const w = new BrowserWindow({
width: 100,
height: 100,
@@ -1,13 +1,8 @@
import { expect } from 'chai'
import { globalShortcut } from 'electron'
import { ifdescribe } from './spec-helpers'

describe('globalShortcut module', () => {
before(function () {
if (isCI && process.platform === 'win32') {
this.skip()
}
})

ifdescribe(process.platform !== 'win32')('globalShortcut module', () => {
beforeEach(() => {
globalShortcut.unregisterAll()
})
@@ -1,5 +1,5 @@
import { expect } from 'chai'
import { BrowserWindow, globalShortcut, Menu, MenuItem } from 'electron'
import { BrowserWindow, Menu, MenuItem } from 'electron'
import { sortMenuItems } from '../lib/browser/api/menu-utils'
import { closeWindow } from './window-helpers'

@@ -840,97 +840,4 @@ describe('Menu module', function () {
expect(Menu.getApplicationMenu()).to.be.null('application menu')
})
})

describe('menu accelerators', async () => {
const sendRobotjsKey = (key: string, modifiers: string | string[] = [], delay = 500) => {
return new Promise((resolve, reject) => {
try {
require('robotjs').keyTap(key, modifiers)
setTimeout(() => {
resolve()
}, delay)
} catch (e) {
reject(e)
}
})
}

before(async function () {
// --ci flag breaks accelerator and robotjs interaction
if (isCI) {
this.skip()
}

// before accelerator tests, use globalShortcut to test if
// RobotJS is working at all
let isKeyPressed = false
globalShortcut.register('q', () => {
isKeyPressed = true
})
try {
await sendRobotjsKey('q')
} catch (e) {
this.skip()
}

if (!isKeyPressed) {
this.skip()
}

globalShortcut.unregister('q')
})

it('should perform the specified action', async () => {
let hasBeenClicked = false
const menu = Menu.buildFromTemplate([
{
label: 'Test',
submenu: [
{
label: 'Test Item',
accelerator: 'T',
click: (a, b, event) => {
hasBeenClicked = true
expect(event).to.deep.equal({
shiftKey: false,
ctrlKey: false,
altKey: false,
metaKey: false,
triggeredByAccelerator: true
})
},
id: 'test'
}
]
}
])
Menu.setApplicationMenu(menu)
expect(Menu.getApplicationMenu()).to.not.be.null('application menu')
await sendRobotjsKey('t')
expect(hasBeenClicked).to.equal(true)
})

it('should not activate upon clicking another key combination', async () => {
let hasBeenClicked = false
const menu = Menu.buildFromTemplate([
{
label: 'Test',
submenu: [
{
label: 'Test Item',
accelerator: 'T',
click: (a, b, event) => {
hasBeenClicked = true
},
id: 'test'
}
]
}
])
Menu.setApplicationMenu(menu)
expect(Menu.getApplicationMenu()).to.not.be.null('application menu')
await sendRobotjsKey('t', 'shift')
expect(hasBeenClicked).to.equal(false)
})
})
})

0 comments on commit 6781d5e

Please sign in to comment.
You can’t perform that action at this time.