Create 'profile' and 'Zotero' directories in temp dir for tests

This commit is contained in:
Dan Stillman 2016-11-22 01:39:33 -05:00
parent fb1e87a2da
commit 288d0c7c06
3 changed files with 9 additions and 6 deletions

View file

@ -1139,9 +1139,9 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
this.getDefaultDataDir = function () {
// Keep data directory siloed within profile directory for tests
// Use special data directory for tests
if (Zotero.test) {
return OS.Path.join(OS.Constants.Path.profileDir, "test-data-dir");
return OS.Path.join(OS.Path.dirname(OS.Constants.Path.profileDir), "Zotero");
}
return OS.Path.join(OS.Constants.Path.homeDir, ZOTERO_CONFIG.CLIENT_NAME);
};

View file

@ -98,8 +98,9 @@ fi
ulimit -n 4096
# Set up profile directory
PROFILE="`mktemp -d 2>/dev/null || mktemp -d -t 'zotero-unit'`"
mkdir "$PROFILE/extensions"
TEMPDIR="`mktemp -d 2>/dev/null || mktemp -d -t 'zotero-unit'`"
PROFILE="$TEMPDIR/profile"
mkdir -p "$PROFILE/extensions"
makePath ZOTERO_UNIT_PATH "$CWD"
echo "$ZOTERO_UNIT_PATH" > "$PROFILE/extensions/zotero-unit@zotero.org"
@ -108,7 +109,7 @@ makePath ZOTERO_PATH "`dirname "$CWD"`"
echo "$ZOTERO_PATH" > "$PROFILE/extensions/zotero@chnm.gmu.edu"
# Create data directory
mkdir "$PROFILE/zotero"
mkdir "$TEMPDIR/Zotero"
cat <<EOF > "$PROFILE/prefs.js"
user_pref("extensions.autoDisableScopes", 0);
@ -139,7 +140,7 @@ if [ "$TRAVIS" = true ]; then
fi
# Clean up on exit
trap "{ rm -rf \"$PROFILE\"; }" EXIT
trap "{ rm -rf \"$TEMPDIR\"; }" EXIT
makePath FX_PROFILE "$PROFILE"
MOZ_NO_REMOTE=1 NO_EM_RESTART=1 "$FX_EXECUTABLE" -profile "$FX_PROFILE" \

View file

@ -38,6 +38,8 @@ describe("Zotero Core Functions", function () {
});
beforeEach(function* () {
// Trigger a call to setDataDirectory() now to avoid affecting the stub call count
Zotero.getZoteroDirectory();
stub1 = sinon.stub(Zotero, "setDataDirectory");
});