Skip to content

Instantly share code, notes, and snippets.

@misterdjules
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save misterdjules/19868bfcfec103cc16d7 to your computer and use it in GitHub Desktop.
Save misterdjules/19868bfcfec103cc16d7 to your computer and use it in GitHub Desktop.
test-v0.12.sh
#!/bin/env bash
#set -x
TESTS_DIR="$(pwd)/app-tests"
NODE_BIN=${NODE_BIN:-$(pwd)/out/Release/node}
t_plan() {
printf "1..%d\n" "$1"
}
t_ok() {
local descr=${1:+" - "}$1
echo "ok$descr"
}
t_fail() {
local descr=${1:+" - "}$1
echo "not ok$descr"
}
launch_npm_test()
{
local APP_DIR=$1
local NODE_VER=$(${NODE_BIN} -v | sed 's/[^0-9\.]//g')
(cd ${APP_DIR} && \
sed -i -e "s/\"node\":.*\".*\"/\"node\":\"~${NODE_VER}\"/" package.json && \
${NODE_BIN} `which npm` install 1> ${APP_DIR}-npm-install.log 2>${APP_DIR}-npm-install-err.log && \
${NODE_BIN} `which npm` test 1> ${APP_DIR}-test-out.log 2> ${APP_DIR}-test-err.log)
}
test_app ()
{
local REPO_URL=$1
local APP_NAME=$(echo ${REPO_URL} | sed -E 's/.*\/(.*)\.git/\1/')
local APP_DIR="${TESTS_DIR}/${APP_NAME}"
git clone ${REPO_URL} ${APP_DIR} &>/dev/null
launch_npm_test ${APP_DIR}
if [ $? -eq 0 ]; then
t_ok $APP_NAME
else
t_fail $APP_NAME
if [ -s ${APP_DIR}-npm-install-err.log ]; then
cat ${APP_DIR}-npm-install-err.log | sed 's/^/#/'
fi
cat ${APP_DIR}-test-err.log | sed 's/^/#/'
fi
}
# Needs casperjs and phantomjs for Ghost
# Needs grunt-cli for Grunt.js
APPS="git://github.com/TryGhost/Ghost.git
git://github.com/npm/npm.git
git://github.com/Automattic/socket.io.git
git://github.com/strongloop/express.git
git://github.com/hapijs/hapi.git
git://github.com/mikeal/request.git
git://github.com/caolan/async.git
git://github.com/gruntjs/grunt.git
git://github.com/lodash/lodash.git
git://github.com/gulpjs/gulp.git
git://github.com/visionmedia/mocha.git
git://github.com/LearnBoost/mongoose.git
"
t_plan $(echo ${APPS} | tr " " "\n" | wc -l)
rm -rf ${TESTS_DIR}
for APP in ${APPS}; do
test_app ${APP}
done
rm -rf ${TESTS_DIR}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment