2015-03-07 17:18:27 +00:00
|
|
|
#!/bin/bash
|
2018-01-19 00:20:24 +00:00
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
ROOT_DIR="$( cd "$( dirname "$SCRIPT_DIR" )" && pwd )"
|
2015-03-07 17:18:27 +00:00
|
|
|
|
2017-06-03 16:54:06 +00:00
|
|
|
case "$OSTYPE" in
|
|
|
|
msys*|mingw*|cygwin*) IS_CYGWIN=1 ;;
|
2015-03-24 06:58:43 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
function makePath {
|
|
|
|
local __assignTo=$1
|
|
|
|
local __path=$2
|
|
|
|
if [ ! -z $IS_CYGWIN ]; then
|
|
|
|
__path="`cygpath -aw \"$__path\"`"
|
|
|
|
fi
|
|
|
|
eval $__assignTo="'$__path'"
|
|
|
|
}
|
|
|
|
|
2022-06-09 07:00:54 +00:00
|
|
|
if [ -z "$Z_EXECUTABLE" ]; then
|
2015-03-24 04:52:36 +00:00
|
|
|
if [ "`uname`" == "Darwin" ]; then
|
2023-04-27 04:50:14 +00:00
|
|
|
Z_EXECUTABLE="$ROOT_DIR/app/staging/Zotero.app/Contents/MacOS/zotero"
|
2015-03-24 04:52:36 +00:00
|
|
|
else
|
2023-04-27 04:50:14 +00:00
|
|
|
Z_EXECUTABLE="$ROOT_DIR/app/staging/Zotero-x86_64/zotero"
|
2015-03-24 04:52:36 +00:00
|
|
|
fi
|
2015-03-07 17:18:27 +00:00
|
|
|
fi
|
2015-03-24 04:52:36 +00:00
|
|
|
|
2016-08-16 08:03:07 +00:00
|
|
|
if [ -z "$DISPLAY" ]; then
|
2022-06-09 07:00:54 +00:00
|
|
|
Z_ARGS=""
|
2016-08-16 08:03:07 +00:00
|
|
|
else
|
2022-06-09 07:00:54 +00:00
|
|
|
Z_ARGS="--class=ZTestFirefox"
|
2016-08-16 08:03:07 +00:00
|
|
|
fi
|
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
|
2017-06-20 04:47:13 +00:00
|
|
|
-e TEST end at the given test
|
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)
|
2016-02-22 21:00:15 +00:00
|
|
|
-h display this help
|
2016-12-16 09:21:21 +00:00
|
|
|
-s TEST start at the given test
|
2015-06-01 03:59:15 +00:00
|
|
|
-t generate test data and quit
|
2022-06-09 07:00:54 +00:00
|
|
|
-x EXECUTABLE path to Zotero executable (default: $Z_EXECUTABLE)
|
2015-03-07 17:18:27 +00:00
|
|
|
TESTS set of tests to run (default: all)
|
|
|
|
DONE
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2016-04-24 08:02:33 +00:00
|
|
|
DEBUG=false
|
|
|
|
DEBUG_LEVEL=5
|
2017-06-20 04:47:13 +00:00
|
|
|
while getopts "bcd:e:fg:hs:tx:" opt; do
|
2015-03-07 17:18:27 +00:00
|
|
|
case $opt in
|
2015-06-01 03:59:15 +00:00
|
|
|
b)
|
2022-06-09 07:00:54 +00:00
|
|
|
Z_ARGS="$Z_ARGS -ZoteroSkipBundledFiles"
|
2015-06-01 03:59:15 +00:00
|
|
|
;;
|
|
|
|
c)
|
2022-06-09 07:00:54 +00:00
|
|
|
Z_ARGS="$Z_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
|
|
|
;;
|
2017-06-20 04:47:13 +00:00
|
|
|
e)
|
|
|
|
if [[ -z "$OPTARG" ]] || [[ ${OPTARG:0:1} = "-" ]]; then
|
|
|
|
usage
|
|
|
|
fi
|
2022-06-09 07:00:54 +00:00
|
|
|
Z_ARGS="$Z_ARGS -stopAtTestFile $OPTARG"
|
2017-06-20 04:47:13 +00:00
|
|
|
;;
|
2015-05-29 08:01:40 +00:00
|
|
|
f)
|
2022-06-09 07:00:54 +00:00
|
|
|
Z_ARGS="$Z_ARGS -bail"
|
2015-05-31 07:27:03 +00:00
|
|
|
;;
|
|
|
|
g)
|
|
|
|
GREP="$OPTARG"
|
2015-05-29 08:01:40 +00:00
|
|
|
;;
|
2016-02-22 21:00:15 +00:00
|
|
|
h)
|
|
|
|
usage
|
|
|
|
;;
|
2016-12-16 09:21:21 +00:00
|
|
|
s)
|
|
|
|
if [[ -z "$OPTARG" ]] || [[ ${OPTARG:0:1} = "-" ]]; then
|
|
|
|
usage
|
|
|
|
fi
|
2022-06-09 07:00:54 +00:00
|
|
|
Z_ARGS="$Z_ARGS -startAtTestFile $OPTARG"
|
2016-12-16 09:21:21 +00:00
|
|
|
;;
|
2015-06-01 03:59:15 +00:00
|
|
|
t)
|
2022-06-09 07:00:54 +00:00
|
|
|
Z_ARGS="$Z_ARGS -makeTestData"
|
2015-06-01 03:59:15 +00:00
|
|
|
;;
|
|
|
|
x)
|
2022-06-09 07:00:54 +00:00
|
|
|
Z_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
|
|
|
|
|
2016-01-26 09:37:01 +00:00
|
|
|
# Increase open files limit
|
|
|
|
#
|
|
|
|
# Mozilla file functions (OS.File.move()/copy(), NetUtil.asyncFetch/asyncCopy()) can leave file
|
|
|
|
# descriptors open for a few seconds (even with an explicit inputStream.close() in the case of
|
|
|
|
# the latter), so a source installation that copies ~500 translators and styles (with fds for
|
|
|
|
# source and target) can exceed the default 1024 limit.
|
2016-10-21 09:28:49 +00:00
|
|
|
ulimit -n 4096
|
2016-01-26 09:37:01 +00:00
|
|
|
|
2015-03-07 17:18:27 +00:00
|
|
|
# Set up profile directory
|
2016-11-22 06:39:33 +00:00
|
|
|
TEMPDIR="`mktemp -d 2>/dev/null || mktemp -d -t 'zotero-unit'`"
|
|
|
|
PROFILE="$TEMPDIR/profile"
|
2022-06-09 07:00:54 +00:00
|
|
|
mkdir -p "$PROFILE"
|
2015-03-24 06:58:43 +00:00
|
|
|
|
2018-01-19 00:20:24 +00:00
|
|
|
makePath ZOTERO_PATH "$ROOT_DIR/build"
|
2017-05-24 05:01:22 +00:00
|
|
|
|
2015-04-13 00:28:50 +00:00
|
|
|
# Create data directory
|
2016-11-22 06:39:33 +00:00
|
|
|
mkdir "$TEMPDIR/Zotero"
|
2015-04-13 00:28:50 +00:00
|
|
|
|
2022-06-09 07:00:54 +00:00
|
|
|
touch "$PROFILE/prefs.js"
|
2018-09-26 06:49:01 +00:00
|
|
|
cat <<EOF >> "$PROFILE/prefs.js"
|
2017-10-02 02:06:35 +00:00
|
|
|
user_pref("app.update.enabled", false);
|
2023-04-15 05:21:45 +00:00
|
|
|
//user_pref("dom.max_chrome_script_run_time", 0);
|
2017-12-08 05:10:59 +00:00
|
|
|
// It would be better to leave this on and handle it in Sinon's FakeXMLHttpRequest
|
|
|
|
user_pref("extensions.zotero.sync.server.compressData", false);
|
2018-08-24 23:44:42 +00:00
|
|
|
user_pref("extensions.zotero.automaticScraperUpdates", 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);
|
2017-11-18 03:36:50 +00:00
|
|
|
user_pref("extensions.zotero.firstRun.skipFirefoxProfileAccessCheck", true);
|
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-06-04 04:47:58 +00:00
|
|
|
user_pref("extensions.zotero.httpServer.enabled", true);
|
2015-06-11 20:06:32 +00:00
|
|
|
user_pref("extensions.zotero.backup.numBackups", 0);
|
2016-04-01 06:49:50 +00:00
|
|
|
user_pref("extensions.zotero.sync.autoSync", false);
|
2023-04-15 05:21:45 +00:00
|
|
|
user_pref("extensions.zoteroMacWordIntegration.installed", true);
|
|
|
|
user_pref("extensions.zoteroMacWordIntegration.skipInstallation", true);
|
|
|
|
user_pref("extensions.zoteroWinWordIntegration.skipInstallation", true);
|
|
|
|
user_pref("extensions.zoteroOpenOfficeIntegration.skipInstallation", true);
|
2015-03-08 03:17:44 +00:00
|
|
|
EOF
|
2015-03-07 17:18:27 +00:00
|
|
|
|
2021-03-21 21:39:40 +00:00
|
|
|
if [ -n "$CI" ]; then
|
2022-06-09 07:00:54 +00:00
|
|
|
Z_ARGS="$Z_ARGS -ZoteroAutomatedTest -ZoteroTestTimeout 15000"
|
2015-03-31 04:52:38 +00:00
|
|
|
fi
|
|
|
|
|
2015-05-28 01:42:37 +00:00
|
|
|
# Clean up on exit
|
2016-11-22 06:39:33 +00:00
|
|
|
trap "{ rm -rf \"$TEMPDIR\"; }" EXIT
|
2015-05-28 01:42:37 +00:00
|
|
|
|
2017-07-01 10:28:13 +00:00
|
|
|
# Check if build watch process is running
|
|
|
|
# If not, run now
|
2021-03-21 21:39:40 +00:00
|
|
|
if [[ -z "$CI" ]] && ! ps | grep scripts/build.js | grep -v grep > /dev/null; then
|
2017-07-01 10:28:13 +00:00
|
|
|
echo
|
|
|
|
echo "Running JS build process"
|
2018-01-19 00:20:24 +00:00
|
|
|
cd "$ROOT_DIR"
|
2017-10-27 05:08:48 +00:00
|
|
|
npm run build || exit $?
|
2017-07-01 10:28:13 +00:00
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
2023-04-27 04:50:14 +00:00
|
|
|
ZOTERO_INCLUDE_TESTS=1 "$ROOT_DIR/app/scripts/dir_build" -q
|
2022-06-09 07:00:54 +00:00
|
|
|
|
2015-03-24 06:58:43 +00:00
|
|
|
makePath FX_PROFILE "$PROFILE"
|
2022-06-09 07:00:54 +00:00
|
|
|
MOZ_NO_REMOTE=1 NO_EM_RESTART=1 "$Z_EXECUTABLE" -profile "$FX_PROFILE" -jsconsole \
|
|
|
|
-chrome chrome://zotero-unit/content/runtests.html -test "$TESTS" -grep "$GREP" -ZoteroTest $Z_ARGS
|
2015-03-07 17:18:27 +00:00
|
|
|
|
|
|
|
# Check for success
|
|
|
|
test -e "$PROFILE/success"
|
|
|
|
STATUS=$?
|
|
|
|
|
2018-03-01 08:38:46 +00:00
|
|
|
exit $STATUS
|