1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 22:47:59 +01:00

Bang on the tests a bit more.

This commit is contained in:
Kris Maglione
2011-01-29 22:10:51 -05:00
parent 9128fcc51a
commit c50ddf6bb6
5 changed files with 56 additions and 38 deletions

View File

@@ -13,6 +13,8 @@ MOZMILL = mozmill
HOSTAPP_PATH = $(shell which $(HOSTAPP)) HOSTAPP_PATH = $(shell which $(HOSTAPP))
TEST_DIR = $(BASE)/tests/functional TEST_DIR = $(BASE)/tests/functional
IDNAME := $(shell echo "$(NAME)" | tr a-z A-Z)
LOCALEDIR = locale LOCALEDIR = locale
DOC_FILES = $(wildcard $(LOCALEDIR)/*/*.xml) DOC_FILES = $(wildcard $(LOCALEDIR)/*/*.xml)
@@ -164,7 +166,8 @@ distclean:
# TODO: generalize log path # TODO: generalize log path
test: xpi test: xpi
@echo "Running functional tests..." @echo "Running functional tests..."
$(MOZMILL) --show-all -l /tmp/dactyl-test.log -b $(HOSTAPP_PATH) --addons $(XPI) -t $(TEST_DIR) $(IDNAME)_INIT="set loadplugins=" \
$(MOZMILL) --show-all -l /tmp/dactyl-test.log -b $(HOSTAPP_PATH) --addons $(XPI) -t $(TEST_DIR)
#### xpi #### xpi

View File

