Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow customization of namespace for TestTasks.

  • Loading branch information...
commit ab5da01a8f17493fdbba4b3c8d264b4aef72d5e3 1 parent aa80ca7
mde authored
Showing with 9 additions and 10 deletions.
  1. +9 −10 lib/test_task.js
View
19 lib/test_task.js
@@ -21,23 +21,22 @@ var path = require('path')
, exec = require('child_process').exec
, currDir = process.cwd();
-var TestTask = function (name, directory) {
+var TestTask = function (projectName, directory, namespaceName) {
+ var ns = namespaceName || 'test';
- this.directory = directory;
+ desc('Run the tests for ' + projectName);
+ task(ns, [ns + ':run']);
- desc('Run the tests for ' + name);
- task('test', ['test:run']);
-
- namespace('test', function () {
+ namespace(ns, function () {
task('run', function () {
// Grab all the JS files in the specified directory
var jsFiles = jake.readdirR(directory).filter(function (f) {
- return /\.js$/.test(f);
+ return (/\.js$/).test(f);
});
// Create a namespace for all the testing tasks to live in
- namespace('testExec', function () {
+ namespace(ns + 'Exec', function () {
// Each test will be a prereq for the dummy top-level task
var prereqs = []
// Continuation to pass to the async tests, wrapping `continune`
@@ -52,7 +51,7 @@ var TestTask = function (name, directory) {
jake.logger.log('Running ' + n);
// 'this' will be the task when action is run
return a.call(this, next);
- }
+ };
};
// Pull in each test-file, and iterate over any exported
@@ -85,7 +84,7 @@ var TestTask = function (name, directory) {
// with `invoke` that is async (or has async prereqs), have to listen
// for the 'complete' event to know when it's done
task('__top__', prereqs);
- var t = jake.Task['testExec:__top__'];
+ var t = jake.Task[ns + 'Exec:__top__'];
t.addListener('complete', function () {
jake.logger.log('All tests ran successfully');
complete();
Please sign in to comment.
Something went wrong with that request. Please try again.