From 2f562a4fdf018f3b93cb3611bae2e9a42451b99e Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 24 Jun 2016 19:40:10 -0400 Subject: [PATCH] Fix Travis errors with OS.File.DirectoryIterator for real --- chrome/content/zotero/xpcom/storage/storageLocal.js | 5 +++++ test/tests/fileTest.js | 4 ++-- test/tests/storageLocalTest.js | 7 +++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/storage/storageLocal.js b/chrome/content/zotero/xpcom/storage/storageLocal.js index dd6146d6d..df5272652 100644 --- a/chrome/content/zotero/xpcom/storage/storageLocal.js +++ b/chrome/content/zotero/xpcom/storage/storageLocal.js @@ -896,6 +896,11 @@ Zotero.Sync.Storage.Local = { _deleteExistingAttachmentFiles: Zotero.Promise.method(function (item) { var parentDir = Zotero.Attachments.getStorageDirectory(item).path; + // OS.File.DirectoryIterator, used by OS.File.removeDir(), isn't reliable on Travis, + // returning entry.isDir == false for subdirectories, so use nsIFile instead + if (Zotero.automatedTest) { + Zotero.File.pathToFile(parentDir).remove(true); + } return OS.File.removeDir(parentDir); }), diff --git a/test/tests/fileTest.js b/test/tests/fileTest.js index 65db2c54d..e71a193b5 100644 --- a/test/tests/fileTest.js +++ b/test/tests/fileTest.js @@ -74,12 +74,12 @@ describe("Zotero.File", function () { it("should compress a directory recursively", function* () { var tmpPath = Zotero.getTempDirectory().path; var path = OS.Path.join(tmpPath, Zotero.Utilities.randomString()); - yield OS.File.makeDir(path); + yield OS.File.makeDir(path, { unixMode: 0o755 }); yield Zotero.File.putContentsAsync(OS.Path.join(path, '.zotero-ft-cache'), ''); yield Zotero.File.putContentsAsync(OS.Path.join(path, 'a.txt'), 'A'); // Create subdirectory var subPath = OS.Path.join(path, 'sub'); - yield OS.File.makeDir(subPath); + yield OS.File.makeDir(subPath, { unixMode: 0o755 }); yield Zotero.File.putContentsAsync(OS.Path.join(subPath, 'b.txt'), 'B'); var zipFile = OS.Path.join(tmpPath, 'test.zip'); diff --git a/test/tests/storageLocalTest.js b/test/tests/storageLocalTest.js index 369521129..c4a78f08c 100644 --- a/test/tests/storageLocalTest.js +++ b/test/tests/storageLocalTest.js @@ -125,7 +125,7 @@ describe("Zotero.Sync.Storage.Local", function () { yield Zotero.File.zipDirectory(zipDir, zipFile); // OS.File.DirectoryIterator, used by OS.File.removeDir(), isn't reliable on Travis, - // returning entry.isDir == false for directories, so use nsIFile instead + // returning entry.isDir == false for subdirectories, so use nsIFile instead //yield OS.File.removeDir(zipDir); Zotero.File.pathToFile(zipDir).remove(true); }); @@ -143,7 +143,10 @@ describe("Zotero.Sync.Storage.Local", function () { var dir = Zotero.Attachments.getStorageDirectoryByLibraryAndKey(libraryID, key).path; yield OS.File.makeDir( OS.Path.join(dir, 'subdir'), - { from: Zotero.getZoteroDirectory().path } + { + from: Zotero.getZoteroDirectory().path, + unixMode: 0o755 + } ); yield Zotero.File.putContentsAsync(OS.Path.join(dir, 'A'), ''); yield Zotero.File.putContentsAsync(OS.Path.join(dir, 'subdir', 'B'), '');