Do not write to stdout in Electron when running on win32 CI machine

This makes Electron crash on CI machine somehow.
This commit is contained in:
Cheng Zhao 2016-04-30 17:05:52 +09:00
parent 6756f8c7af
commit 8aa88067ca
3 changed files with 22 additions and 9 deletions

View file

@ -39,7 +39,6 @@ def main():
if os.environ.has_key('TARGET_ARCH'): if os.environ.has_key('TARGET_ARCH'):
target_arch = os.environ['TARGET_ARCH'] target_arch = os.environ['TARGET_ARCH']
is_appveyor = (os.getenv('APPVEYOR') == 'True')
is_travis = (os.getenv('TRAVIS') == 'true') is_travis = (os.getenv('TRAVIS') == 'true')
if is_travis and PLATFORM == 'linux': if is_travis and PLATFORM == 'linux':
print 'Setup travis CI' print 'Setup travis CI'
@ -76,8 +75,10 @@ def main():
run_script('create-dist.py') run_script('create-dist.py')
run_script('upload.py') run_script('upload.py')
else: else:
if PLATFORM == 'win32':
os.environ['OUTPUT_TO_FILE'] = 'output.log'
run_script('build.py', ['-c', 'D']) run_script('build.py', ['-c', 'D'])
if not is_appveyor and target_arch == 'x64': if target_arch == 'x64':
run_script('test.py', ['--ci']) run_script('test.py', ['--ci'])

View file

@ -32,6 +32,11 @@ def main():
subprocess.check_call([atom_shell, 'spec'] + sys.argv[1:]) 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__': if __name__ == '__main__':
sys.exit(main()) sys.exit(main())

View file

@ -7,8 +7,10 @@ const ipcMain = electron.ipcMain
const dialog = electron.dialog const dialog = electron.dialog
const BrowserWindow = electron.BrowserWindow const BrowserWindow = electron.BrowserWindow
const fs = require('fs')
const path = require('path') const path = require('path')
const url = require('url') const url = require('url')
const util = require('util')
var argv = require('yargs') var argv = require('yargs')
.boolean('ci') .boolean('ci')
@ -35,13 +37,18 @@ ipcMain.on('message', function (event, arg) {
event.sender.send('message', arg) event.sender.send('message', arg)
}) })
ipcMain.on('console.log', function (event, args) { // Write output to file if OUTPUT_TO_FILE is defined.
console.error.apply(console, args) const outputToFile = process.env.OUTPUT_TO_FILE
}) const print = function (_, args) {
let output = util.format.apply(null, args)
ipcMain.on('console.error', function (event, args) { if (outputToFile) {
console.error.apply(console, args) 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) { ipcMain.on('process.exit', function (event, code) {
process.exit(code) process.exit(code)