Create 'profile' and 'Zotero' directories in temp dir for tests
This commit is contained in:
parent
fb1e87a2da
commit
288d0c7c06
3 changed files with 9 additions and 6 deletions
|
@ -1139,9 +1139,9 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
|
|
||||||
|
|
||||||
this.getDefaultDataDir = function () {
|
this.getDefaultDataDir = function () {
|
||||||
// Keep data directory siloed within profile directory for tests
|
// Use special data directory for tests
|
||||||
if (Zotero.test) {
|
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);
|
return OS.Path.join(OS.Constants.Path.homeDir, ZOTERO_CONFIG.CLIENT_NAME);
|
||||||
};
|
};
|
||||||
|
|
|
@ -98,8 +98,9 @@ fi
|
||||||
ulimit -n 4096
|
ulimit -n 4096
|
||||||
|
|
||||||
# Set up profile directory
|
# Set up profile directory
|
||||||
PROFILE="`mktemp -d 2>/dev/null || mktemp -d -t 'zotero-unit'`"
|
TEMPDIR="`mktemp -d 2>/dev/null || mktemp -d -t 'zotero-unit'`"
|
||||||
mkdir "$PROFILE/extensions"
|
PROFILE="$TEMPDIR/profile"
|
||||||
|
mkdir -p "$PROFILE/extensions"
|
||||||
|
|
||||||
makePath ZOTERO_UNIT_PATH "$CWD"
|
makePath ZOTERO_UNIT_PATH "$CWD"
|
||||||
echo "$ZOTERO_UNIT_PATH" > "$PROFILE/extensions/zotero-unit@zotero.org"
|
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"
|
echo "$ZOTERO_PATH" > "$PROFILE/extensions/zotero@chnm.gmu.edu"
|
||||||
|
|
||||||
# Create data directory
|
# Create data directory
|
||||||
mkdir "$PROFILE/zotero"
|
mkdir "$TEMPDIR/Zotero"
|
||||||
|
|
||||||
cat <<EOF > "$PROFILE/prefs.js"
|
cat <<EOF > "$PROFILE/prefs.js"
|
||||||
user_pref("extensions.autoDisableScopes", 0);
|
user_pref("extensions.autoDisableScopes", 0);
|
||||||
|
@ -139,7 +140,7 @@ if [ "$TRAVIS" = true ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean up on exit
|
# Clean up on exit
|
||||||
trap "{ rm -rf \"$PROFILE\"; }" EXIT
|
trap "{ rm -rf \"$TEMPDIR\"; }" EXIT
|
||||||
|
|
||||||
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 "$FX_EXECUTABLE" -profile "$FX_PROFILE" \
|
||||||
|
|
|
@ -38,6 +38,8 @@ describe("Zotero Core Functions", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function* () {
|
beforeEach(function* () {
|
||||||
|
// Trigger a call to setDataDirectory() now to avoid affecting the stub call count
|
||||||
|
Zotero.getZoteroDirectory();
|
||||||
stub1 = sinon.stub(Zotero, "setDataDirectory");
|
stub1 = sinon.stub(Zotero, "setDataDirectory");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue