From 6756f8c7af799c4a99cc7c9f5d7faaff655fd4d0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 30 Apr 2016 15:38:23 +0900 Subject: [PATCH 1/8] Make win32 CI machine run tests --- script/cibuild | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/cibuild b/script/cibuild index 59437837aa1..8d21e3a4024 100755 --- a/script/cibuild +++ b/script/cibuild @@ -39,6 +39,7 @@ def main(): if os.environ.has_key('TARGET_ARCH'): target_arch = os.environ['TARGET_ARCH'] + is_appveyor = (os.getenv('APPVEYOR') == 'True') is_travis = (os.getenv('TRAVIS') == 'true') if is_travis and PLATFORM == 'linux': print 'Setup travis CI' @@ -76,7 +77,7 @@ def main(): run_script('upload.py') else: run_script('build.py', ['-c', 'D']) - if PLATFORM != 'win32' and target_arch == 'x64': + if not is_appveyor and target_arch == 'x64': run_script('test.py', ['--ci']) From 8aa88067ca0cef906e7f7bda97239c09335b4fcf Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 30 Apr 2016 17:05:52 +0900 Subject: [PATCH 2/8] Do not write to stdout in Electron when running on win32 CI machine This makes Electron crash on CI machine somehow. --- script/cibuild | 5 +++-- script/test.py | 5 +++++ spec/static/main.js | 21 ++++++++++++++------- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/script/cibuild b/script/cibuild index 8d21e3a4024..3a141eac099 100755 --- a/script/cibuild +++ b/script/cibuild @@ -39,7 +39,6 @@ def main(): if os.environ.has_key('TARGET_ARCH'): target_arch = os.environ['TARGET_ARCH'] - is_appveyor = (os.getenv('APPVEYOR') == 'True') is_travis = (os.getenv('TRAVIS') == 'true') if is_travis and PLATFORM == 'linux': print 'Setup travis CI' @@ -76,8 +75,10 @@ def main(): run_script('create-dist.py') run_script('upload.py') else: + if PLATFORM == 'win32': + os.environ['OUTPUT_TO_FILE'] = 'output.log' run_script('build.py', ['-c', 'D']) - if not is_appveyor and target_arch == 'x64': + if target_arch == 'x64': run_script('test.py', ['--ci']) diff --git a/script/test.py b/script/test.py index 28aeac9dc1f..2acf1f7154a 100755 --- a/script/test.py +++ b/script/test.py @@ -32,6 +32,11 @@ def main(): subprocess.check_call([atom_shell, 'spec'] + sys.argv[1:]) + if os.environ.has_key('OUTPUT_TO_FILE'): + output_to_file = os.environ['OUTPUT_TO_FILE'] + with open(output_to_file, 'r') as f: + print f.read() + if __name__ == '__main__': sys.exit(main()) diff --git a/spec/static/main.js b/spec/static/main.js index 84e9ba3da55..025ff394bc6 100644 --- a/spec/static/main.js +++ b/spec/static/main.js @@ -7,8 +7,10 @@ const ipcMain = electron.ipcMain const dialog = electron.dialog const BrowserWindow = electron.BrowserWindow +const fs = require('fs') const path = require('path') const url = require('url') +const util = require('util') var argv = require('yargs') .boolean('ci') @@ -35,13 +37,18 @@ ipcMain.on('message', function (event, arg) { event.sender.send('message', arg) }) -ipcMain.on('console.log', function (event, args) { - console.error.apply(console, args) -}) - -ipcMain.on('console.error', function (event, args) { - console.error.apply(console, args) -}) +// Write output to file if OUTPUT_TO_FILE is defined. +const outputToFile = process.env.OUTPUT_TO_FILE +const print = function (_, args) { + let output = util.format.apply(null, args) + if (outputToFile) { + fs.appendFileSync(outputToFile, output + '\n') + } else { + console.error(output) + } +} +ipcMain.on('console.log', print) +ipcMain.on('console.error', print) ipcMain.on('process.exit', function (event, code) { process.exit(code) From 3dcf69eab3d6deabd26f5c05c8f6e2cc409794af Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 30 Apr 2016 17:17:23 +0900 Subject: [PATCH 3/8] Also run tests on 32bit Windows --- script/cibuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/cibuild b/script/cibuild index 3a141eac099..7d025b4e82c 100755 --- a/script/cibuild +++ b/script/cibuild @@ -78,7 +78,7 @@ def main(): if PLATFORM == 'win32': os.environ['OUTPUT_TO_FILE'] = 'output.log' run_script('build.py', ['-c', 'D']) - if target_arch == 'x64': + if PLATFORM == 'win32' or target_arch == 'x64': run_script('test.py', ['--ci']) From b68a25835fe68d7a8cab44ad47aabd5e005f7236 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 30 Apr 2016 17:47:29 +0900 Subject: [PATCH 4/8] Make sure output is written when test fails --- script/test.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/script/test.py b/script/test.py index 2acf1f7154a..85061db5746 100755 --- a/script/test.py +++ b/script/test.py @@ -30,13 +30,19 @@ def main(): else: atom_shell = os.path.join(SOURCE_ROOT, 'out', config, PROJECT_NAME) - subprocess.check_call([atom_shell, 'spec'] + sys.argv[1:]) + returncode = 0 + try: + subprocess.check_call([atom_shell, 'spec'] + sys.argv[1:]) + except subprocess.CalledProcessError as e: + returncode = e.returncode if os.environ.has_key('OUTPUT_TO_FILE'): output_to_file = os.environ['OUTPUT_TO_FILE'] with open(output_to_file, 'r') as f: print f.read() + return returncode + if __name__ == '__main__': sys.exit(main()) From 2a55d935015e73baaae87dd341ad01ef13b54152 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 30 Apr 2016 17:52:53 +0900 Subject: [PATCH 5/8] Remove the output file after testing --- script/test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script/test.py b/script/test.py index 85061db5746..5adfd4eed6c 100755 --- a/script/test.py +++ b/script/test.py @@ -4,7 +4,7 @@ import os import subprocess import sys -from lib.util import atom_gyp +from lib.util import atom_gyp, rm_rf SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) @@ -40,6 +40,8 @@ def main(): output_to_file = os.environ['OUTPUT_TO_FILE'] with open(output_to_file, 'r') as f: print f.read() + rm_rf(output_to_file) + return returncode From 214eb0430c823f5196cc5989a6189bd774caa142 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 30 Apr 2016 18:21:18 +0900 Subject: [PATCH 6/8] Fix a few failing tests on Windows --- spec/api-browser-window-spec.js | 5 +++-- spec/chromium-spec.js | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index c364b916c3a..e76821020bd 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -173,11 +173,12 @@ describe('browser-window module', function () { }) it('does not crash in did-fail-provisional-load handler', function (done) { + this.timeout(10000) w.webContents.once('did-fail-provisional-load', function () { - w.loadURL('http://localhost:11111') + w.loadURL('http://127.0.0.1:11111') done() }) - w.loadURL('http://localhost:11111') + w.loadURL('http://127.0.0.1:11111') }) }) diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index 1d37d0fe051..706447c00dd 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -97,6 +97,9 @@ describe('chromium feature', function () { if (isCI && process.platform === 'linux') { return } + if (isCI && process.platform === 'win32') { + return + } it('can return labels of enumerated devices', function (done) { navigator.mediaDevices.enumerateDevices().then((devices) => { @@ -327,6 +330,10 @@ describe('chromium feature', function () { }) describe('webgl', function () { + if (isCI && process.platform === 'win32') { + return + } + it('can be get as context in canvas', function () { if (process.platform === 'linux') return From 33370b18b3f468a3eb501e45c35626cdb031a81d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 30 Apr 2016 20:41:45 +0900 Subject: [PATCH 7/8] Run tests for branches on appveyor --- appveyor.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 0fa0c0d9bdd..a3fd5192558 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,10 +14,6 @@ install: - cmd: SET PATH=C:\python27;%PATH% - cmd: python script/cibuild -branches: - only: - - master - # disable build and test pahses build: off test: off From f65f8918c95ed2b83651309d48a91bb9b60f211d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 30 Apr 2016 20:51:09 +0900 Subject: [PATCH 8/8] Fix specs on Windows when running without desktop session --- spec/api-desktop-capturer-spec.js | 6 ++++++ spec/chromium-spec.js | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/spec/api-desktop-capturer-spec.js b/spec/api-desktop-capturer-spec.js index 68ab2463087..35b7248ed5e 100644 --- a/spec/api-desktop-capturer-spec.js +++ b/spec/api-desktop-capturer-spec.js @@ -1,7 +1,13 @@ const assert = require('assert') const desktopCapturer = require('electron').desktopCapturer +const isCI = require('electron').remote.getGlobal('isCi') + describe('desktopCapturer', function () { + if (isCI && process.platform === 'win32') { + return + } + it('should return a non-empty array of sources', function (done) { desktopCapturer.getSources({ types: ['window', 'screen'] diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index 706447c00dd..577f020128a 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -62,6 +62,10 @@ describe('chromium feature', function () { w.loadURL(url) }) + if (isCI && process.platform === 'win32') { + return + } + it('is set correctly when window is inactive', function (done) { w = new BrowserWindow({ show: false