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,
|
path,
|
||||||
data,
|
data,
|
||||||
{
|
{
|
||||||
|
// Note: this will fail on Windows if the temp
|
||||||
|
// directory is on a different drive from
|
||||||
|
// destination path
|
||||||
tmpPath: OS.Path.join(
|
tmpPath: OS.Path.join(
|
||||||
Zotero.getTempDirectory().path,
|
Zotero.getTempDirectory().path,
|
||||||
OS.Path.basename(path) + ".tmp"
|
OS.Path.basename(path) + ".tmp"
|
||||||
|
|
|
@ -318,6 +318,8 @@ Zotero.Fulltext = new function(){
|
||||||
if (version.startsWith('3.02')) break;
|
if (version.startsWith('3.02')) break;
|
||||||
|
|
||||||
var script = Zotero.getZoteroDirectory();
|
var script = Zotero.getZoteroDirectory();
|
||||||
|
// TEMP: disabled on Win
|
||||||
|
if (!Zotero.isWin) {
|
||||||
script.append('pdfinfo.' + _getScriptExtension())
|
script.append('pdfinfo.' + _getScriptExtension())
|
||||||
// The redirection script is necessary to run pdfinfo
|
// The redirection script is necessary to run pdfinfo
|
||||||
if (!script.exists()) {
|
if (!script.exists()) {
|
||||||
|
@ -326,6 +328,7 @@ Zotero.Fulltext = new function(){
|
||||||
}
|
}
|
||||||
Zotero.debug(toolName + " redirection script registered");
|
Zotero.debug(toolName + " redirection script registered");
|
||||||
_pdfInfoScript = script;
|
_pdfInfoScript = script;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,8 +359,6 @@ Zotero.Fulltext = new function(){
|
||||||
Zotero.debug("Uninstalling PDF tools");
|
Zotero.debug("Uninstalling PDF tools");
|
||||||
|
|
||||||
var dataDir = Zotero.getZoteroDirectory().path;
|
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) {
|
if (_pdfConverter) {
|
||||||
yield Zotero.File.removeIfExists(_pdfConverter.path);
|
yield Zotero.File.removeIfExists(_pdfConverter.path);
|
||||||
yield Zotero.File.removeIfExists(_pdfConverter.path + ".version");
|
yield Zotero.File.removeIfExists(_pdfConverter.path + ".version");
|
||||||
|
@ -372,7 +373,6 @@ Zotero.Fulltext = new function(){
|
||||||
_pdfConverter = null;
|
_pdfConverter = null;
|
||||||
_pdfInfo = null;
|
_pdfInfo = null;
|
||||||
_pdfInfoScript = null;
|
_pdfInfoScript = null;
|
||||||
_pdfInfoScript = null;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -245,21 +245,18 @@ if(run) {
|
||||||
//
|
//
|
||||||
// To reset, delete test/tests/data/pdf/ directory
|
// To reset, delete test/tests/data/pdf/ directory
|
||||||
var cachePDFTools = Zotero.Promise.coroutine(function* () {
|
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');
|
var path = OS.Path.join(getTestDataDirectory().path, 'pdf');
|
||||||
yield OS.File.makeDir(path, { ignoreExisting: true });
|
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
|
// Get latest tools version for the current platform
|
||||||
var latestPath = OS.Path.join(path, "latest.json");
|
yield Zotero.File.download(baseURL + 'latest.json', 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);
|
|
||||||
|
|
||||||
var platform = Zotero.platform.replace(/\s/g, '-');
|
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
|
// Create version directory (e.g., data/pdf/3.04) and download tools to it if
|
||||||
// they don't exist
|
// they don't exist
|
||||||
|
@ -270,14 +267,11 @@ if(run) {
|
||||||
if (!(yield OS.File.exists(execPath))) {
|
if (!(yield OS.File.exists(execPath))) {
|
||||||
yield Zotero.File.download(baseURL + version + "/" + fileName, 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);
|
execPath = OS.Path.join(path, version, fileName);
|
||||||
if (!(yield OS.File.exists(execPath))) {
|
if (!(yield OS.File.exists(execPath))) {
|
||||||
yield Zotero.File.download(baseURL + version + "/" + fileName, 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 {
|
try {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
describe("Zotero.Fulltext", function () {
|
describe("Zotero.Fulltext", function () {
|
||||||
describe("#downloadPDFTool()", function () {
|
describe("#downloadPDFTool()", function () {
|
||||||
it("should install the PDF tools", 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 dataDir = Zotero.getZoteroDirectory().path;
|
||||||
var execFileName = Zotero.Fulltext.pdfInfoFileName;
|
var execFileName = Zotero.Fulltext.pdfInfoFileName;
|
||||||
var execPath = OS.Path.join(dataDir, execFileName);
|
var execPath = OS.Path.join(dataDir, execFileName);
|
||||||
|
@ -37,16 +37,22 @@ describe("Zotero.Fulltext", function () {
|
||||||
(yield Zotero.File.getBinaryContentsAsync(cacheExecPath)),
|
(yield Zotero.File.getBinaryContentsAsync(cacheExecPath)),
|
||||||
(yield Zotero.File.getBinaryContentsAsync(execPath))
|
(yield Zotero.File.getBinaryContentsAsync(execPath))
|
||||||
);
|
);
|
||||||
|
if (!Zotero.isWin) {
|
||||||
assert.equal((yield OS.File.stat(execPath)).unixMode, 0o755);
|
assert.equal((yield OS.File.stat(execPath)).unixMode, 0o755);
|
||||||
|
}
|
||||||
assert.equal(
|
assert.equal(
|
||||||
(yield Zotero.File.getContentsAsync(versionPath)),
|
(yield Zotero.File.getContentsAsync(versionPath)),
|
||||||
version
|
version
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//Temp: disabled on Windows
|
||||||
|
if (!Zotero.isWin) {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
(yield Zotero.File.getContentsAsync(scriptPath)),
|
(yield Zotero.File.getContentsAsync(scriptPath)),
|
||||||
scriptContents
|
scriptContents
|
||||||
);
|
);
|
||||||
assert.equal((yield OS.File.stat(scriptPath)).unixMode, 0o755);
|
assert.equal((yield OS.File.stat(scriptPath)).unixMode, 0o755);
|
||||||
|
}
|
||||||
|
|
||||||
yield Zotero.Fulltext.uninstallPDFTools();
|
yield Zotero.Fulltext.uninstallPDFTools();
|
||||||
assert.isFalse(Zotero.Fulltext.pdfInfoIsRegistered());
|
assert.isFalse(Zotero.Fulltext.pdfInfoIsRegistered());
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
describe("Zotero.Sync.Data.Engine", function () {
|
describe("Zotero.Sync.Data.Engine", function () {
|
||||||
|
Components.utils.import("resource://zotero/config.js");
|
||||||
|
|
||||||
var apiKey = Zotero.Utilities.randomString(24);
|
var apiKey = Zotero.Utilities.randomString(24);
|
||||||
var baseURL = "http://local.zotero/";
|
var baseURL = "http://local.zotero/";
|
||||||
var engine, server, client, caller, stub, spy;
|
var engine, server, client, caller, stub, spy;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
describe("Zotero.Sync.Runner", function () {
|
describe("Zotero.Sync.Runner", function () {
|
||||||
|
Components.utils.import("resource://zotero/config.js");
|
||||||
|
|
||||||
var apiKey = Zotero.Utilities.randomString(24);
|
var apiKey = Zotero.Utilities.randomString(24);
|
||||||
var baseURL = "http://local.zotero/";
|
var baseURL = "http://local.zotero/";
|
||||||
var userLibraryID, publicationsLibraryID, runner, caller, server, client, stub, spy;
|
var userLibraryID, publicationsLibraryID, runner, caller, server, client, stub, spy;
|
||||||
|
|
Loading…
Reference in a new issue