Permalink
Browse files

update qunit

  • Loading branch information...
1 parent 8e153fc commit 3338cd202577a3c37ab28227d09f0f5b66d167e2 @kof kof committed Sep 21, 2011
Showing with 31 additions and 17 deletions.
  1. +1 −0 .gitmodules
  2. +1 −1 deps/qunit
  3. +25 −12 lib/child.js
  4. +1 −1 package.json
  5. +1 −1 test/fixtures/testrunner-code.js
  6. +2 −2 test/testrunner.js
View
@@ -1,3 +1,4 @@
+
[submodule "deps/qunit"]
path = deps/qunit
url = https://github.com/jquery/qunit.git
Submodule qunit updated from 28be47 to 167e41
View
@@ -1,13 +1,28 @@
var path = require('path'),
+ fs = require('fs'),
+ vm = require('vm'),
_ = require('underscore'),
trace = require('tracejs').trace,
options = JSON.parse(process.argv[2]);
var currentModule = path.basename(options.code.path, '.js'),
currentTest;
+var qunitPath = __dirname + '/../deps/qunit/qunit/qunit.js',
+ qunitCode = fs.readFileSync(qunitPath, 'utf-8'),
+ sandbox = {
+ require: require,
+ exports: {},
+ window: {setTimeout: setTimeout},
+ console: console,
+ clearTimeout: clearTimeout
+ };
+
+vm.runInNewContext('(function(){'+ qunitCode +'}.call(window))', sandbox, qunitPath);
+_.extend(global, sandbox.exports);
+
// make qunit api global, like it is in the browser
-_.extend(global, require('../deps/qunit/qunit/qunit'));
+//_.extend(global, require('../deps/qunit/qunit/qunit'));
/**
* Require a resource.
@@ -40,48 +55,46 @@ function calcCoverage() {
* Callback for each started test.
* @param {Object} test
*/
-QUnit.testStart = function(test) {
+QUnit.testStart(function(test) {
// currentTest is undefined while first test is not done yet
currentTest = test.name;
// use last module name if no module name defined
currentModule = test.module || currentModule;
-};
+});
/**
* Callback for each assertion.
* @param {Object} data
*/
-QUnit.log = function(data) {
+QUnit.log(function(data) {
data.test = currentTest;
data.module = currentModule;
process.send({
event: 'assertionDone',
data: data
});
-};
+});
/**
* Callback for one done test.
* @param {Object} test
*/
-QUnit.testDone = function(test) {
+QUnit.testDone(function(test) {
// use last module name if no module name defined
test.module = test.module || currentModule;
process.send({
event: 'testDone',
data: test
});
-};
+});
/**
* Callback for all done tests in the file.
* @param {Object} res
*/
-QUnit.done = function done(res) {
- // XXX don't know why, but qunit fires a lot of done callbacks,
- // only the last one has correct data #wtf
+QUnit.done(function done(res) {
clearTimeout(done.timeout);
done.timeout = setTimeout(function() {
if (options.coverage) {
@@ -92,8 +105,8 @@ QUnit.done = function done(res) {
event: 'done',
data: res
});
- }, 300);
-};
+ }, 1000);
+});
// require deps
View
@@ -1,7 +1,7 @@
{
"name": "qunit",
"description": "A port of QUnit unit testing framework to nodejs",
- "version": "0.2.2pre",
+ "version": "0.2.3pre",
"author": "Oleg Slobodskoi <oleg008@gmail.com>",
"contributors": [
{"name": "Jonathan Buchanan"}
@@ -5,5 +5,5 @@ exports.myMethod = function() {
exports.myAsyncMethod = function(callback) {
setTimeout(function() {
callback(123);
- }, 1);
+ }, 100);
}
View
@@ -29,8 +29,8 @@ chain.add('base testrunner', function() {
failed: 2,
passed: 3
};
-
- a.deepEqual(stat, res, 'base testrunner test works');
+
+ a.deepEqual(stat, res, 'base testrunner test');
chain.next();
});
});

0 comments on commit 3338cd2

Please sign in to comment.