@@ -2036,13 +2036,11 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
dactyl.log("All modules loaded", 3); dactyl.log("All modules loaded", 3);
try { try {
if (services.fuel) var args = services.fuel && services.fuel.storage.get("dactyl.commandlineArgs", null)
var args = services.fuel.storage.get("dactyl.commandlineArgs", null); || services.commandLineHandler.optionValue;
if (!args) { if (isString(args))
let commandline = services.commandLineHandler.optionValue; args = dactyl.parseCommandLine(args);
if (commandline)
args = dactyl.parseCommandLine(commandline);
}
if (args) { if (args) {
dactyl.commandLineOptions.rcFile = args["+u"]; dactyl.commandLineOptions.rcFile = args["+u"];
dactyl.commandLineOptions.noPlugins = "++noplugin" in args; dactyl.commandLineOptions.noPlugins = "++noplugin" in args;
@@ -2112,7 +2110,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
} }
if (dactyl.commandLineOptions.rcFile == "NONE" || dactyl.commandLineOptions.noPlugins) if (dactyl.commandLineOptions.rcFile == "NONE" || dactyl.commandLineOptions.noPlugins)
options["loadplugins"] = false; options["loadplugins"] = [];
if (options["loadplugins"]) if (options["loadplugins"])
dactyl.loadPlugins(); dactyl.loadPlugins();

View File

@@ -133,9 +133,9 @@ var QuickMarks = Module("quickmarks", {
quickmarks.remove(args[0]); quickmarks.remove(args[0]);
}, },
{ {
argCount: "?",
bang: true, bang: true,
completer: function (context) completion.quickmark(context), completer: function (context) completion.quickmark(context)
literal: 0
}); });
commands.add(["qma[rk]"], commands.add(["qma[rk]"],
@@ -171,8 +171,8 @@ var QuickMarks = Module("quickmarks", {
function (args) { function (args) {
quickmarks.list(args[0] || ""); quickmarks.list(args[0] || "");
}, { }, {
argCount: "?",
completer: function (context) completion.quickmark(context), completer: function (context) completion.quickmark(context),
literal: 0
}); });
}, },
completion: function () { completion: function () {

View File

@@ -48,9 +48,10 @@ function Controller(controller) {
this._counBeep = function countBeep() { this._counBeep = function countBeep() {
self.beepCount++; self.beepCount++;
} }
this.errors = [];
this._countError = function countError(message, highlight) { this._countError = function countError(message, highlight) {
if (/\bErrorMsg\b/.test(highlight)) if (/\bErrorMsg\b/.test(highlight))
self.errorMessageCount++; self.errors.push(String(message));
} }
this.dactyl.dactyl.registerObserver("beep", this._countBeep); this.dactyl.dactyl.registerObserver("beep", this._countBeep);
this.dactyl.dactyl.registerObserver("echoLine", this._countError); this.dactyl.dactyl.registerObserver("echoLine", this._countError);
@@ -69,7 +70,6 @@ Controller.prototype = {
beepCount: 0, beepCount: 0,
errorCount: 0, errorCount: 0,
errorMessageCount: 0,
/** /**
* Asserts that an error message is displayed during the execution * Asserts that an error message is displayed during the execution
@@ -83,10 +83,10 @@ Controller.prototype = {
* @param {string} message The message to display upon assertion failure. @optional * @param {string} message The message to display upon assertion failure. @optional
*/ */
assertMessageError: function (func, self, args, message) { assertMessageError: function (func, self, args, message) {
let errorCount = this.errorMessageCount; let errorCount = this.errors.length;
this.assertNoErrors(func, self, args, message); this.assertNoErrors(func, self, args, message);
// dump("assertMessageError " + errorCount + " " + this.errorMessageCount + "\n"); // dump("assertMessageError " + errorCount + " " + this.errorMessageCount + "\n");
return utils.assert('dactyl.assertMessageError', this.errorMessageCount > errorCount, return utils.assert('dactyl.assertMessageError', this.errors.length > errorCount,
"Expected error but got none" + (message ? ": " + message : "")); "Expected error but got none" + (message ? ": " + message : ""));
}, },
@@ -213,7 +213,7 @@ Controller.prototype = {
*/ */
assertNoErrorMessages: function (func, self, args, message) { assertNoErrorMessages: function (func, self, args, message) {
let msg = message ? ": " + message : ""; let msg = message ? ": " + message : "";
let count = this.errorMessageCount; let count = this.errors.length;
try { try {
func.apply(self || this, args || []); func.apply(self || this, args || []);
@@ -222,8 +222,9 @@ Controller.prototype = {
this.dactyl.util.reportError(e); this.dactyl.util.reportError(e);
} }
return utils.assertEqual('dactyl.assertNoErrorMessages', count, this.errorMessageCount, return utils.assertEqual('dactyl.assertNoErrorMessages', count, this.errors.length,
"Error messsages were reported" + msg); "Error messsages were reported" + msg + ":\n\t" +
this.errors.slice(count).join("\n\t"));
}, },
/** /**

View File

@@ -78,9 +78,10 @@ var tests = {
error: ["", "some-non-existent-scheme"] error: ["", "some-non-existent-scheme"]
}, },
command: { command: {
multiOutput: [""], init: ["comclear"],
someOutput: ["foo"], lineOutput: ["", "foobar"],
noOutput: ["foo bar", "-js bar baz"], noOutput: ["foo bar", "-js bar baz"],
multiOutput: [""],
error: ["foo bar", "-js bar baz"] error: ["foo bar", "-js bar baz"]
}, },
comclear: { comclear: {
@@ -353,7 +354,9 @@ var tests = {
complete: ["", "m "] complete: ["", "m "]
}, },
qmarks: { qmarks: {
init: ["delqmarks x"], // init: ["delqmarks a-zA-Z0-9"],
// error: ["", "x"],
init: ["qmark x"],
multiOutput: ["", "m", "x"], multiOutput: ["", "m", "x"],
complete: [""] complete: [""]
}, },
@@ -397,13 +400,36 @@ var tests = {
}, },
sanitize: {}, sanitize: {},
saveas: {}, saveas: {},
sbclose: {}, sbclose: {
noOutput: [""]
},
scriptnames: {}, scriptnames: {},
set: {}, set: {},
setglobal: {}, get setglobal() this.set,
setlocal: {}, get setlocal() this.set,
sidebar: {}, sidebar: {
silent: {}, error: ["!", ""],
noOutput: [
"! Add-ons", "Add-ons", "! Add-ons",
"! Bookmarks", "Bookmarks", "! Bookmarks",
"! Console", "Console", "! Console",
"! Downloads", "Downloads", "! Downloads",
"! History", "History", "! History",
"! Preferences", "Preferences", "! Preferences",
// "!" Previous sidebar isn't saved until the window loads.
// We don't give it enough time.
],
completions: ["", "! "]
},
silent: {
noOutput: [
"echo 'foo'",
"echo " + "foo\nbar".quote(),
"echoerr 'foo'",
"echoerr " + "foo\nbar".quote()
],
completions: [""]
},
source: {}, source: {},
stop: {}, stop: {},
stopall: {}, stopall: {},
@@ -424,10 +450,6 @@ var tests = {
tabprevious: {}, tabprevious: {},
tabrewind: {}, tabrewind: {},
time: {}, time: {},
tlistkeys: {},
tmap: {},
tmapclear: {},
tnoremap: {},
toolbarhide: {}, toolbarhide: {},
toolbarshow: {}, toolbarshow: {},
toolbartoggle: {}, toolbartoggle: {},
@@ -440,11 +462,6 @@ var tests = {
verbose: {}, verbose: {},
version: {}, version: {},
viewsource: {}, viewsource: {},
vlistkeys: {},
vmap: {},
vmapclear: {},
vnoremap: {},
vunmap: {},
winclose: {}, winclose: {},
window: {}, window: {},
winonly: {}, winonly: {},
@@ -510,7 +527,7 @@ for (var val in Iterator(tests)) (function ([command, params]) {
case "singleOutput": case "singleOutput":
runCommands(command, testName, commands, function (cmd) { runCommands(command, testName, commands, function (cmd) {
dactyl.assertMessageLine(/./, "Expected command output: " + cmd); dactyl.assertMessageLine(/./, "Expected command output: " + cmd);
}, true); }, true && !params.errorsOk);
break; break;
case "multiOutput": case "multiOutput":
runCommands(command, testName, commands, function (cmd) { runCommands(command, testName, commands, function (cmd) {
@@ -533,7 +550,6 @@ for (var val in Iterator(tests)) (function ([command, params]) {
commands.forEach(function (cmd) { commands.forEach(function (cmd) {
dactyl.assertNoErrorMessages(function () { dactyl.assertNoErrorMessages(function () {
dactyl.runExCompletion(command + cmd.replace(/^(!?) ?/, "$1 ")); dactyl.runExCompletion(command + cmd.replace(/^(!?) ?/, "$1 "));
controller.waitForPageLoad(controller.tabs.activeTab);
}); });
}); });
}); });