mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-01 13:14:16 +08:00
fix(spec): cleanup N1.sh and make specs fail with exit code 1
This commit is contained in:
parent
78dd69290d
commit
669995961a
2 changed files with 33 additions and 119 deletions
97
N1.sh
97
N1.sh
|
@ -1,103 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This file is sym-linked to the `electron` executable.
|
||||
# It is used by `apm` when calling commands.
|
||||
N1_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd );
|
||||
|
||||
if [ "$(uname)" == 'Darwin' ]; then
|
||||
OS='Mac'
|
||||
ELECTRON_PATH=${ELECTRON_PATH:-$N1_PATH/electron/Electron.app/Contents/MacOS/Electron}
|
||||
elif [ "$(expr substr $(uname -s) 1 5)" == 'Linux' ]; then
|
||||
OS='Linux'
|
||||
ELECTRON_PATH=${ELECTRON_PATH:-$N1_PATH/electron/electron}
|
||||
mkdir -p "$HOME/.nylas"
|
||||
elif [ "$(expr substr $(uname -s) 1 10)" == 'MINGW32_NT' ]; then
|
||||
OS='Cygwin'
|
||||
ELECTRON_PATH=${ELECTRON_PATH:-$N1_PATH/electron/electron.exe}
|
||||
else
|
||||
echo "Your platform ($(uname -a)) is not supported."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while getopts ":wtfvh-:" opt; do
|
||||
case "$opt" in
|
||||
-)
|
||||
case "${OPTARG}" in
|
||||
wait)
|
||||
WAIT=1
|
||||
;;
|
||||
help|version)
|
||||
REDIRECT_STDERR=1
|
||||
EXPECT_OUTPUT=1
|
||||
;;
|
||||
foreground|test)
|
||||
EXPECT_OUTPUT=1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
w)
|
||||
WAIT=1
|
||||
;;
|
||||
h|v)
|
||||
REDIRECT_STDERR=1
|
||||
EXPECT_OUTPUT=1
|
||||
;;
|
||||
f|t)
|
||||
EXPECT_OUTPUT=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $REDIRECT_STDERR ]; then
|
||||
exec 2> /dev/null
|
||||
if [ ! -e "$ELECTRON_PATH" ]; then
|
||||
echo "Can't find the Electron executable at $ELECTRON_PATH. Be sure you have run script/bootstrap first from $N1_PATH or set the ELECTRON_PATH environment variable."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
N1_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd );
|
||||
export N1_PATH
|
||||
|
||||
if [ $OS == 'Mac' ]; then
|
||||
if [ -z "$N1_PATH" ]; then
|
||||
echo "Set the N1_PATH environment variable to the absolute location of the main edgehill folder."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ELECTRON_PATH=${ELECTRON_PATH:-$N1_PATH/electron} # Set ELECTRON_PATH unless it is already set
|
||||
|
||||
# Exit if Electron can't be found
|
||||
if [ ! -d "$ELECTRON_PATH" ]; then
|
||||
echo "Cannot locate electron. Be sure you have run script/bootstrap first from $N1_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# We find the electron executable inside of the electron directory.
|
||||
$ELECTRON_PATH/Electron.app/Contents/MacOS/Electron --executed-from="$(pwd)" --pid=$$ "$@" $N1_PATH
|
||||
|
||||
elif [ $OS == 'Linux' ]; then
|
||||
DOT_INBOX_DIR="$HOME/.nylas"
|
||||
|
||||
mkdir -p "$DOT_INBOX_DIR"
|
||||
|
||||
if [ -z "$N1_PATH" ]; then
|
||||
echo "Set the N1_PATH environment variable to the absolute location of the main N1 folder."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ELECTRON_PATH=${ELECTRON_PATH:-$N1_PATH/electron} # Set ELECTRON_PATH unless it is already set
|
||||
|
||||
# Exit if Electron can't be found
|
||||
if [ ! -d "$ELECTRON_PATH" ]; then
|
||||
echo "Cannot locate electron. Be sure you have run script/bootstrap first from $N1_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# We find the electron executable inside of the electron directory.
|
||||
$ELECTRON_PATH/electron --executed-from="$(pwd)" --pid=$$ "$@" $N1_PATH
|
||||
|
||||
fi
|
||||
|
||||
on_die() {
|
||||
exit 0
|
||||
}
|
||||
trap 'on_die' SIGQUIT SIGTERM
|
||||
|
||||
# If the wait flag is set, don't exit this process until Electron tells it to.
|
||||
if [ $WAIT ]; then
|
||||
while true; do
|
||||
sleep 1
|
||||
done
|
||||
fi
|
||||
$ELECTRON_PATH --executed-from="$(pwd)" --pid=$$ "$@" $N1_PATH
|
||||
exit $?
|
||||
|
|
|
@ -1,42 +1,33 @@
|
|||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
request = require 'request'
|
||||
proc = require 'child_process'
|
||||
childProcess = require 'child_process'
|
||||
|
||||
executeTests = ({cmd, args}, grunt, done) ->
|
||||
testProc = childProcess.spawn(cmd, args)
|
||||
|
||||
executeTests = (test, grunt, done) ->
|
||||
testSucceeded = false
|
||||
testOutput = ""
|
||||
testProc.stdout.pipe(process.stdout)
|
||||
testProc.stderr.pipe(process.stderr)
|
||||
testProc.stdout.on 'data', (data) -> testOutput += data.toString()
|
||||
testProc.stderr.on 'data', (data) -> testOutput += data.toString()
|
||||
|
||||
testProc = proc.spawn(test.cmd, test.args, {stdio: "inherit"})
|
||||
testProc.on 'error', (err) -> grunt.log.error("Process error: #{err}")
|
||||
|
||||
# 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 'exit', (exitCode, signal) ->
|
||||
if exitCode is 0 then done()
|
||||
else notifyOfTestError(testOutput, grunt).then -> done(false)
|
||||
|
||||
testProc.on 'error', (err) ->
|
||||
grunt.log.error("Process error: #{err}")
|
||||
|
||||
testProc.on 'close', (exitCode, signal) ->
|
||||
if testSucceeded and exitCode is 0
|
||||
done()
|
||||
else
|
||||
testOutput = testOutput.replace(/\x1b\[[^m]+m/g, '')
|
||||
url = "https://hooks.slack.com/services/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"
|
||||
request.post
|
||||
url: url
|
||||
json:
|
||||
username: "Edgehill Builds"
|
||||
text: "Aghhh somebody broke the build. ```#{testOutput}```"
|
||||
, (err, httpResponse, body) ->
|
||||
done(false)
|
||||
notifyOfTestError = (testOutput, grunt) -> new Promise (resolve, reject) ->
|
||||
if (process.env("TEST_ERROR_HOOK_URL") ? "").length > 0
|
||||
testOutput = grunt.log.uncolor(testOutput)
|
||||
request.post
|
||||
url: process.env("TEST_ERROR_HOOK_URL")
|
||||
json:
|
||||
username: "Edgehill Builds"
|
||||
text: "Aghhh somebody broke the build. ```#{testOutput}```"
|
||||
, resolve
|
||||
else resolve()
|
||||
|
||||
module.exports = (grunt) ->
|
||||
|
||||
|
@ -50,7 +41,7 @@ module.exports = (grunt) ->
|
|||
|
||||
process.chdir('./spectron')
|
||||
grunt.log.writeln "Current dir: #{process.cwd()}"
|
||||
installProc = proc.exec "#{npmPath} install", (error) ->
|
||||
installProc = childProcess.exec "#{npmPath} install", (error) ->
|
||||
if error?
|
||||
process.chdir('..')
|
||||
grunt.log.error('Failed while running npm install in spectron folder')
|
||||
|
|
Loading…
Reference in a new issue