From 971089aeb0c6232853e7133a29f5ae4babaa1b0c Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Mon, 23 Nov 2015 14:07:36 -0500 Subject: [PATCH] fix(build): bail if script/bootstrap fails and enhance test output Have the test output --- build/tasks/spec-task.coffee | 24 +++++++++++++----------- script/cibuild | 2 ++ script/docs | 2 ++ spec/spec-bootstrap.coffee | 3 ++- src/browser/application.coffee | 14 ++++++++++---- src/browser/main.coffee | 7 ++++--- src/browser/main.js | 8 ++++---- src/browser/nylas-window.coffee | 1 + 8 files changed, 38 insertions(+), 23 deletions(-) diff --git a/build/tasks/spec-task.coffee b/build/tasks/spec-task.coffee index 4bc35b415..3b0966f25 100644 --- a/build/tasks/spec-task.coffee +++ b/build/tasks/spec-task.coffee @@ -6,18 +6,20 @@ proc = require 'child_process' executeTests = (test, grunt, done) -> testSucceeded = false testOutput = "" - testProc = proc.spawn(test.cmd, test.args) - testProc.stdout.on 'data', (data) -> - str = data.toString() - testOutput += str - console.log(str) - if str.indexOf(' 0 failures') isnt -1 - testSucceeded = true - testProc.stderr.on 'data', (data) -> - str = data.toString() - testOutput += str - grunt.log.error(str) + testProc = proc.spawn(test.cmd, test.args, {stdio: "inherit"}) + + # testProc.stdout.on 'data', (data) -> + # str = data.toString() + # testOutput += str + # console.log(str) + # if str.indexOf(' 0 failures') isnt -1 + # testSucceeded = true + # + # testProc.stderr.on 'data', (data) -> + # str = data.toString() + # testOutput += str + # grunt.log.error(str) testProc.on 'error', (err) -> grunt.log.error("Process error: #{err}") diff --git a/script/cibuild b/script/cibuild index 9848505df..8c6d78bba 100755 --- a/script/cibuild +++ b/script/cibuild @@ -7,6 +7,8 @@ # The credentials for the Keychain are availble via the Jenkins-injected # KEYCHAIN_ACCESS environment variable. +set -e + echo "---> $(npm --version)" echo "---> $(node --version)" script/bootstrap diff --git a/script/docs b/script/docs index aaa07c081..a80317208 100644 --- a/script/docs +++ b/script/docs @@ -1,5 +1,7 @@ #!/bin/bash +set -e + # Runs script/grunt docs and moves the output to gh-pages branch # This overwrites whatever is in gh-pages mkdir docs/output diff --git a/spec/spec-bootstrap.coffee b/spec/spec-bootstrap.coffee index de1fc9522..391f1e522 100644 --- a/spec/spec-bootstrap.coffee +++ b/spec/spec-bootstrap.coffee @@ -18,7 +18,8 @@ try # Show window synchronously so a focusout doesn't fire on input elements # that are focused in the very first spec run. - NylasEnv.getCurrentWindow().show() unless NylasEnv.getLoadSettings().exitWhenDone + if NylasEnv.getLoadSettings().showSpecsInWindow + NylasEnv.getCurrentWindow().show() {runSpecSuite} = require './jasmine-helper' diff --git a/src/browser/application.coffee b/src/browser/application.coffee index ad7d16500..333483ad5 100644 --- a/src/browser/application.coffee +++ b/src/browser/application.coffee @@ -98,9 +98,10 @@ class Application @launchWithOptions(options) # Opens a new window based on the options provided. - launchWithOptions: ({urlsToOpen, test, devMode, safeMode, specDirectory, specFilePattern, logFile, specsOnCommandLine}) -> + launchWithOptions: ({urlsToOpen, test, devMode, safeMode, specDirectory, specFilePattern, logFile, showSpecsInWindow}) -> if test - @runSpecs({exitWhenDone: specsOnCommandLine, @resourcePath, specDirectory, specFilePattern, logFile}) + exitWhenDone = true + @runSpecs({exitWhenDone, showSpecsInWindow, @resourcePath, specDirectory, specFilePattern, logFile}) else @openWindowsForTokenState() for urlToOpen in (urlsToOpen || []) @@ -214,6 +215,7 @@ class Application @on 'application:run-all-specs', -> @runSpecs exitWhenDone: false + showSpecsInWindow: true resourcePath: @resourcePath safeMode: @windowManager.focusedWindow()?.safeMode @@ -226,6 +228,7 @@ class Application return if not filenames or filenames.length is 0 @runSpecs exitWhenDone: false + showSpecsInWindow: true resourcePath: @resourcePath specDirectory: filenames[0] @@ -469,12 +472,15 @@ class Application # # options - # :exitWhenDone - A Boolean that, if true, will close the window upon - # completion. + # completion and exit the app with the status code of + # 1 if the specs failed and 0 if they passed. + # :showSpecsInWindow - A Boolean that, if true, will run specs in a + # window # :resourcePath - The path to include specs from. # :specPath - The directory to load specs from. # :safeMode - A Boolean that, if true, won't run specs from ~/.nylas/packages # and ~/.nylas/dev/packages, defaults to false. - runSpecs: ({exitWhenDone, resourcePath, specDirectory, specFilePattern, logFile, safeMode}) -> + runSpecs: ({exitWhenDone, showSpecsInWindow, resourcePath, specDirectory, specFilePattern, logFile, safeMode}) -> if resourcePath isnt @resourcePath and not fs.existsSync(resourcePath) resourcePath = @resourcePath diff --git a/src/browser/main.coffee b/src/browser/main.coffee index d92237d5a..b6395f120 100644 --- a/src/browser/main.coffee +++ b/src/browser/main.coffee @@ -129,11 +129,12 @@ parseCommandLine = -> specFilePattern = args['file-pattern'] devResourcePath = process.env.N1_PATH ? process.cwd() + showSpecsInWindow = false + if args['resource-path'] devMode = true resourcePath = args['resource-path'] else - specsOnCommandLine = true # Set resourcePath based on the specDirectory if running specs on N1 core if specDirectory? packageDirectoryPath = path.resolve(specDirectory, '..') @@ -150,7 +151,7 @@ parseCommandLine = -> specDirectory = path.join(devResourcePath, "spec") else if test is "window" specDirectory = path.join(devResourcePath, "spec") - specsOnCommandLine = false + showSpecsInWindow = true else specDirectory = path.resolve(path.join(devResourcePath, "internal_packages", test)) @@ -167,6 +168,6 @@ parseCommandLine = -> resourcePath = normalizeDriveLetterName(resourcePath) devResourcePath = normalizeDriveLetterName(devResourcePath) - {resourcePath, pathsToOpen, urlsToOpen, executedFrom, test, version, pidToKillWhenClosed, devMode, safeMode, newWindow, specDirectory, specsOnCommandLine, logFile, specFilePattern} + {resourcePath, pathsToOpen, urlsToOpen, executedFrom, test, version, pidToKillWhenClosed, devMode, safeMode, newWindow, specDirectory, showSpecsInWindow, logFile, specFilePattern} start() diff --git a/src/browser/main.js b/src/browser/main.js index d42eb4202..88831310d 100644 --- a/src/browser/main.js +++ b/src/browser/main.js @@ -112,7 +112,7 @@ setupCrashReporter = function() {}; parseCommandLine = function() { - var args, devMode, devResourcePath, executedFrom, logFile, newWindow, options, packageDirectoryPath, packageManifest, packageManifestPath, pathsToOpen, pidToKillWhenClosed, ref, ref1, ref2, resourcePath, safeMode, specDirectory, specFilePattern, specsOnCommandLine, test, urlsToOpen, version; + var args, devMode, devResourcePath, executedFrom, logFile, newWindow, options, packageDirectoryPath, packageManifest, packageManifestPath, pathsToOpen, pidToKillWhenClosed, ref, ref1, ref2, resourcePath, safeMode, showSpecsInWindow, specDirectory, specFilePattern, test, urlsToOpen, version; version = app.getVersion(); options = optimist(process.argv.slice(1)); options.usage("N1 v" + version + "\n\nUsage: n1 [options] [path ...]\n\nOne or more paths to files or folders to open may be specified.\n\nFile paths will open in the current window.\n\nFolder paths will open in an existing window if that folder has already been\nopened or a new window if it hasn't.\n\nEnvironment Variables:\nN1_PATH The path from which N1 loads source code in dev mode.\n Defaults to `cwd`."); @@ -153,11 +153,11 @@ logFile = args['log-file']; specFilePattern = args['file-pattern']; devResourcePath = (ref2 = process.env.N1_PATH) != null ? ref2 : process.cwd(); + showSpecsInWindow = false; if (args['resource-path']) { devMode = true; resourcePath = args['resource-path']; } else { - specsOnCommandLine = true; if (specDirectory != null) { packageDirectoryPath = path.resolve(specDirectory, '..'); packageManifestPath = path.join(packageDirectoryPath, 'package.json'); @@ -175,7 +175,7 @@ specDirectory = path.join(devResourcePath, "spec"); } else if (test === "window") { specDirectory = path.join(devResourcePath, "spec"); - specsOnCommandLine = false; + showSpecsInWindow = true; } else { specDirectory = path.resolve(path.join(devResourcePath, "internal_packages", test)); } @@ -210,7 +210,7 @@ safeMode: safeMode, newWindow: newWindow, specDirectory: specDirectory, - specsOnCommandLine: specsOnCommandLine, + showSpecsInWindow: showSpecsInWindow, logFile: logFile, specFilePattern: specFilePattern }; diff --git a/src/browser/nylas-window.coffee b/src/browser/nylas-window.coffee index 9c0be19eb..a66325016 100644 --- a/src/browser/nylas-window.coffee +++ b/src/browser/nylas-window.coffee @@ -24,6 +24,7 @@ class NylasWindow toolbar, resizable, pathToOpen, + showSpecsInWindow, @isSpec, @devMode, @safeMode,