mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-19 14:40:26 +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
|
#!/bin/bash
|
||||||
|
|
||||||
# This file is sym-linked to the `electron` executable.
|
N1_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd );
|
||||||
# It is used by `apm` when calling commands.
|
|
||||||
|
|
||||||
if [ "$(uname)" == 'Darwin' ]; then
|
if [ "$(uname)" == 'Darwin' ]; then
|
||||||
OS='Mac'
|
OS='Mac'
|
||||||
|
ELECTRON_PATH=${ELECTRON_PATH:-$N1_PATH/electron/Electron.app/Contents/MacOS/Electron}
|
||||||
elif [ "$(expr substr $(uname -s) 1 5)" == 'Linux' ]; then
|
elif [ "$(expr substr $(uname -s) 1 5)" == 'Linux' ]; then
|
||||||
OS='Linux'
|
OS='Linux'
|
||||||
|
ELECTRON_PATH=${ELECTRON_PATH:-$N1_PATH/electron/electron}
|
||||||
|
mkdir -p "$HOME/.nylas"
|
||||||
elif [ "$(expr substr $(uname -s) 1 10)" == 'MINGW32_NT' ]; then
|
elif [ "$(expr substr $(uname -s) 1 10)" == 'MINGW32_NT' ]; then
|
||||||
OS='Cygwin'
|
OS='Cygwin'
|
||||||
|
ELECTRON_PATH=${ELECTRON_PATH:-$N1_PATH/electron/electron.exe}
|
||||||
else
|
else
|
||||||
echo "Your platform ($(uname -a)) is not supported."
|
echo "Your platform ($(uname -a)) is not supported."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while getopts ":wtfvh-:" opt; do
|
if [ ! -e "$ELECTRON_PATH" ]; then
|
||||||
case "$opt" in
|
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
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
N1_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd );
|
$ELECTRON_PATH --executed-from="$(pwd)" --pid=$$ "$@" $N1_PATH
|
||||||
export N1_PATH
|
exit $?
|
||||||
|
|
||||||
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
|
|
||||||
|
|
|
@ -1,42 +1,33 @@
|
||||||
fs = require 'fs'
|
fs = require 'fs'
|
||||||
path = require 'path'
|
path = require 'path'
|
||||||
request = require 'request'
|
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 = ""
|
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) ->
|
testProc.on 'exit', (exitCode, signal) ->
|
||||||
# str = data.toString()
|
if exitCode is 0 then done()
|
||||||
# testOutput += str
|
else notifyOfTestError(testOutput, grunt).then -> done(false)
|
||||||
# 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) ->
|
notifyOfTestError = (testOutput, grunt) -> new Promise (resolve, reject) ->
|
||||||
grunt.log.error("Process error: #{err}")
|
if (process.env("TEST_ERROR_HOOK_URL") ? "").length > 0
|
||||||
|
testOutput = grunt.log.uncolor(testOutput)
|
||||||
testProc.on 'close', (exitCode, signal) ->
|
request.post
|
||||||
if testSucceeded and exitCode is 0
|
url: process.env("TEST_ERROR_HOOK_URL")
|
||||||
done()
|
json:
|
||||||
else
|
username: "Edgehill Builds"
|
||||||
testOutput = testOutput.replace(/\x1b\[[^m]+m/g, '')
|
text: "Aghhh somebody broke the build. ```#{testOutput}```"
|
||||||
url = "https://hooks.slack.com/services/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"
|
, resolve
|
||||||
request.post
|
else resolve()
|
||||||
url: url
|
|
||||||
json:
|
|
||||||
username: "Edgehill Builds"
|
|
||||||
text: "Aghhh somebody broke the build. ```#{testOutput}```"
|
|
||||||
, (err, httpResponse, body) ->
|
|
||||||
done(false)
|
|
||||||
|
|
||||||
module.exports = (grunt) ->
|
module.exports = (grunt) ->
|
||||||
|
|
||||||
|
@ -50,7 +41,7 @@ module.exports = (grunt) ->
|
||||||
|
|
||||||
process.chdir('./spectron')
|
process.chdir('./spectron')
|
||||||
grunt.log.writeln "Current dir: #{process.cwd()}"
|
grunt.log.writeln "Current dir: #{process.cwd()}"
|
||||||
installProc = proc.exec "#{npmPath} install", (error) ->
|
installProc = childProcess.exec "#{npmPath} install", (error) ->
|
||||||
if error?
|
if error?
|
||||||
process.chdir('..')
|
process.chdir('..')
|
||||||
grunt.log.error('Failed while running npm install in spectron folder')
|
grunt.log.error('Failed while running npm install in spectron folder')
|
||||||
|
|
Loading…
Reference in a new issue