Permalink
Browse files

Incorporating changes from Yammer's foounit modifications; Include so…

…urce line numbers; Added params to configure the suite's UI; Fixed foounit's runtime stats in the browser
  • Loading branch information...
foobarfighter committed Jan 24, 2012
1 parent 56bb607 commit db5c24dd77f23c9c546603089e6c51c455e5f2ea
Showing with 34 additions and 15 deletions.
  1. +13 −5 src/adapters/browser/ui.js
  2. +21 −10 src/adapters/browser/xhr_loader_strategy.js
View
@@ -3,7 +3,9 @@ if (typeof foounit.ui == 'undefined'){
}
(function (ui){
- var _body, _index = 0, _autoScrolling = true;
+ var _body, _index = 0
+ , _autoScrolling = window.location.search.indexOf("foounit.ui.autoScroll=true") > -1
+ , _logAll = window.location.search.indexOf("foounit.ui.log=all") > -1;
var _createTitleNode = function (title, index, className){
var titleDiv = document.createElement('div');
@@ -102,11 +104,15 @@ if (typeof foounit.ui == 'undefined'){
}
this.bottom = function (){
- window.scroll(0, 1000000);
+ if (_autoScrolling){
+ window.scroll(0, 1000000);
+ }
}
this.top = function (){
- window.scroll(0, 0);
+ if (_autoScrolling){
+ window.scroll(0, 0);
+ }
}
}
@@ -146,7 +152,9 @@ if (typeof foounit.ui == 'undefined'){
*/
ui.onSuccess = function (example){
try {
- _body.appendChild(_createSuccessNode(example, _index));
+ if (_logAll){
+ _body.appendChild(_createSuccessNode(example, _index));
+ }
_progressBar.success(_index);
_scroller.bottom();
++_index;
@@ -180,7 +188,7 @@ if (typeof foounit.ui == 'undefined'){
info.pending.length + ' pending, ' +
info.totalCount + ' total');
- _progressBar.log('>> foounit runtime: ', info.runMillis + 'ms');
+ _progressBar.log('>> foounit runtime: ' + info.runMillis + 'ms');
_scroller.top();
} catch (e){
alert('foounit.ui.onFinish: ' + e.message);
@@ -40,9 +40,26 @@ foounit.browser.XhrLoaderStrategy = function (){
return parts[parts.length - 1];
};
- var geval = function (src){
+ var geval = function (src, hint){
var g = foounit.hostenv.global;
- return (g.execScript) ? g.execScript(src) : g.eval.call(null, src);
+ src += appendHint(src, hint);
+ return (g.execScript) ? g.execScript(src) : g.eval.call(g, src);
+ };
+
+ var leval = function (src, hint){
+ src = appendHint(src, hint);
+
+ var ret;
+ if (document.all){ // IE is slightly different
+ eval('ret = ' + src);
+ } else {
+ ret = eval(src);
+ }
+ return ret;
+ };
+
+ var appendHint = function (src, hint){
+ return src + "\r\n////@ sourceURL=" + hint;
};
/**
@@ -54,14 +71,8 @@ foounit.browser.XhrLoaderStrategy = function (){
, module = { exports: {} }
, funcString = '(function (foounit, module, exports, __dirname, __filename){' + code + '});';
- var func;
try {
- // IE sucks shit.
- if (document.all){
- eval('func = ' + funcString);
- } else {
- func = eval(funcString);
- }
+ var func = leval(funcString, path);
func.call({}, foounit, module, module.exports, dirname(path), basename(path));
} catch (e){
console.error('Failed to load path: ' + path + ': ' + e.message, e);
@@ -75,7 +86,7 @@ foounit.browser.XhrLoaderStrategy = function (){
*/
this.load = function (path){
var code = get(path);
- geval(code);
+ geval(code, path);
return true;
};
};

0 comments on commit db5c24d

Please sign in to comment.