mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 10:37:59 +01:00
added ability to just run single tests of the regression suite
This commit is contained in:
@@ -8,7 +8,8 @@
|
|||||||
// NOTE: It is preferable to run this script in a clean profile or at least do NOT use
|
// NOTE: It is preferable to run this script in a clean profile or at least do NOT use
|
||||||
// :mkvimperatorrc afterwards, as it can remove commands/mappings, etc.
|
// :mkvimperatorrc afterwards, as it can remove commands/mappings, etc.
|
||||||
//
|
//
|
||||||
// Usage: :regr[essions]
|
// Usage: :[count]regr[essions]
|
||||||
|
// When [count] is given, just run this test. TODO: move to :regressions [spec]?
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -88,7 +89,7 @@ var Tests = {
|
|||||||
|
|
||||||
commands.addUserCommand(["regr[essions]"],
|
commands.addUserCommand(["regr[essions]"],
|
||||||
"Run regression tests",
|
"Run regression tests",
|
||||||
function (args, special)
|
function (args, special, count)
|
||||||
{
|
{
|
||||||
// TODO: might need to increase the 'messages' option temprarily
|
// TODO: might need to increase the 'messages' option temprarily
|
||||||
// TODO: count (better even range) support to just run test 34 of 102
|
// TODO: count (better even range) support to just run test 34 of 102
|
||||||
@@ -101,41 +102,50 @@ commands.addUserCommand(["regr[essions]"],
|
|||||||
let now = Date.now();
|
let now = Date.now();
|
||||||
let totalTests = tests.length + functions.length;
|
let totalTests = tests.length + functions.length;
|
||||||
let successfulTests = 0;
|
let successfulTests = 0;
|
||||||
let currentTest = 1;
|
let currentTest = 0;
|
||||||
|
|
||||||
|
// TODO: might want to unify 'tests' and 'functions' handling
|
||||||
// 1.) run commands and mappings tests
|
// 1.) run commands and mappings tests
|
||||||
tests.forEach(function (test) {
|
for (let [, test] in Iterator(tests))
|
||||||
|
{
|
||||||
|
if (count >= 1 && ++currentTest != count)
|
||||||
|
continue;
|
||||||
|
|
||||||
let testDescription = util.clip(test.cmds.join(" -> "), 80);
|
let testDescription = util.clip(test.cmds.join(" -> "), 80);
|
||||||
liberator.echomsg("Running test " + currentTest++ + " of " + totalTests + ": " + testDescription);
|
liberator.echomsg("Running test " + currentTest + " of " + totalTests + ": " + testDescription);
|
||||||
Tests.resetEnvironment();
|
Tests.resetEnvironment();
|
||||||
if ("init" in test)
|
if ("init" in test)
|
||||||
test.init();
|
test.init();
|
||||||
|
|
||||||
test.cmds.forEach(function (cmd) {
|
test.cmds.forEach(function (cmd) {
|
||||||
if (cmd.indexOf(":") == 0)
|
if (cmd[0] == ":")
|
||||||
liberator.execute(cmd);
|
liberator.execute(cmd);
|
||||||
else
|
else
|
||||||
events.feedkeys(cmd);
|
events.feedkeys(cmd);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!test.verify())
|
if (!test.verify())
|
||||||
liberator.echoerr("Test failed: " + testDescription);
|
liberator.echoerr("Test " + currentTest + " failed: " + testDescription);
|
||||||
else
|
else
|
||||||
successfulTests++;
|
successfulTests++;
|
||||||
});
|
}
|
||||||
|
|
||||||
// 2.) Run function tests
|
// 2.) Run function tests
|
||||||
functions.forEach(function (func) {
|
for (let [, func] in Iterator(functions))
|
||||||
liberator.echomsg("Running test " + currentTest++ + " of " + totalTests + ": " + util.clip(func.toString().replace(/[\s\n]+/gm, " "), 80));
|
{
|
||||||
|
if (count >= 1 && ++currentTest != count)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
liberator.echomsg("Running test " + currentTest + " of " + totalTests + ": " + util.clip(func.toString().replace(/[\s\n]+/gm, " "), 80));
|
||||||
Tests.resetEnvironment();
|
Tests.resetEnvironment();
|
||||||
|
|
||||||
if (!func())
|
if (!func())
|
||||||
liberator.echoerr("Test failed!");
|
liberator.echoerr("Test " + currentTest + " failed!");
|
||||||
else
|
else
|
||||||
successfulTests++;
|
successfulTests++;
|
||||||
});
|
}
|
||||||
|
|
||||||
liberator.echomsg(successfulTests + " of " + totalTests + " tests successfully completed in " + ((Date.now() - now) / 1000.0) + " msec");
|
liberator.echomsg(successfulTests + " of " + (count >= 1 ? 1 : totalTests) + " tests successfully completed in " + ((Date.now() - now) / 1000.0) + " msec");
|
||||||
liberator.execute(":messages");
|
liberator.execute(":messages");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +156,8 @@ commands.addUserCommand(["regr[essions]"],
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
bang: true,
|
bang: true,
|
||||||
argCount: 0
|
argCount: 0,
|
||||||
|
count: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// vimperator: set et ts=4 sw=4 :
|
// vimperator: set et ts=4 sw=4 :
|
||||||
|
|||||||
Reference in New Issue
Block a user