diff --git a/test/content/support.js b/test/content/support.js index 827177a975..1a629e13e4 100644 --- a/test/content/support.js +++ b/test/content/support.js @@ -494,6 +494,16 @@ var getTempDirectory = Zotero.Promise.coroutine(function* getTempDirectory() { return path; }); +var removeDir = Zotero.Promise.coroutine(function* (dir) { + // OS.File.DirectoryIterator, used by OS.File.removeDir(), isn't reliable on Travis, + // returning entry.isDir == false for subdirectories, so use nsIFile instead + //yield OS.File.removeDir(zipDir); + dir = Zotero.File.pathToFile(dir); + if (dir.exists()) { + dir.remove(true); + } +}); + /** * Resets the Zotero DB and restarts Zotero. Returns a promise resolved * when this finishes. diff --git a/test/tests/storageLocalTest.js b/test/tests/storageLocalTest.js index cd19313223..cb696dda86 100644 --- a/test/tests/storageLocalTest.js +++ b/test/tests/storageLocalTest.js @@ -140,10 +140,7 @@ describe("Zotero.Sync.Storage.Local", function () { yield Zotero.File.putContentsAsync(OS.Path.join(subDir, file3Name), file3Contents); yield Zotero.File.zipDirectory(zipDir, zipFile); - // OS.File.DirectoryIterator, used by OS.File.removeDir(), isn't reliable on Travis, - // returning entry.isDir == false for subdirectories, so use nsIFile instead - //yield OS.File.removeDir(zipDir); - Zotero.File.pathToFile(zipDir).remove(true); + yield removeDir(zipDir); }); it("should download and extract a ZIP file into the attachment directory", function* () { diff --git a/test/tests/zoteroTest.js b/test/tests/zoteroTest.js index 561d8979ad..0cd10f2cab 100644 --- a/test/tests/zoteroTest.js +++ b/test/tests/zoteroTest.js @@ -42,8 +42,8 @@ describe("Zotero Core Functions", function () { }); afterEach(function* () { - yield OS.File.removeDir(oldDir); - yield OS.File.removeDir(newDir); + yield removeDir(oldDir); + yield removeDir(newDir); Zotero._cacheDataDirectory(false); stub1.restore(); @@ -245,9 +245,9 @@ describe("Zotero Core Functions", function () { // Not moved: one storage dir, translators dir yield OS.File.remove(oldDBFile); yield OS.File.remove(oldDBFile + '.bak'); - yield OS.File.removeDir(oldStorageDir1); - yield OS.File.removeDir(newTranslatorsDir); - yield OS.File.removeDir(newStorageDir2); + yield removeDir(oldStorageDir1); + yield removeDir(newTranslatorsDir); + yield removeDir(newStorageDir2); yield Zotero.migrateDataDirectory(oldDir, newDir, true); yield checkMigration(); @@ -262,7 +262,7 @@ describe("Zotero Core Functions", function () { yield checkMigration(); assert.isTrue(yield OS.File.exists(OS.Path.join(newDir + "-1", 'existing'))); - yield OS.File.removeDir(newDir + "-1"); + yield removeDir(newDir + "-1"); }); // Run all tests again without using mv