Browse files

Merge branch 'master' into develop

Conflicts:
	package.json
	src/adapters/node.js
  • Loading branch information...
2 parents d1329be + 5db8791 commit 8bb6de0a792d2354cee908fdecc6cb4655c818fc @foobarfighter committed Jan 23, 2012
Showing with 39 additions and 15 deletions.
  1. +8 −0 Jakefile
  2. +4 −4 package.json
  3. +13 −4 src/adapters/node.js
  4. +14 −7 src/adapters/node/colors.js
View
8 Jakefile
@@ -42,6 +42,14 @@ namespace('spec', function (){
task('browser', ['build:all'], function (){
generateBrowserSuite();
+
+ var connect = require('connect');
+ var port = process.env.FOOUNIT_PORT || 5057;
+
+ console.log('You can now run your tests by opening http://localhost:' + port + '/spec/browser/suite_runner.html in your browser');
+ connect(connect.static(__dirname)).listen(port, 'localhost');
+ console.log('Static web server is started');
+
});
task('server', ['build:all'], function (){
View
8 package.json
@@ -4,11 +4,11 @@
, "repository" : {"type": "git", "url": "http://github.com/foobarfighter/foounit.git"}
, "author" : "Bob Remeika"
, "version" : "0.1.0"
-, "main" : "./src/adapters/node"
+, "main" : "./src/adapters/node"
, "bin" : "./bin/foounit"
, "dependencies": {
- "nomnom" : ">=0.5.0",
- "fsh" : "=0.0.2",
- "underscore" : "=1.1.6"
+ "nomnom" : ">=0.5.0",
+ "fsh" : "=0.0.2",
+ "underscore": ""
}
}
View
17 src/adapters/node.js
@@ -24,9 +24,18 @@ foounit.cli = require('./node/cli').cli;
foounit.generateSuite = require('./node/cli').generateSuite;
var adapter = (function (){
- var sys = require('sys')
+ var puts
, fs = require('fs')
- , runInThisContext = (process.binding('evals').Script || require('vm').Script).runInThisContext;
+ , runInThisContext = (
+ process.binding('evals').Script || // older node versions
+ require('vm') // newer node versions
+ ).runInThisContext;
+
+ try {
+ puts = require('util').puts;
+ } catch (e) {
+ puts = require('sys').puts;
+ }
// Private variables
var self = {}, _specdir;
@@ -52,7 +61,7 @@ var adapter = (function (){
self.load = function (path){
path = foounit.translatePath(path) + '.js';
var code = fs.readFileSync(path);
- runInThisContext(code, path, true);
+ runInThisContext(code, path, true);
}
/**
@@ -82,7 +91,7 @@ var adapter = (function (){
if (example.isFailure()){
colors.putsRed('F');
colors.putsRed(example.getFullDescription());
- sys.puts(new Array(example.getFullDescription().length+1).join('='));
+ puts(new Array(example.getFullDescription().length+1).join('='));
colors.highlightSpecs(example.getException().stack);
} else if (example.isSuccess()){
colors.printGreen('.');
View
21 src/adapters/node/colors.js
@@ -1,24 +1,31 @@
// TODO: Switch to a better color library
-var sys = require('sys');
+var puts;
+try {
+ puts = require('util').puts;
+ print = require('util').print;
+} catch (e) {
+ puts = require('sys').puts;
+ print = require('sys').print;
+}
exports.putsRed = function (str){
- sys.puts('\33[31m' + str + '\33[39m');
+ puts('\33[31m' + str + '\33[39m');
}
exports.printYellow = function (str){
- sys.print('\33[33m' + str + '\33[39m');
+ print('\33[33m' + str + '\33[39m');
}
exports.putsYellow = function (str){
- sys.puts('\33[33m' + str + '\33[39m');
+ puts('\33[33m' + str + '\33[39m');
}
exports.printGreen = function (str){
- sys.print('\33[32m' + str + '\33[39m');
+ print('\33[32m' + str + '\33[39m');
}
exports.putsGreen = function (str){
- sys.puts('\33[32m' + str + '\33[39m');
+ puts('\33[32m' + str + '\33[39m');
}
exports.highlightSpecs = function (stack){
@@ -28,7 +35,7 @@ exports.highlightSpecs = function (stack){
if (line.match(/_spec\.js/)){
exports.printYellow(line + "\n");
} else {
- sys.puts(line);
+ puts(line);
}
}
}

0 comments on commit 8bb6de0

Please sign in to comment.