Permalink
Browse files

Ability to only run tests matching a given string

  • Loading branch information...
1 parent a4915ef commit e69c16c0440680505cf01a2b236ce2f2f2b95f79 cloudhead committed Apr 29, 2010
Showing with 13 additions and 1 deletion.
  1. +13 −1 lib/vows.js
View
@@ -180,6 +180,8 @@ vows.tell = function (topic, tests) {
this.tests = tests;
this.remaining = 0;
+ var matcher = new(RegExp)(process.argv[2] || '.*');
+
function Context(vow, ctx) {
this.tests = vow.callback;
this.topics = (ctx.topics || []).slice(0);
@@ -208,11 +210,21 @@ vows.tell = function (topic, tests) {
} else {
// Count the number of vows/promises expected to fire,
// so we know when the tests are over.
+ // We match the keys against `matcher`, to decide
+ // whether or not they should be included in the test.
(function count(tests) {
+ var match = false;
vows.remaining++;
Object.keys(tests).forEach(function (key) {
- if (! (tests[key] instanceof Function)) count(tests[key]);
+ if (typeof(tests[key]) !== "function") {
+ if (! (match = count(tests[key]) ||
+ match || matcher.test(key))) {
+ delete tests[key];
+ vows.remaining--;
+ }
+ }
});
+ return match;
})(vows.tests);
// The test runner, it calls itself recursively, passing the

0 comments on commit e69c16c

Please sign in to comment.