Fix Travis errors due to broken DirectoryIterator

This commit is contained in:
Dan Stillman 2016-11-19 18:52:10 -05:00
parent d89da85606
commit 6d07cb44df
3 changed files with 17 additions and 10 deletions

View File

@ -494,6 +494,16 @@ var getTempDirectory = Zotero.Promise.coroutine(function* getTempDirectory() {
return path; 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 * Resets the Zotero DB and restarts Zotero. Returns a promise resolved
* when this finishes. * when this finishes.

View File

@ -140,10 +140,7 @@ describe("Zotero.Sync.Storage.Local", function () {
yield Zotero.File.putContentsAsync(OS.Path.join(subDir, file3Name), file3Contents); yield Zotero.File.putContentsAsync(OS.Path.join(subDir, file3Name), file3Contents);
yield Zotero.File.zipDirectory(zipDir, zipFile); yield Zotero.File.zipDirectory(zipDir, zipFile);
// OS.File.DirectoryIterator, used by OS.File.removeDir(), isn't reliable on Travis, yield removeDir(zipDir);
// returning entry.isDir == false for subdirectories, so use nsIFile instead
//yield OS.File.removeDir(zipDir);
Zotero.File.pathToFile(zipDir).remove(true);
}); });
it("should download and extract a ZIP file into the attachment directory", function* () { it("should download and extract a ZIP file into the attachment directory", function* () {

View File

@ -42,8 +42,8 @@ describe("Zotero Core Functions", function () {
}); });
afterEach(function* () { afterEach(function* () {
yield OS.File.removeDir(oldDir); yield removeDir(oldDir);
yield OS.File.removeDir(newDir); yield removeDir(newDir);
Zotero._cacheDataDirectory(false); Zotero._cacheDataDirectory(false);
stub1.restore(); stub1.restore();
@ -245,9 +245,9 @@ describe("Zotero Core Functions", function () {
// Not moved: one storage dir, translators dir // Not moved: one storage dir, translators dir
yield OS.File.remove(oldDBFile); yield OS.File.remove(oldDBFile);
yield OS.File.remove(oldDBFile + '.bak'); yield OS.File.remove(oldDBFile + '.bak');
yield OS.File.removeDir(oldStorageDir1); yield removeDir(oldStorageDir1);
yield OS.File.removeDir(newTranslatorsDir); yield removeDir(newTranslatorsDir);
yield OS.File.removeDir(newStorageDir2); yield removeDir(newStorageDir2);
yield Zotero.migrateDataDirectory(oldDir, newDir, true); yield Zotero.migrateDataDirectory(oldDir, newDir, true);
yield checkMigration(); yield checkMigration();
@ -262,7 +262,7 @@ describe("Zotero Core Functions", function () {
yield checkMigration(); yield checkMigration();
assert.isTrue(yield OS.File.exists(OS.Path.join(newDir + "-1", 'existing'))); 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 // Run all tests again without using mv