From 8aa88067ca0cef906e7f7bda97239c09335b4fcf Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 30 Apr 2016 17:05:52 +0900 Subject: [PATCH] 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 8d21e3a40244..3a141eac0997 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 28aeac9dc1ff..2acf1f7154a8 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 84e9ba3da55d..025ff394bc66 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)