Do not write to stdout in Electron when running on win32 CI machine
authorCheng Zhao <zcbenz@gmail.com>
Sat, 30 Apr 2016 08:05:52 +0000 (17:05 +0900)
committerCheng Zhao <zcbenz@gmail.com>
Sat, 30 Apr 2016 08:08:51 +0000 (17:08 +0900)
This makes Electron crash on CI machine somehow.

script/cibuild
script/test.py
spec/static/main.js

index 8d21e3a4024468811db87191abc4dd3e19efd6c1..3a141eac099717b0d732bb276eabb374e9c1a264 100755 (executable)
@@ -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'])
 
 
index 28aeac9dc1ff012301f271fd7831223c13598b86..2acf1f7154a8cf4d72d2ce603c04f12691eb74bf 100755 (executable)
@@ -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())
index 84e9ba3da55d62557db8188e112a52ccebf9ebde..025ff394bc661f3f14d123b897c40b160c1140e1 100644 (file)
@@ -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)