commit 288d0c7c0647110a026ecdb558159d65f2234c46
parent fb1e87a2da81fe54a94564b852727597bb8756e8
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 22 Nov 2016 01:39:33 -0500
Create 'profile' and 'Zotero' directories in temp dir for tests
Diffstat:
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -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);
};
diff --git a/test/runtests.sh b/test/runtests.sh
@@ -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" \
diff --git a/test/tests/zoteroTest.js b/test/tests/zoteroTest.js
@@ -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");
});