fx-compat: Restore tests and test using actual Zotero executable
The test runner now uses the Zotero executable from `zotero-standalone-build/staging` rather than the Firefox from `zotero-standalone-build/xulrunner`. Along with testing the actual program, this restores visible UI updates during tests, which should make debugging various things easier. We can also now remove anything related to Zotero being an extension. Many tests are still broken, but this at least lets us start running them.
This commit is contained in:
parent
5d08359dc9
commit
730e86d661
7 changed files with 51 additions and 44 deletions
|
@ -73,7 +73,7 @@ Zotero.Debug = new function () {
|
||||||
if (Zotero.isStandalone) {
|
if (Zotero.isStandalone) {
|
||||||
// Enable dump() from window (non-XPCOM) scopes when terminal or viewer logging is enabled.
|
// Enable dump() from window (non-XPCOM) scopes when terminal or viewer logging is enabled.
|
||||||
// (These will always go to the terminal, even in viewer mode.)
|
// (These will always go to the terminal, even in viewer mode.)
|
||||||
Zotero.Prefs.set('browser.dom.window.dump.enabled', _console || _consoleViewer, true);
|
Zotero.Prefs.set('browser.dom.window.dump.enabled', _console || _consoleViewer || Zotero.test, true);
|
||||||
|
|
||||||
if (_consoleViewer) {
|
if (_consoleViewer) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
|
|
@ -105,7 +105,9 @@ Zotero.Schema = new function(){
|
||||||
Zotero.debug('Database does not exist -- creating\n');
|
Zotero.debug('Database does not exist -- creating\n');
|
||||||
return _initializeSchema()
|
return _initializeSchema()
|
||||||
.then(function() {
|
.then(function() {
|
||||||
(Zotero.isStandalone ? Zotero.uiReadyPromise : Zotero.initializationPromise)
|
// Don't load bundled files until after UI is ready, unless this is a test run,
|
||||||
|
// in which case tests can run without a window open
|
||||||
|
(!Zotero.test ? Zotero.uiReadyPromise : Zotero.initializationPromise)
|
||||||
.delay(1000)
|
.delay(1000)
|
||||||
.then(async function () {
|
.then(async function () {
|
||||||
await this.updateBundledFiles();
|
await this.updateBundledFiles();
|
||||||
|
@ -294,9 +296,8 @@ Zotero.Schema = new function(){
|
||||||
// Reset sync queue tries if new version
|
// Reset sync queue tries if new version
|
||||||
await _checkClientVersion();
|
await _checkClientVersion();
|
||||||
|
|
||||||
// In Standalone, don't load bundled files until after UI is ready. In Firefox, load them as
|
// See above
|
||||||
// soon initialization is done so that translation works before the Zotero pane is opened.
|
(!Zotero.test ? Zotero.uiReadyPromise : Zotero.initializationPromise)
|
||||||
(Zotero.isStandalone ? Zotero.uiReadyPromise : Zotero.initializationPromise)
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setTimeout(async function () {
|
setTimeout(async function () {
|
||||||
try {
|
try {
|
||||||
|
@ -847,11 +848,12 @@ Zotero.Schema = new function(){
|
||||||
await Zotero.SearchConditions.init();
|
await Zotero.SearchConditions.init();
|
||||||
|
|
||||||
// Update item type menus in every open window
|
// Update item type menus in every open window
|
||||||
|
// TODO: Remove?
|
||||||
Zotero.Schema.schemaUpdatePromise.then(function () {
|
Zotero.Schema.schemaUpdatePromise.then(function () {
|
||||||
var enumerator = Services.wm.getEnumerator("navigator:browser");
|
var enumerator = Services.wm.getEnumerator("navigator:browser");
|
||||||
while (enumerator.hasMoreElements()) {
|
while (enumerator.hasMoreElements()) {
|
||||||
let win = enumerator.getNext();
|
let win = enumerator.getNext();
|
||||||
win.document.getElementById('zotero-editpane-item-box').buildItemTypeMenu();
|
//win.document.getElementById('zotero-editpane-item-box').buildItemTypeMenu();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,16 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
||||||
this.startupError;
|
this.startupError;
|
||||||
Object.defineProperty(this, 'startupErrorHandler', {
|
Object.defineProperty(this, 'startupErrorHandler', {
|
||||||
get: () => _startupErrorHandler,
|
get: () => _startupErrorHandler,
|
||||||
enumerable: true
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
Object.defineProperty(this, 'resourcesDir', {
|
||||||
|
get: () => {
|
||||||
|
// AChrome is app/chrome
|
||||||
|
return FileUtils.getDir('AChrom', []).parent.parent.path;
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
});
|
});
|
||||||
this.version;
|
this.version;
|
||||||
this.platform;
|
this.platform;
|
||||||
|
@ -107,7 +116,8 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
||||||
this.unlockDeferred.resolve();
|
this.unlockDeferred.resolve();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
enumerable: true
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
content zotero-unit content/
|
content zotero-unit test/content/
|
||||||
resource zotero-unit resource/
|
resource zotero-unit test/resource/
|
||||||
resource zotero-unit-tests tests/
|
resource zotero-unit-tests test/tests/
|
||||||
|
|
||||||
component {b8570031-be5e-46e8-9785-38cd50a5d911} components/zotero-unit.js
|
component {b8570031-be5e-46e8-9785-38cd50a5d911} test/components/zotero-unit.js
|
||||||
contract @mozilla.org/commandlinehandler/general-startup;1?type=zotero-unit {b8570031-be5e-46e8-9785-38cd50a5d911}
|
contract @mozilla.org/commandlinehandler/general-startup;1?type=zotero-unit {b8570031-be5e-46e8-9785-38cd50a5d911}
|
||||||
category command-line-handler m-zotero-unit @mozilla.org/commandlinehandler/general-startup;1?type=zotero-unit
|
category command-line-handler m-zotero-unit @mozilla.org/commandlinehandler/general-startup;1?type=zotero-unit
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
***** END LICENSE BLOCK *****
|
***** END LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
Components.utils.import("resource://gre/modules/ComponentUtils.jsm");
|
||||||
|
|
||||||
function ZoteroUnit() {
|
function ZoteroUnit() {
|
||||||
this.wrappedJSObject = this;
|
this.wrappedJSObject = this;
|
||||||
|
@ -56,4 +56,4 @@ ZoteroUnit.prototype = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var NSGetFactory = XPCOMUtils.generateNSGetFactory([ZoteroUnit]);
|
var NSGetFactory = ComponentUtils.generateNSGetFactory([ZoteroUnit]);
|
||||||
|
|
|
@ -557,11 +557,10 @@ function initPDFToolsPath() {
|
||||||
* (i.e., test/tests/data)
|
* (i.e., test/tests/data)
|
||||||
*/
|
*/
|
||||||
function getTestDataDirectory() {
|
function getTestDataDirectory() {
|
||||||
var resource = Services.io.getProtocolHandler("resource").
|
var file = Zotero.File.pathToFile(Zotero.resourcesDir);
|
||||||
QueryInterface(Components.interfaces.nsIResProtocolHandler),
|
file.append('tests');
|
||||||
resURI = Services.io.newURI("resource://zotero-unit-tests/data", null, null);
|
file.append('data');
|
||||||
return Services.io.newURI(resource.resolveURI(resURI), null, null).
|
return file;
|
||||||
QueryInterface(Components.interfaces.nsIFileURL).file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTestDataUrl(path) {
|
function getTestDataUrl(path) {
|
||||||
|
|
|
@ -15,18 +15,18 @@ function makePath {
|
||||||
eval $__assignTo="'$__path'"
|
eval $__assignTo="'$__path'"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z "$FX_EXECUTABLE" ]; then
|
if [ -z "$Z_EXECUTABLE" ]; then
|
||||||
if [ "`uname`" == "Darwin" ]; then
|
if [ "`uname`" == "Darwin" ]; then
|
||||||
FX_EXECUTABLE="$( dirname "$ROOT_DIR" )/zotero-standalone-build/xulrunner/Firefox.app/Contents/MacOS/firefox"
|
Z_EXECUTABLE="$( dirname "$ROOT_DIR" )/zotero-standalone-build/staging/Zotero.app/Contents/MacOS/zotero"
|
||||||
else
|
else
|
||||||
FX_EXECUTABLE="$( dirname "$ROOT_DIR" )/zotero-standalone-build/xulrunner/firefox-x86_64/firefox"
|
Z_EXECUTABLE="$( dirname "$ROOT_DIR" )/zotero-standalone-build/staging/Zotero-x86_64/zotero"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$DISPLAY" ]; then
|
if [ -z "$DISPLAY" ]; then
|
||||||
FX_ARGS=""
|
Z_ARGS=""
|
||||||
else
|
else
|
||||||
FX_ARGS="--class=ZTestFirefox"
|
Z_ARGS="--class=ZTestFirefox"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function usage {
|
function usage {
|
||||||
|
@ -42,7 +42,7 @@ Options
|
||||||
-h display this help
|
-h display this help
|
||||||
-s TEST start at the given test
|
-s TEST start at the given test
|
||||||
-t generate test data and quit
|
-t generate test data and quit
|
||||||
-x FX_EXECUTABLE path to Firefox executable (default: $FX_EXECUTABLE)
|
-x EXECUTABLE path to Zotero executable (default: $Z_EXECUTABLE)
|
||||||
TESTS set of tests to run (default: all)
|
TESTS set of tests to run (default: all)
|
||||||
DONE
|
DONE
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -53,10 +53,10 @@ DEBUG_LEVEL=5
|
||||||
while getopts "bcd:e:fg:hs:tx:" opt; do
|
while getopts "bcd:e:fg:hs:tx:" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
b)
|
b)
|
||||||
FX_ARGS="$FX_ARGS -ZoteroSkipBundledFiles"
|
Z_ARGS="$Z_ARGS -ZoteroSkipBundledFiles"
|
||||||
;;
|
;;
|
||||||
c)
|
c)
|
||||||
FX_ARGS="$FX_ARGS -jsconsole -noquit"
|
Z_ARGS="$Z_ARGS -jsconsole -noquit"
|
||||||
;;
|
;;
|
||||||
d)
|
d)
|
||||||
DEBUG=true
|
DEBUG=true
|
||||||
|
@ -66,10 +66,10 @@ while getopts "bcd:e:fg:hs:tx:" opt; do
|
||||||
if [[ -z "$OPTARG" ]] || [[ ${OPTARG:0:1} = "-" ]]; then
|
if [[ -z "$OPTARG" ]] || [[ ${OPTARG:0:1} = "-" ]]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
FX_ARGS="$FX_ARGS -stopAtTestFile $OPTARG"
|
Z_ARGS="$Z_ARGS -stopAtTestFile $OPTARG"
|
||||||
;;
|
;;
|
||||||
f)
|
f)
|
||||||
FX_ARGS="$FX_ARGS -bail"
|
Z_ARGS="$Z_ARGS -bail"
|
||||||
;;
|
;;
|
||||||
g)
|
g)
|
||||||
GREP="$OPTARG"
|
GREP="$OPTARG"
|
||||||
|
@ -81,13 +81,13 @@ while getopts "bcd:e:fg:hs:tx:" opt; do
|
||||||
if [[ -z "$OPTARG" ]] || [[ ${OPTARG:0:1} = "-" ]]; then
|
if [[ -z "$OPTARG" ]] || [[ ${OPTARG:0:1} = "-" ]]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
FX_ARGS="$FX_ARGS -startAtTestFile $OPTARG"
|
Z_ARGS="$Z_ARGS -startAtTestFile $OPTARG"
|
||||||
;;
|
;;
|
||||||
t)
|
t)
|
||||||
FX_ARGS="$FX_ARGS -makeTestData"
|
Z_ARGS="$Z_ARGS -makeTestData"
|
||||||
;;
|
;;
|
||||||
x)
|
x)
|
||||||
FX_EXECUTABLE="$OPTARG"
|
Z_EXECUTABLE="$OPTARG"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
usage
|
usage
|
||||||
|
@ -115,13 +115,9 @@ ulimit -n 4096
|
||||||
# Set up profile directory
|
# Set up profile directory
|
||||||
TEMPDIR="`mktemp -d 2>/dev/null || mktemp -d -t 'zotero-unit'`"
|
TEMPDIR="`mktemp -d 2>/dev/null || mktemp -d -t 'zotero-unit'`"
|
||||||
PROFILE="$TEMPDIR/profile"
|
PROFILE="$TEMPDIR/profile"
|
||||||
mkdir -p "$PROFILE/extensions"
|
mkdir -p "$PROFILE"
|
||||||
|
|
||||||
makePath ZOTERO_PATH "$ROOT_DIR/build"
|
makePath ZOTERO_PATH "$ROOT_DIR/build"
|
||||||
echo "$ZOTERO_PATH" > "$PROFILE/extensions/zotero@chnm.gmu.edu"
|
|
||||||
|
|
||||||
makePath ZOTERO_UNIT_PATH "$ZOTERO_PATH/test"
|
|
||||||
echo "$ZOTERO_UNIT_PATH" > "$PROFILE/extensions/zotero-unit@zotero.org"
|
|
||||||
|
|
||||||
# Create data directory
|
# Create data directory
|
||||||
mkdir "$TEMPDIR/Zotero"
|
mkdir "$TEMPDIR/Zotero"
|
||||||
|
@ -144,9 +140,7 @@ if [ ! -f "$PDF_TOOLS_CACHE_DIR/$PDF_TOOLS_VERSION" ]; then
|
||||||
fi
|
fi
|
||||||
cp -R $PDF_TOOLS_CACHE_DIR $PDF_TOOLS_DIR
|
cp -R $PDF_TOOLS_CACHE_DIR $PDF_TOOLS_DIR
|
||||||
|
|
||||||
# Add default prefs, which are apparently no longer read from extensions in Firefox 60
|
touch "$PROFILE/prefs.js"
|
||||||
cat "$ZOTERO_PATH/defaults/preferences/zotero.js" | sed 's/^pref/user_pref/g' > "$PROFILE/prefs.js"
|
|
||||||
|
|
||||||
cat <<EOF >> "$PROFILE/prefs.js"
|
cat <<EOF >> "$PROFILE/prefs.js"
|
||||||
user_pref("app.update.enabled", false);
|
user_pref("app.update.enabled", false);
|
||||||
user_pref("extensions.autoDisableScopes", 0);
|
user_pref("extensions.autoDisableScopes", 0);
|
||||||
|
@ -181,11 +175,11 @@ EOF
|
||||||
|
|
||||||
# -v flag on Windows makes Firefox process hang
|
# -v flag on Windows makes Firefox process hang
|
||||||
if [ -z $IS_CYGWIN ]; then
|
if [ -z $IS_CYGWIN ]; then
|
||||||
echo "`MOZ_NO_REMOTE=1 NO_EM_RESTART=1 \"$FX_EXECUTABLE\" -v`"
|
echo "`MOZ_NO_REMOTE=1 NO_EM_RESTART=1 \"$Z_EXECUTABLE\" -v`"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$CI" ]; then
|
if [ -n "$CI" ]; then
|
||||||
FX_ARGS="$FX_ARGS -ZoteroAutomatedTest -ZoteroTestTimeout 15000"
|
Z_ARGS="$Z_ARGS -ZoteroAutomatedTest -ZoteroTestTimeout 15000"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean up on exit
|
# Clean up on exit
|
||||||
|
@ -201,9 +195,11 @@ if [[ -z "$CI" ]] && ! ps | grep scripts/build.js | grep -v grep > /dev/null; th
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ZOTERO_INCLUDE_TESTS=1 $( dirname "$ROOT_DIR" )/zotero-standalone-build/scripts/dir_build -q
|
||||||
|
|
||||||
makePath FX_PROFILE "$PROFILE"
|
makePath FX_PROFILE "$PROFILE"
|
||||||
MOZ_NO_REMOTE=1 NO_EM_RESTART=1 "$FX_EXECUTABLE" -profile "$FX_PROFILE" \
|
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 $FX_ARGS
|
-chrome chrome://zotero-unit/content/runtests.html -test "$TESTS" -grep "$GREP" -ZoteroTest $Z_ARGS
|
||||||
|
|
||||||
# Check for success
|
# Check for success
|
||||||
test -e "$PROFILE/success"
|
test -e "$PROFILE/success"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue