2015-03-07 17:18:27 +00:00
|
|
|
#!/bin/bash
|
|
|
|
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
2015-03-24 06:58:43 +00:00
|
|
|
case "$(uname -s)" in
|
|
|
|
CYGWIN*) IS_CYGWIN=1 ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
function makePath {
|
|
|
|
local __assignTo=$1
|
|
|
|
local __path=$2
|
|
|
|
if [ ! -z $IS_CYGWIN ]; then
|
|
|
|
__path="`cygpath -aw \"$__path\"`"
|
|
|
|
fi
|
|
|
|
eval $__assignTo="'$__path'"
|
|
|
|
}
|
|
|
|
|
2015-03-08 03:17:44 +00:00
|
|
|
DEBUG=false
|
2015-03-24 04:52:36 +00:00
|
|
|
if [ -z "$FX_EXECUTABLE" ]; then
|
|
|
|
if [ "`uname`" == "Darwin" ]; then
|
|
|
|
FX_EXECUTABLE="/Applications/Firefox.app/Contents/MacOS/firefox"
|
|
|
|
else
|
|
|
|
FX_EXECUTABLE="firefox"
|
|
|
|
fi
|
2015-03-07 17:18:27 +00:00
|
|
|
fi
|
2015-03-24 04:52:36 +00:00
|
|
|
|
2015-03-08 03:17:44 +00:00
|
|
|
FX_ARGS=""
|
2015-03-07 17:18:27 +00:00
|
|
|
|
|
|
|
function usage {
|
|
|
|
cat >&2 <<DONE
|
2015-03-24 04:52:36 +00:00
|
|
|
Usage: $0 [option] [TESTS...]
|
2015-03-07 17:18:27 +00:00
|
|
|
Options
|
2015-06-01 03:59:15 +00:00
|
|
|
-b skip bundled translator/style installation
|
2015-03-08 03:17:44 +00:00
|
|
|
-c open JavaScript console and don't quit on completion
|
2015-06-01 03:59:15 +00:00
|
|
|
-d LEVEL enable debug logging
|
2015-05-29 08:01:40 +00:00
|
|
|
-f stop after first test failure
|
2015-05-31 07:27:03 +00:00
|
|
|
-g only run tests matching the given pattern (grep)
|
2015-06-01 03:59:15 +00:00
|
|
|
-t generate test data and quit
|
2015-03-24 04:52:36 +00:00
|
|
|
-x FX_EXECUTABLE path to Firefox executable (default: $FX_EXECUTABLE)
|
2015-04-16 21:35:38 +00:00
|
|
|
-b skip bundled translator/style installation
|
2015-03-07 17:18:27 +00:00
|
|
|
TESTS set of tests to run (default: all)
|
|
|
|
DONE
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2015-06-01 03:59:15 +00:00
|
|
|
while getopts "bcd:fg:tx:" opt; do
|
2015-03-07 17:18:27 +00:00
|
|
|
case $opt in
|
2015-06-01 03:59:15 +00:00
|
|
|
b)
|
|
|
|
FX_ARGS="$FX_ARGS -ZoteroSkipBundledFiles"
|
|
|
|
;;
|
|
|
|
c)
|
|
|
|
FX_ARGS="$FX_ARGS -jsconsole -noquit"
|
2015-03-07 17:18:27 +00:00
|
|
|
;;
|
2015-03-08 03:17:44 +00:00
|
|
|
d)
|
2015-03-24 04:52:36 +00:00
|
|
|
DEBUG=true
|
2015-06-01 03:59:15 +00:00
|
|
|
DEBUG_LEVEL="$OPTARG"
|
2015-03-24 04:52:36 +00:00
|
|
|
;;
|
2015-05-29 08:01:40 +00:00
|
|
|
f)
|
2015-05-31 07:27:03 +00:00
|
|
|
FX_ARGS="$FX_ARGS -bail"
|
|
|
|
;;
|
|
|
|
g)
|
|
|
|
GREP="$OPTARG"
|
2015-05-29 08:01:40 +00:00
|
|
|
;;
|
2015-06-01 03:59:15 +00:00
|
|
|
t)
|
|
|
|
FX_ARGS="$FX_ARGS -makeTestData"
|
|
|
|
;;
|
|
|
|
x)
|
|
|
|
FX_EXECUTABLE="$OPTARG"
|
2015-03-24 04:52:36 +00:00
|
|
|
;;
|
2015-03-07 17:18:27 +00:00
|
|
|
*)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift $((OPTIND-1)); OPTIND=1
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z $1 ]; then
|
|
|
|
TESTS="all"
|
|
|
|
else
|
|
|
|
ARGS=("${@:1}")
|
|
|
|
function join { local IFS="$1"; shift; echo "$*"; }
|
|
|
|
TESTS="$(join , "${ARGS[@]}")"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Set up profile directory
|
|
|
|
PROFILE="`mktemp -d 2>/dev/null || mktemp -d -t 'zotero-unit'`"
|
|
|
|
mkdir "$PROFILE/extensions"
|
2015-03-24 06:58:43 +00:00
|
|
|
|
|
|
|
makePath ZOTERO_UNIT_PATH "$CWD"
|
|
|
|
echo "$ZOTERO_UNIT_PATH" > "$PROFILE/extensions/zotero-unit@zotero.org"
|
|
|
|
|
|
|
|
makePath ZOTERO_PATH "`dirname "$CWD"`"
|
|
|
|
echo "$ZOTERO_PATH" > "$PROFILE/extensions/zotero@chnm.gmu.edu"
|
|
|
|
|
2015-04-13 00:28:50 +00:00
|
|
|
# Create data directory
|
|
|
|
mkdir "$PROFILE/zotero"
|
|
|
|
|
2015-03-08 03:17:44 +00:00
|
|
|
cat <<EOF > "$PROFILE/prefs.js"
|
|
|
|
user_pref("extensions.autoDisableScopes", 0);
|
2015-04-26 20:39:19 +00:00
|
|
|
user_pref("browser.uitour.enabled", false);
|
2015-05-05 06:39:31 +00:00
|
|
|
user_pref("browser.shell.checkDefaultBrowser", false);
|
2015-03-08 03:17:44 +00:00
|
|
|
user_pref("extensions.zotero.debug.log", $DEBUG);
|
2015-06-01 03:59:15 +00:00
|
|
|
user_pref("extensions.zotero.debug.level", $DEBUG_LEVEL);
|
2015-04-15 04:48:03 +00:00
|
|
|
user_pref("extensions.zotero.debug.time", $DEBUG);
|
2015-03-09 18:39:04 +00:00
|
|
|
user_pref("extensions.zotero.firstRunGuidance", false);
|
|
|
|
user_pref("extensions.zotero.firstRun2", false);
|
2015-05-02 20:30:25 +00:00
|
|
|
user_pref("extensions.zotero.reportTranslationFailure", false);
|
2015-03-08 03:17:44 +00:00
|
|
|
EOF
|
2015-03-07 17:18:27 +00:00
|
|
|
|
2015-03-31 04:52:38 +00:00
|
|
|
# -v flag on Windows makes Firefox process hang
|
2015-03-31 04:09:14 +00:00
|
|
|
if [ -z $IS_CYGWIN ]; then
|
|
|
|
echo "`MOZ_NO_REMOTE=1 NO_EM_RESTART=1 \"$FX_EXECUTABLE\" -v`"
|
|
|
|
fi
|
|
|
|
|
2015-03-24 04:52:36 +00:00
|
|
|
|
2015-03-31 04:52:38 +00:00
|
|
|
if [ "$TRAVIS" = true ]; then
|
2015-06-01 03:59:15 +00:00
|
|
|
FX_ARGS="$FX_ARGS -ZoteroNoUserInput"
|
2015-03-31 04:52:38 +00:00
|
|
|
fi
|
|
|
|
|
2015-05-28 01:42:37 +00:00
|
|
|
# Clean up on exit
|
|
|
|
trap "{ rm -rf \"$PROFILE\"; }" EXIT
|
|
|
|
|
2015-03-24 06:58:43 +00:00
|
|
|
makePath FX_PROFILE "$PROFILE"
|
|
|
|
MOZ_NO_REMOTE=1 NO_EM_RESTART=1 "$FX_EXECUTABLE" -profile "$FX_PROFILE" \
|
2015-05-31 07:27:03 +00:00
|
|
|
-chrome chrome://zotero-unit/content/runtests.html -test "$TESTS" -grep "$GREP" $FX_ARGS
|
2015-03-07 17:18:27 +00:00
|
|
|
|
|
|
|
# Check for success
|
|
|
|
test -e "$PROFILE/success"
|
|
|
|
STATUS=$?
|
|
|
|
|
|
|
|
exit $STATUS
|