Skip to content

Commit

Permalink
adding junit report, making it possible to specify unit test files/dirs
Browse files Browse the repository at this point in the history
from cmd line param and also possible to specify report from cmd line
param
  • Loading branch information
gitaaron committed Oct 7, 2011
1 parent cd5b97e commit baf1b95
Show file tree
Hide file tree
Showing 4 changed files with 292 additions and 270 deletions.
226 changes: 114 additions & 112 deletions deps/ejs.js
Expand Up @@ -8,118 +8,120 @@
/** /**
* Module dependencies. * Module dependencies.
*/ */
define(['exports'], function(exports) {
var sys = require('sys');

/**
* Library version.
*/

exports.version = '0.0.3';

/**
* Intermediate js cache.
*
* @type Object
*/

var cache = {};

/**
* Clear intermediate js cache.
*
* @api public
*/

exports.clearCache = function(){
cache = {};
};

/**
* Escape the given string of `html`.
*
* @param {String} html
* @return {String}
* @api private
*/

function escape(html){
return String(html)
.replace(/&(?!\w+;)/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
}


var sys = require('sys'); /**

* Parse the given `str` of ejs, returning the function body.
/** *
* Library version. * @param {String} str
*/ * @return {String}

* @api public
exports.version = '0.0.3'; */


/** var parse = exports.parse = function(str){
* Intermediate js cache. return 'var buf = [];\n'
* + "with (locals) {\nbuf.push('"
* @type Object + String(str)
*/ .replace(/[\r\t]/g, " ")

.replace(/\n/g, "\\n")
var cache = {}; .split("<%").join("\t")

.replace(/((^|%>)[^\t]*)'/g, "$1\r")
/** .replace(/\t=(.*?)%>/g, "', escape($1) ,'")
* Clear intermediate js cache. .replace(/\t-(.*?)%>/g, "', $1 ,'")
* .split("\t").join("');")
* @api public .split("%>").join("buf.push('")
*/ .split("\r").join("\\'")

+ "');\n}\nreturn buf.join('');";
exports.clearCache = function(){ };
cache = {};
}; /**

* Compile the given `str` of ejs into a `Function`.
/** *
* Escape the given string of `html`. * @param {String} str
* * @param {Object} options
* @param {String} html * @return {Function}
* @return {String} * @api public
* @api private */
*/

var compile = exports.compile = function(str, options){
function escape(html){ if (options.debug) sys.puts(parse(str));
return String(html) return new Function('locals, escape', parse(str));
.replace(/&(?!\w+;)/g, '&amp;') };
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;') /**
.replace(/"/g, '&quot;'); * Render the given `str` of ejs.
} *

* Options:
/** *
* Parse the given `str` of ejs, returning the function body. * - `locals` Local variables object
* * - `cache` Compiled functions are cached, requires `filename`
* @param {String} str * - `filename` Used by `cache` to key caches
* @return {String} * - `context|scope` Function execution context
* @api public * - `debug` Output generated function body
*/ *

* @param {String} str
var parse = exports.parse = function(str){ * @param {Object} options
return 'var buf = [];\n' * @return {String}
+ "with (locals) {\nbuf.push('" * @api public
+ String(str) */
.replace(/[\r\t]/g, " ")
.replace(/\n/g, "\\n") exports.render = function(str, options){
.split("<%").join("\t") var fn,
.replace(/((^|%>)[^\t]*)'/g, "$1\r") options = options || {};
.replace(/\t=(.*?)%>/g, "', escape($1) ,'") if (options.cache) {
.replace(/\t-(.*?)%>/g, "', $1 ,'") if (options.filename) {
.split("\t").join("');") fn = cache[options.filename] = compile(str, options);
.split("%>").join("buf.push('") } else {
.split("\r").join("\\'") throw new Error('"cache" option requires "filename".');
+ "');\n}\nreturn buf.join('');"; }
};

/**
* Compile the given `str` of ejs into a `Function`.
*
* @param {String} str
* @param {Object} options
* @return {Function}
* @api public
*/

var compile = exports.compile = function(str, options){
if (options.debug) sys.puts(parse(str));
return new Function('locals, escape', parse(str));
};

/**
* Render the given `str` of ejs.
*
* Options:
*
* - `locals` Local variables object
* - `cache` Compiled functions are cached, requires `filename`
* - `filename` Used by `cache` to key caches
* - `context|scope` Function execution context
* - `debug` Output generated function body
*
* @param {String} str
* @param {Object} options
* @return {String}
* @api public
*/

exports.render = function(str, options){
var fn,
options = options || {};
if (options.cache) {
if (options.filename) {
fn = cache[options.filename] = compile(str, options);
} else { } else {
throw new Error('"cache" option requires "filename".'); fn = compile(str, options);
} }
} else { return fn.call(
fn = compile(str, options); options.context || options.scope,
} options.locals || {},
return fn.call( escape);
options.context || options.scope, };
options.locals || {}, return this;
escape); });
};
3 changes: 3 additions & 0 deletions lib/nodeunit.js
Expand Up @@ -64,6 +64,9 @@ define(['exports', '../deps/async', './types', './utils', './core', './reporters
if (err) throw err; if (err) throw err;
async.concatSeries(files, function (file, cb) { async.concatSeries(files, function (file, cb) {
var name = path.basename(file); var name = path.basename(file);

if(file.slice(-3)!='.js') file = file+'.js'; // if file is missing extension then add it

exports.runModule(name, require(file), options, cb); exports.runModule(name, require(file), options, cb);
}, },
function (err, all_assertions) { function (err, all_assertions) {
Expand Down

0 comments on commit baf1b95

Please sign in to comment.