From 2d88b07855cc8f9186c9d4c3d5f6815a461a8363 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 24 Jun 2016 18:28:32 -0400 Subject: [PATCH] Set Zotero.automatedTest flag instead of .noUserInput on Travis And don't skip alerts in Zotero.alert() during automated tests. (That was intended to avoid long timeouts after unexpected failures, but, e.g., PDF metadata lookups (which are currently disabled in automated tests) should just be mocked so they don't intermittently fail.) --- chrome/content/zotero/xpcom/zotero.js | 10 +--------- components/zotero-service.js | 4 ++-- test/content/runtests.js | 2 +- test/runtests.sh | 2 +- test/tests/recognizePDFTest.js | 2 +- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index ba00b601da..f38fb37271 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -178,7 +178,7 @@ Components.utils.import("resource://gre/modules/osfile.jsm"); if (options) { if (options.openPane) this.openPane = true; - if (options.noUserInput) this.noUserInput = true; + if (options.automatedTest) this.automatedTest = true; if (options.skipBundledFiles) this.skipBundledFiles = true; } @@ -1348,19 +1348,11 @@ Components.utils.import("resource://gre/modules/osfile.jsm"); /** * Display an alert in a given window * - * This is just a wrapper around nsIPromptService.alert() that takes the Zotero.noUserInput - * flag into consideration - * * @param {Window} * @param {String} title * @param {String} msg */ this.alert = function (window, title, msg) { - if (this.noUserInput) { - Zotero.debug("Not displaying alert: " + title + ": " + msg); - return; - } - var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); ps.alert(window, title, msg); diff --git a/components/zotero-service.js b/components/zotero-service.js index 8470a78aac..07716147c3 100644 --- a/components/zotero-service.js +++ b/components/zotero-service.js @@ -489,8 +489,8 @@ ZoteroCommandLineHandler.prototype = { } } - if (cmdLine.handleFlag("ZoteroNoUserInput", false)) { - zInitOptions.noUserInput = true; + if (cmdLine.handleFlag("ZoteroAutomatedTest", false)) { + zInitOptions.automatedTest = true; } if (cmdLine.handleFlag("ZoteroSkipBundledFiles", false)) { zInitOptions.skipBundledFiles = true; diff --git a/test/content/runtests.js b/test/content/runtests.js index 945c1bbb06..7057c1df45 100644 --- a/test/content/runtests.js +++ b/test/content/runtests.js @@ -141,7 +141,7 @@ function Reporter(runner) { // Dark red X for errors + "\033[31;40m" + Mocha.reporters.Base.symbols.err + " [FAIL]\033[0m" // Trigger bell if interactive - + (Zotero.noUserInput ? "" : "\007") + + (Zotero.automatedTest ? "" : "\007") + " " + test.title + "\n" + indentStr + " " + err.toString() + " at\n" + err.stack.replace(/^/gm, indentStr + " ")); diff --git a/test/runtests.sh b/test/runtests.sh index c0dd2322d5..c1054e2170 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -132,7 +132,7 @@ fi if [ "$TRAVIS" = true ]; then - FX_ARGS="$FX_ARGS -ZoteroNoUserInput -ZoteroTestTimeout 10000" + FX_ARGS="$FX_ARGS -ZoteroAutomatedTest -ZoteroTestTimeout 10000" fi # Clean up on exit diff --git a/test/tests/recognizePDFTest.js b/test/tests/recognizePDFTest.js index 2ce0e62185..df119caf1f 100644 --- a/test/tests/recognizePDFTest.js +++ b/test/tests/recognizePDFTest.js @@ -52,7 +52,7 @@ describe.skip("PDF Recognition", function() { }); it("should recognize a PDF without a DOI", function* () { - if (Zotero.noUserInput) this.skip(); // CAPTCHAs make this fail + if (Zotero.automatedTest) this.skip(); // CAPTCHAs make this fail this.timeout(30000); // Import the PDF