Permalink
Browse files

Fixed a bad merge of testBuilder.coffee

  • Loading branch information...
1 parent ea6543e commit d1c9dc503b13b3ab8eab7fa32fbc999463e0263d this guy committed Dec 19, 2012
Showing with 25 additions and 37 deletions.
  1. +5 −7 lib/mf-tools/test/testBuilder.js
  2. +1 −1 package.json
  3. +19 −29 src/test/testBuilder.coffee
View
12 lib/mf-tools/test/testBuilder.js
@@ -1,5 +1,5 @@
(function() {
- var TestBuilder, exec, fs, glob, path, util, _harnessMod,
+ var TestBuilder, exec, fs, glob, path, util,
__slice = Array.prototype.slice;
exec = require("child_process").exec;
@@ -12,16 +12,14 @@
glob = require('glob');
- _harnessMod = path.join(__dirname, "harness.js");
-
TestBuilder = (function() {
function TestBuilder() {
this._includePaths = [];
this._testDefinitions = {};
this._mochaReporter = process.env.MOCHA_REPORTER || 'spec';
this._mochaUi = process.env.MOCHA_UI || 'tdd';
- this._harnessMod = path.join(__dirname, "harness.js");
+ this._harnessMod = "harness.js";
this._retVal = 0;
this._preRequire = void 0;
this._globals = ['window', 'document'];
@@ -72,11 +70,11 @@
};
TestBuilder.prototype.setGlobals = function() {
- var global, globals, _i, _len;
+ var g, globals, _i, _len;
globals = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
for (_i = 0, _len = globals.length; _i < _len; _i++) {
- global = globals[_i];
- this._globals.push(global);
+ g = globals[_i];
+ this._globals.push(g);
}
return this;
};
View
2 package.json
@@ -1,7 +1,7 @@
{
"name": "mf-tools",
"description": "Build and test tools.",
- "version": "0.1.1",
+ "version": "0.1.2",
"author": "Mason Browne <mason@massivelyfun.com>",
"contributors": [
{"name": "Dean Hudson", "email": "dean@massivelyfun.com"},
View
48 src/test/testBuilder.coffee
@@ -1,24 +1,21 @@
{exec} = require "child_process"
-path = require "path"
-util = require "util"
-fs = require 'fs'
-glob = require 'glob'
-
-_harnessMod = path.join(__dirname, "harness.js")
+path = require "path"
+util = require "util"
+fs = require 'fs'
+glob = require 'glob'
class TestBuilder
constructor: ->
- @_includePaths = []
+ @_includePaths = []
@_testDefinitions = {}
- @_mochaReporter = process.env.MOCHA_REPORTER || 'spec'
- @_mochaUi = process.env.MOCHA_UI || 'tdd'
- # Harness.js file out of the current dir
- @_harnessMod = path.join(__dirname, "harness.js")
- @_retVal = 0
- @_preRequire = undefined
- @_globals = ['window', 'document']
+ @_mochaReporter = process.env.MOCHA_REPORTER || 'spec'
+ @_mochaUi = process.env.MOCHA_UI || 'tdd'
+ @_harnessMod = "harness.js" # Harness.js file out of the current dir
+ @_retVal = 0
+ @_preRequire = undefined
+ @_globals = ['window', 'document']
+ # Pass in the handle for that Cakefile's task function
- # Pass in the handle for that Cakefile's task function
@harnessModule: ->
@_harnessMod
@@ -27,7 +24,6 @@ class TestBuilder
preRequire: (mod) ->
@_preRequire = mod
@
-
_mochaPreRequire: ->
if @_preRequire
@_preRequire
@@ -54,26 +50,21 @@ class TestBuilder
if require.main.filename.indexOf('mf-tools') < 0 then path.join('mf-tools', p) else p
nodeEnv: (@_env) ->
-
task: (@_task) ->
@
-
# Paths to be included in the test process before running the test.
includePaths: (paths...) ->
@_includePaths.push p for p in paths
@
- # Set any globals used in the app. Defaults to window and document
setGlobals: (globals...) ->
- @_globals.push global for global in globals
- @
-
+ @_globals.push g for g in globals
+ @
# Test definitions:
# tests =
# taskName: "test/glob/*.test.coffee"
tests: (@_testDefinitions) ->
@
-
build: ->
unless @_task
"TestBuilder requires task function to define tasks."
@@ -89,13 +80,11 @@ class TestBuilder
do (t) ->
invoke "test:#{t}"
@
-
_testCmd: ->
"NODE_PATH=$NODE_PATH:#{@_includePaths.join ':'} mocha --globals #{@_globals.join ','} -u #{@_mochaUi} -R #{@_mochaReporter} --require #{@_mochaPreRequire()}"
- # Run our test. If we're running in xunit output mode, we want to
- # write each test file's output to a separate file, so that xunit
- # doesn't freak out.
+ # Run our test. If we're running in xunit output mode, we want to write each test file's
+ # output to a separate file, so that xunit doesn't freak out.
_runTests: (testGlob, msg) ->
childEnv = {}
childEnv[k] = v for k,v of process.env
@@ -106,14 +95,15 @@ class TestBuilder
env: childEnv
encoding: 'utf8'
, (err, stdout, stderr) =>
- util.puts stdout # verbiage
+ # console.log "\n#{msg}\n==========================="
+ util.puts stdout # verbiage
console.log stderr # test summary
@_retVal = 1 if err != null
if @_mochaReporter == 'xunit'
fs.mkdirSync('reports') unless fs.readdirSync('.').indexOf('reports') >= 0
outFile = fs.createWriteStream "reports/#{file.replace(/^.*[\\\/]/, '')}.xml", { flags : 'w' }
child.stdout.pipe(outFile)
-
+
_addTestTask: (name, dir) ->
taskName = "test:#{name}"

0 comments on commit d1c9dc5

Please sign in to comment.