Fix fullText tests on Windows
This commit is contained in:
parent
38b9bbc8c8
commit
d122323dbf
6 changed files with 37 additions and 30 deletions
|
@ -358,6 +358,9 @@ Zotero.File = new function(){
|
|||
path,
|
||||
data,
|
||||
{
|
||||
// Note: this will fail on Windows if the temp
|
||||
// directory is on a different drive from
|
||||
// destination path
|
||||
tmpPath: OS.Path.join(
|
||||
Zotero.getTempDirectory().path,
|
||||
OS.Path.basename(path) + ".tmp"
|
||||
|
|
|
@ -318,14 +318,17 @@ Zotero.Fulltext = new function(){
|
|||
if (version.startsWith('3.02')) break;
|
||||
|
||||
var script = Zotero.getZoteroDirectory();
|
||||
script.append('pdfinfo.' + _getScriptExtension())
|
||||
// The redirection script is necessary to run pdfinfo
|
||||
if (!script.exists()) {
|
||||
Zotero.debug(script.leafName + " not found -- PDF statistics disabled");
|
||||
return false;
|
||||
// TEMP: disabled on Win
|
||||
if (!Zotero.isWin) {
|
||||
script.append('pdfinfo.' + _getScriptExtension())
|
||||
// The redirection script is necessary to run pdfinfo
|
||||
if (!script.exists()) {
|
||||
Zotero.debug(script.leafName + " not found -- PDF statistics disabled");
|
||||
return false;
|
||||
}
|
||||
Zotero.debug(toolName + " redirection script registered");
|
||||
_pdfInfoScript = script;
|
||||
}
|
||||
Zotero.debug(toolName + " redirection script registered");
|
||||
_pdfInfoScript = script;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -356,8 +359,6 @@ Zotero.Fulltext = new function(){
|
|||
Zotero.debug("Uninstalling PDF tools");
|
||||
|
||||
var dataDir = Zotero.getZoteroDirectory().path;
|
||||
yield Zotero.File.removeIfExists(OS.Path.join(dataDir, _pdfConverterFileName));
|
||||
yield Zotero.File.removeIfExists(OS.Path.join(dataDir, _pdfInfoFileName));
|
||||
if (_pdfConverter) {
|
||||
yield Zotero.File.removeIfExists(_pdfConverter.path);
|
||||
yield Zotero.File.removeIfExists(_pdfConverter.path + ".version");
|
||||
|
@ -372,7 +373,6 @@ Zotero.Fulltext = new function(){
|
|||
_pdfConverter = null;
|
||||
_pdfInfo = null;
|
||||
_pdfInfoScript = null;
|
||||
_pdfInfoScript = null;
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -245,21 +245,18 @@ if(run) {
|
|||
//
|
||||
// To reset, delete test/tests/data/pdf/ directory
|
||||
var cachePDFTools = Zotero.Promise.coroutine(function* () {
|
||||
Components.utils.import("resource://zotero/config.js");
|
||||
var baseURL = ZOTERO_CONFIG.PDF_TOOLS_URL;
|
||||
|
||||
var path = OS.Path.join(getTestDataDirectory().path, 'pdf');
|
||||
yield OS.File.makeDir(path, { ignoreExisting: true });
|
||||
|
||||
var baseURL = Zotero.Fulltext.pdfToolsDownloadBaseURL;
|
||||
// Point full-text code to the cache directory, so downloads come from there
|
||||
Zotero.Fulltext.pdfToolsDownloadBaseURL = OS.Path.toFileURI(path) + "/";
|
||||
|
||||
// Get latest tools version for the current platform
|
||||
var latestPath = OS.Path.join(path, "latest.json");
|
||||
var xmlhttp = yield Zotero.HTTP.request("GET", baseURL + "latest.json");
|
||||
var json = xmlhttp.responseText;
|
||||
yield Zotero.File.putContentsAsync(latestPath, json);
|
||||
json = JSON.parse(json);
|
||||
yield Zotero.File.download(baseURL + 'latest.json', OS.Path.join(path, 'latest.json'));
|
||||
|
||||
var platform = Zotero.platform.replace(/\s/g, '-');
|
||||
var version = json[platform] || json['default'];
|
||||
var version = yield Zotero.Fulltext.getLatestPDFToolsVersion();
|
||||
|
||||
// Create version directory (e.g., data/pdf/3.04) and download tools to it if
|
||||
// they don't exist
|
||||
|
@ -270,14 +267,11 @@ if(run) {
|
|||
if (!(yield OS.File.exists(execPath))) {
|
||||
yield Zotero.File.download(baseURL + version + "/" + fileName, execPath);
|
||||
}
|
||||
fileName = "pdftotext-" + platform;
|
||||
fileName = "pdftotext-" + platform + (Zotero.isWin ? ".exe" : "");;
|
||||
execPath = OS.Path.join(path, version, fileName);
|
||||
if (!(yield OS.File.exists(execPath))) {
|
||||
yield Zotero.File.download(baseURL + version + "/" + fileName, execPath);
|
||||
}
|
||||
|
||||
// Point full-text code to the cache directory, so downloads come from there
|
||||
Zotero.Fulltext.pdfToolsDownloadBaseURL = OS.Path.toFileURI(path) + "/";
|
||||
});
|
||||
|
||||
try {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
describe("Zotero.Fulltext", function () {
|
||||
describe("#downloadPDFTool()", function () {
|
||||
it("should install the PDF tools", function* () {
|
||||
var version = "3.04";
|
||||
var version = Zotero.isWin ? '3.02a' : '3.04';
|
||||
var dataDir = Zotero.getZoteroDirectory().path;
|
||||
var execFileName = Zotero.Fulltext.pdfInfoFileName;
|
||||
var execPath = OS.Path.join(dataDir, execFileName);
|
||||
|
@ -37,16 +37,22 @@ describe("Zotero.Fulltext", function () {
|
|||
(yield Zotero.File.getBinaryContentsAsync(cacheExecPath)),
|
||||
(yield Zotero.File.getBinaryContentsAsync(execPath))
|
||||
);
|
||||
assert.equal((yield OS.File.stat(execPath)).unixMode, 0o755);
|
||||
if (!Zotero.isWin) {
|
||||
assert.equal((yield OS.File.stat(execPath)).unixMode, 0o755);
|
||||
}
|
||||
assert.equal(
|
||||
(yield Zotero.File.getContentsAsync(versionPath)),
|
||||
version
|
||||
);
|
||||
assert.equal(
|
||||
(yield Zotero.File.getContentsAsync(scriptPath)),
|
||||
scriptContents
|
||||
);
|
||||
assert.equal((yield OS.File.stat(scriptPath)).unixMode, 0o755);
|
||||
|
||||
//Temp: disabled on Windows
|
||||
if (!Zotero.isWin) {
|
||||
assert.equal(
|
||||
(yield Zotero.File.getContentsAsync(scriptPath)),
|
||||
scriptContents
|
||||
);
|
||||
assert.equal((yield OS.File.stat(scriptPath)).unixMode, 0o755);
|
||||
}
|
||||
|
||||
yield Zotero.Fulltext.uninstallPDFTools();
|
||||
assert.isFalse(Zotero.Fulltext.pdfInfoIsRegistered());
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"use strict";
|
||||
|
||||
describe("Zotero.Sync.Data.Engine", function () {
|
||||
Components.utils.import("resource://zotero/config.js");
|
||||
|
||||
var apiKey = Zotero.Utilities.randomString(24);
|
||||
var baseURL = "http://local.zotero/";
|
||||
var engine, server, client, caller, stub, spy;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"use strict";
|
||||
|
||||
describe("Zotero.Sync.Runner", function () {
|
||||
Components.utils.import("resource://zotero/config.js");
|
||||
|
||||
var apiKey = Zotero.Utilities.randomString(24);
|
||||
var baseURL = "http://local.zotero/";
|
||||
var userLibraryID, publicationsLibraryID, runner, caller, server, client, stub, spy;
|
||||
|
|
Loading…
Reference in a new issue