From 9d0f841def419b7c661f04929ecb1d1268d54e02 Mon Sep 17 00:00:00 2001 From: Oleg Slobodskoi Date: Fri, 3 Oct 2014 00:20:04 +0200 Subject: [PATCH 01/28] closes #98 implemented child block detection --- lib/child.js | 9 ++++ lib/testrunner.js | 64 +++++++++++++++++++---------- package.json | 2 +- readme.md | 5 ++- test/fixtures/infinite-loop-code.js | 1 + test/fixtures/infinite-loop-test.js | 3 ++ test/testrunner.js | 10 +++++ 7 files changed, 70 insertions(+), 24 deletions(-) create mode 100644 test/fixtures/infinite-loop-code.js create mode 100644 test/fixtures/infinite-loop-test.js diff --git a/lib/child.js b/lib/child.js index c0dda7b..f270987 100644 --- a/lib/child.js +++ b/lib/child.js @@ -16,6 +16,14 @@ var options = JSON.parse(process.argv[2]), currentModule = path.basename(options.code.path, '.js'), currentTest; +// send ping messages to when child is blocked. +// after I sent the first ping, testrunner will start to except the next ping +// within maxBlockDuration, otherwise this process will be killed +process.send({event: 'ping'}); +setInterval(function() { + process.send({event: 'ping'}); +}, Math.floor(options.maxBlockDuration / 2)); + process.on('uncaughtException', function(err) { if (QUnit.config.current) { QUnit.ok(false, 'Test threw unexpected exception: ' + err.message); @@ -168,3 +176,4 @@ _require(options.code, true); options.tests.forEach(function(test) { _require(test, false); }); + diff --git a/lib/testrunner.js b/lib/testrunner.js index f7a7621..6233336 100644 --- a/lib/testrunner.js +++ b/lib/testrunner.js @@ -45,7 +45,10 @@ options = exports.options = { deps: null, // define namespace your code will be attached to on global['your namespace'] - namespace: null + namespace: null, + + // max amount of ms child can be blocked, after that we assume running an infinite loop + maxBlockDuration: 1000 }; /** @@ -55,6 +58,7 @@ options = exports.options = { */ function runOne(opts, callback) { var child; + var pingCheckTimeoutId; child = cp.fork( __dirname + '/child.js', @@ -67,28 +71,44 @@ function runOne(opts, callback) { child.kill(); } + function complete(err, data) { + kill(); + clearTimeout(pingCheckTimeoutId); + callback(err, data) + } + child.on('message', function(msg) { - if (msg.event === 'assertionDone') { - log.add('assertions', msg.data); - } else if (msg.event === 'testDone') { - log.add('tests', msg.data); - } else if (msg.event === 'done') { - msg.data.code = opts.code.path; - log.add('summaries', msg.data); - if (opts.coverage) { - coverage.add(msg.data.coverage); - msg.data.coverage = coverage.get(); - msg.data.coverage.code = msg.data.code; - log.add('coverages', msg.data.coverage); - } - if (opts.log.testing) { - console.log('done'); - } - callback(null, msg.data); - kill(); - } else if (msg.event === 'uncaughtException') { - callback(_.extend(new Error(), msg.data)); - kill(); + switch (msg.event) { + case 'ping': + clearTimeout(pingCheckTimeoutId); + pingCheckTimeoutId = setTimeout(function() { + complete(new Error('Process blocked for too long')); + }, opts.maxBlockDuration); + break; + case 'assertionDone': + log.add('assertions', msg.data); + break; + case 'testDone': + log.add('tests', msg.data); + break; + case 'done': + clearTimeout(pingCheckTimeoutId); + msg.data.code = opts.code.path; + log.add('summaries', msg.data); + if (opts.coverage) { + coverage.add(msg.data.coverage); + msg.data.coverage = coverage.get(); + msg.data.coverage.code = msg.data.code; + log.add('coverages', msg.data.coverage); + } + if (opts.log.testing) { + console.log('done'); + } + complete(null, msg.data); + break; + case 'uncaughtException': + complete(_.extend(new Error(), msg.data)); + break; } }); diff --git a/package.json b/package.json index 24455c4..62b6688 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "qunit", "description": "QUnit testing framework for nodejs", - "version": "0.7.2", + "version": "0.7.3", "author": "Oleg Slobodskoi ", "contributors": [ { diff --git a/readme.md b/readme.md index 35b52f5..44266f8 100644 --- a/readme.md +++ b/readme.md @@ -97,7 +97,10 @@ var testrunner = require("qunit"); deps: null, // define namespace your code will be attached to on global['your namespace'] - namespace: null + namespace: null, + + // max amount of ms child can be blocked, after that we assume running an infinite loop + maxBlockDuration: 1000 } ``` diff --git a/test/fixtures/infinite-loop-code.js b/test/fixtures/infinite-loop-code.js new file mode 100644 index 0000000..7d69e1c --- /dev/null +++ b/test/fixtures/infinite-loop-code.js @@ -0,0 +1 @@ +while(1) {} diff --git a/test/fixtures/infinite-loop-test.js b/test/fixtures/infinite-loop-test.js new file mode 100644 index 0000000..a43d419 --- /dev/null +++ b/test/fixtures/infinite-loop-test.js @@ -0,0 +1,3 @@ +test('infinite loop', function() { + ok(true) +}) diff --git a/test/testrunner.js b/test/testrunner.js index 536b7dd..fdb3eb0 100644 --- a/test/testrunner.js +++ b/test/testrunner.js @@ -153,6 +153,16 @@ chain.add('uncaught exception', function() { }); }); +chain.add('infinite loop', function() { + tr.run({ + code: fixtures + '/infinite-loop-code.js', + tests: fixtures + '/infinite-loop-test.js', + }, function(err, res) { + a.ok(err instanceof Error, 'error was forwarded'); + chain.next(); + }); +}); + chain.add('coverage', function() { tr.options.coverage = true; tr.run({ From f57e0db5194257ba6807072433370398bbb80cb7 Mon Sep 17 00:00:00 2001 From: Oleg Slobodskoi Date: Sat, 4 Oct 2014 04:00:49 +0200 Subject: [PATCH 02/28] inc maxBlockDuration --- lib/testrunner.js | 2 +- package.json | 2 +- readme.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/testrunner.js b/lib/testrunner.js index 6233336..89cc2ae 100644 --- a/lib/testrunner.js +++ b/lib/testrunner.js @@ -48,7 +48,7 @@ options = exports.options = { namespace: null, // max amount of ms child can be blocked, after that we assume running an infinite loop - maxBlockDuration: 1000 + maxBlockDuration: 2000 }; /** diff --git a/package.json b/package.json index 62b6688..acc0b1b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "qunit", "description": "QUnit testing framework for nodejs", - "version": "0.7.3", + "version": "0.7.4", "author": "Oleg Slobodskoi ", "contributors": [ { diff --git a/readme.md b/readme.md index 44266f8..56501f3 100644 --- a/readme.md +++ b/readme.md @@ -100,7 +100,7 @@ var testrunner = require("qunit"); namespace: null, // max amount of ms child can be blocked, after that we assume running an infinite loop - maxBlockDuration: 1000 + maxBlockDuration: 2000 } ``` From 7065bb8204801111cae56b68ed89911eae645beb Mon Sep 17 00:00:00 2001 From: Oleg Slobodskoi Date: Tue, 7 Oct 2014 13:26:50 +0200 Subject: [PATCH 03/28] #105 forward argv to the child --- lib/child.js | 2 +- lib/testrunner.js | 8 +++----- package.json | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/child.js b/lib/child.js index f270987..a4a3411 100644 --- a/lib/child.js +++ b/lib/child.js @@ -12,7 +12,7 @@ var QUnit = require('qunitjs'), // http://GOESSNER.net/articles/JsonPath/ require('../support/json/cycle'); -var options = JSON.parse(process.argv[2]), +var options = JSON.parse(process.argv.pop()), currentModule = path.basename(options.code.path, '.js'), currentTest; diff --git a/lib/testrunner.js b/lib/testrunner.js index 89cc2ae..08d3f77 100644 --- a/lib/testrunner.js +++ b/lib/testrunner.js @@ -59,12 +59,10 @@ options = exports.options = { function runOne(opts, callback) { var child; var pingCheckTimeoutId; + var argv = process.argv.slice(); - child = cp.fork( - __dirname + '/child.js', - [JSON.stringify(opts)], - {env: process.env} - ); + argv.push(JSON.stringify(opts)); + child = cp.fork(__dirname + '/child.js', argv, {env: process.env}); function kill() { process.removeListener('exit', kill); diff --git a/package.json b/package.json index acc0b1b..436325e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "qunit", "description": "QUnit testing framework for nodejs", - "version": "0.7.4", + "version": "0.7.5", "author": "Oleg Slobodskoi ", "contributors": [ { From 95ccdc798a4a358377468f28974a4323339927c3 Mon Sep 17 00:00:00 2001 From: Oleg Abrosimov Date: Tue, 23 Dec 2014 21:19:07 +0500 Subject: [PATCH 04/28] Update package.json qunit version upgrade: https://github.com/kof/node-qunit/issues/110 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 436325e..fa214fe 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "argsparser": "^0.0.6", "cli-table": "^0.3.0", "co": "^3.0.6", - "qunitjs": "1.10.0", + "qunitjs": "1.16.0", "tracejs": "^0.1.8", "underscore": "^1.6.0" }, From 1f21d7ffe1a3819b9df23004af45c94c3f346dca Mon Sep 17 00:00:00 2001 From: Oleg Abrosimov Date: Tue, 23 Dec 2014 21:24:48 +0500 Subject: [PATCH 05/28] Update readme.md travis status icon --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 56501f3..957a0aa 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,7 @@ ## QUnit testing framework for nodejs. +[![Build Status](https://travis-ci.org/olegabr/node-qunit.png?branch=master)](https://travis-ci.org/olegabr/node-qunit) + http://qunitjs.com http://github.com/jquery/qunit From 57754a6b08989820acd91a24d61393140a5c6a68 Mon Sep 17 00:00:00 2001 From: Oleg Abrosimov Date: Tue, 23 Dec 2014 22:04:08 +0500 Subject: [PATCH 06/28] Update readme.md set the upstream build status --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 957a0aa..3dad1e3 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ ## QUnit testing framework for nodejs. -[![Build Status](https://travis-ci.org/olegabr/node-qunit.png?branch=master)](https://travis-ci.org/olegabr/node-qunit) +[![Build Status](https://travis-ci.org/kof/node-qunit.png?branch=master)](https://travis-ci.org/kof/node-qunit) http://qunitjs.com From 6f121072b6582f5fb0c69e3944e243e6e65a5571 Mon Sep 17 00:00:00 2001 From: Oleg Abrosimov Date: Tue, 23 Dec 2014 22:07:50 +0500 Subject: [PATCH 07/28] Update package.json temporarily change it back to not interfere with tests that are already broken --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fa214fe..436325e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "argsparser": "^0.0.6", "cli-table": "^0.3.0", "co": "^3.0.6", - "qunitjs": "1.16.0", + "qunitjs": "1.10.0", "tracejs": "^0.1.8", "underscore": "^1.6.0" }, From 7307e8ecea2b77bb7e5c435644f6e242b28a49f7 Mon Sep 17 00:00:00 2001 From: Oleg Abrosimov Date: Tue, 23 Dec 2014 22:21:44 +0500 Subject: [PATCH 08/28] Update package.json Upgrade qunitjs version once more... --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 436325e..fa214fe 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "argsparser": "^0.0.6", "cli-table": "^0.3.0", "co": "^3.0.6", - "qunitjs": "1.10.0", + "qunitjs": "1.16.0", "tracejs": "^0.1.8", "underscore": "^1.6.0" }, From bc39c6e6f3907db5796a36c38e676f15c6e041d9 Mon Sep 17 00:00:00 2001 From: Oleg Abrosimov Date: Tue, 23 Dec 2014 22:32:01 +0500 Subject: [PATCH 09/28] Update package.json The error is caused by this 1.10.0 to 1.16.0 upgrade --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fa214fe..436325e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "argsparser": "^0.0.6", "cli-table": "^0.3.0", "co": "^3.0.6", - "qunitjs": "1.16.0", + "qunitjs": "1.10.0", "tracejs": "^0.1.8", "underscore": "^1.6.0" }, From c926ea0c2577320cd10242cd919a11e1c6b93b71 Mon Sep 17 00:00:00 2001 From: Jakub Olek Date: Tue, 30 Dec 2014 11:55:09 +0100 Subject: [PATCH 10/28] Default reporters lcov, json with a way to specify it from runner --- lib/coverage.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/coverage.js b/lib/coverage.js index 1c844f1..7e81135 100644 --- a/lib/coverage.js +++ b/lib/coverage.js @@ -4,7 +4,8 @@ var path = require('path'), var istanbul, collector, options = { - dir: 'coverage' + dir: 'coverage', + reporters: ['lcov', 'json'] }; try { @@ -38,7 +39,11 @@ exports.report = function() { if (collector) { Report = istanbul.Report; - reports = [Report.create('lcov', options), Report.create('json', options)]; + + reports = options.reporters.map(function (report) { + return Report.create(report, options); + }); + reports.forEach(function(rep) { rep.writeReport(collector, true); }); From d16a2c267b09872dfbce06bc27c21a998859076f Mon Sep 17 00:00:00 2001 From: Jakub Olek Date: Tue, 6 Jan 2015 20:33:48 +0100 Subject: [PATCH 11/28] Update readme.md --- readme.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 3014fd2..d27c742 100644 --- a/readme.md +++ b/readme.md @@ -244,4 +244,10 @@ Some tests examples ### Coverage -Code coverage via Istanbul. To utilize, install `istanbul` and set option `coverage: true` or give a path where to store report `coverage: {dir: "coverage/path"}` or pass `--cov` parameter in the shell. Coverage calculations based on code and tests passed to `node-qunit`. +Code coverage via Istanbul. + +To utilize, install `istanbul` and set option `coverage: true` or give a path where to store report `coverage: {dir: "coverage/path"}` or pass `--cov` parameter in the shell. + +To specify the format of coverage report pass reporters array to the coverage options: `coverage: {reporters: ['lcov', 'json']}` (default) + +Coverage calculations based on code and tests passed to `node-qunit`. From 4fb32b6da7841475a28b6f32e5f06c6e228f8376 Mon Sep 17 00:00:00 2001 From: nikolas Date: Thu, 9 Apr 2015 01:28:25 -0400 Subject: [PATCH 12/28] Test on nodejs 0.12 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 3c6757d..f33b951 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,3 +2,4 @@ language: node_js node_js: - '0.10' - '0.11' + - '0.12' From 49c1ca832fe6cd65dc46e83ba4d73a249a845cf3 Mon Sep 17 00:00:00 2001 From: Oleg Slobodskoi Date: Mon, 13 Apr 2015 12:53:03 +0200 Subject: [PATCH 13/28] add node < 0.13 support, bump the version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 436325e..bbf97bb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "qunit", "description": "QUnit testing framework for nodejs", - "version": "0.7.5", + "version": "0.7.6", "author": "Oleg Slobodskoi ", "contributors": [ { @@ -30,7 +30,7 @@ "qunit": "./bin/cli.js" }, "engines": { - "node": ">=0.6.0 < 0.12.0" + "node": ">=0.6.0 < 0.13.0" }, "scripts": { "test": "node --harmony ./test/testrunner.js" From 8d855830e287535068277b688bd2916af2971526 Mon Sep 17 00:00:00 2001 From: Edgar Hipp Date: Sat, 26 Sep 2015 12:00:36 +0200 Subject: [PATCH 14/28] Add node v4 support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bbf97bb..b8f48ce 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "qunit": "./bin/cli.js" }, "engines": { - "node": ">=0.6.0 < 0.13.0" + "node": ">=0.6.0 < 5.0" }, "scripts": { "test": "node --harmony ./test/testrunner.js" From f6981b3bebc76bf9a983aa2318e3cfa7fcb781e6 Mon Sep 17 00:00:00 2001 From: Oleg Slobodskoi Date: Sat, 26 Sep 2015 13:26:16 +0200 Subject: [PATCH 15/28] bump version, add latest node to travis --- .travis.yml | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f33b951..15275e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,4 @@ node_js: - '0.10' - '0.11' - '0.12' + - '4.1.1' diff --git a/package.json b/package.json index b8f48ce..15ac5c8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "qunit", "description": "QUnit testing framework for nodejs", - "version": "0.7.6", + "version": "0.7.7", "author": "Oleg Slobodskoi ", "contributors": [ { From 60c869f5b1f03a4b570da358ca82566bb3dc4ba9 Mon Sep 17 00:00:00 2001 From: Bruno Jouhier Date: Mon, 1 Feb 2016 18:01:21 +0100 Subject: [PATCH 16/28] allow coverage instrumentation of multiple files --- lib/coverage.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/coverage.js b/lib/coverage.js index 7e81135..28cc635 100644 --- a/lib/coverage.js +++ b/lib/coverage.js @@ -54,7 +54,9 @@ exports.instrument = function(options) { var matcher, instrumenter; matcher = function (file) { - return file === options.code.path; + if (typeof options.coverage === 'string') return file.indexOf(options.coverage) === 0; + else if (options.coverage instanceof RegExp) return options.coverage.test(file); + else return file === options.code.path; } instrumenter = new istanbul.Instrumenter(); istanbul.hook.hookRequire(matcher, instrumenter.instrumentSync.bind(instrumenter)); From b53a7eeaa21cdbc4964ca93c4d551257f79fff93 Mon Sep 17 00:00:00 2001 From: Bruno Jouhier Date: Tue, 2 Feb 2016 11:42:31 +0100 Subject: [PATCH 17/28] use options.coverage.files + allow array of strings or regexps --- lib/coverage.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/coverage.js b/lib/coverage.js index 28cc635..3858960 100644 --- a/lib/coverage.js +++ b/lib/coverage.js @@ -54,9 +54,17 @@ exports.instrument = function(options) { var matcher, instrumenter; matcher = function (file) { - if (typeof options.coverage === 'string') return file.indexOf(options.coverage) === 0; - else if (options.coverage instanceof RegExp) return options.coverage.test(file); - else return file === options.code.path; + var files = options.coverage.files; + if (files) { + files = Array.isArray(files) ? files : [files]; + return files.some(function(f) { + if (typeof f === 'string') return file.indexOf(f) === 0; + else if (f instanceof RegExp) return f.test(file); + else throw new Error("invalid entry in options.coverage.files: " + typeof f); + }); + } else { + return file === options.code.path; + } } instrumenter = new istanbul.Instrumenter(); istanbul.hook.hookRequire(matcher, instrumenter.instrumentSync.bind(instrumenter)); From 19102354523db5ea2c9efa34961dafcefbd1856d Mon Sep 17 00:00:00 2001 From: Oleg Slobodskoi Date: Tue, 2 Feb 2016 13:14:38 +0100 Subject: [PATCH 18/28] bump the version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 15ac5c8..631fcec 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "qunit", "description": "QUnit testing framework for nodejs", - "version": "0.7.7", + "version": "0.8.0", "author": "Oleg Slobodskoi ", "contributors": [ { From 164a61761a81169fc66ff8b7939cb7859b50eb3c Mon Sep 17 00:00:00 2001 From: Bruno Jouhier Date: Tue, 2 Feb 2016 22:04:37 +0000 Subject: [PATCH 19/28] removed buggy regexp option from instrument filter --- lib/coverage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/coverage.js b/lib/coverage.js index 3858960..58ffd5e 100644 --- a/lib/coverage.js +++ b/lib/coverage.js @@ -59,7 +59,6 @@ exports.instrument = function(options) { files = Array.isArray(files) ? files : [files]; return files.some(function(f) { if (typeof f === 'string') return file.indexOf(f) === 0; - else if (f instanceof RegExp) return f.test(file); else throw new Error("invalid entry in options.coverage.files: " + typeof f); }); } else { From afc4beca06e26a18af612a7a50d87357882ad505 Mon Sep 17 00:00:00 2001 From: Bruno Jouhier Date: Tue, 2 Feb 2016 22:25:37 +0000 Subject: [PATCH 20/28] unit test for instrumentation of multiple files --- test/fixtures/coverage-multiple-code.js | 1 + test/testrunner.js | 34 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 test/fixtures/coverage-multiple-code.js diff --git a/test/fixtures/coverage-multiple-code.js b/test/fixtures/coverage-multiple-code.js new file mode 100644 index 0000000..d21a63b --- /dev/null +++ b/test/fixtures/coverage-multiple-code.js @@ -0,0 +1 @@ +module.exports = require('./coverage-code') \ No newline at end of file diff --git a/test/testrunner.js b/test/testrunner.js index fdb3eb0..5518d8b 100644 --- a/test/testrunner.js +++ b/test/testrunner.js @@ -191,6 +191,40 @@ chain.add('coverage', function() { }); }); +chain.add('coverage-multiple', function() { + tr.options.coverage = true; + tr.run({ + code: fixtures + '/coverage-multiple-code.js', + tests: fixtures + '/coverage-test.js', + coverage: { + files: [ + fixtures + '/coverage-multiple-code.js', + fixtures + '/coverage-code.js' + ], + }, + }, function(err, res) { + var stat = { + files: 1, + tests: 2, + assertions: 3, + failed: 0, + passed: 3, + coverage: { + files: 1, + statements: { covered: 7, total: 8 }, + branches: { covered: 0, total: 0 }, + functions: { covered: 3, total: 4 }, + lines: { covered: 7, total: 8 } + } + }; + delete res.runtime; + a.equal(err, null, 'no errors'); + a.deepEqual(stat, res, 'coverage multiple code testing works'); + tr.options.coverage = false; + chain.next(); + }); +}); + if (generators.support) { chain.add('generators', function() { tr.run({ From 6ba2337a099a9c9997fb4b9045dc2f1b9e3fa4a8 Mon Sep 17 00:00:00 2001 From: Oleg Slobodskoi Date: Wed, 3 Feb 2016 02:31:44 +0100 Subject: [PATCH 21/28] bump the version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 631fcec..287aea8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "qunit", "description": "QUnit testing framework for nodejs", - "version": "0.8.0", + "version": "0.9.0", "author": "Oleg Slobodskoi ", "contributors": [ { From 265595392c25854938e6ce0db07a182508a203c5 Mon Sep 17 00:00:00 2001 From: Andrew Brampton Date: Sat, 26 Mar 2016 08:48:52 -0700 Subject: [PATCH 22/28] Added parsing of the maxBlockDuration config from the command line. --- bin/cli.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/cli.js b/bin/cli.js index dade70a..eb25a12 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -20,6 +20,7 @@ help = '' + '\n -d, --deps dependency paths - files required before code (space separated)' + '\n -l, --log logging options, json have to be used' + '\n --cov create tests coverage report' + + '\n --timeout max block duration (in ms)' + '\n -h, --help show this help' + '\n -v, --version show module version' + '\n'; @@ -84,6 +85,9 @@ for (var key in args) { case '--paths': o.paths = args[key]; break; + case '--timeout': + o.maxBlockDuration = args[key]; + break; case '-v': case '--version': util.print( From f199b966d4e9121289a5afc760d38bfeaa27fdae Mon Sep 17 00:00:00 2001 From: Oleg Slobodskoi Date: Wed, 30 Mar 2016 13:41:52 +0200 Subject: [PATCH 23/28] release 0.9.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 287aea8..72ce4a9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "qunit", "description": "QUnit testing framework for nodejs", - "version": "0.9.0", + "version": "0.9.1", "author": "Oleg Slobodskoi ", "contributors": [ { From 5f34c2ba8a1dad2e62e020340c7176cdf61711ee Mon Sep 17 00:00:00 2001 From: Yomi Osamiluyi Date: Thu, 2 Jun 2016 13:39:27 -0400 Subject: [PATCH 24/28] Bumped `qunitjs` version to `1.23.1` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 72ce4a9..48b0092 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "argsparser": "^0.0.6", "cli-table": "^0.3.0", "co": "^3.0.6", - "qunitjs": "1.10.0", + "qunitjs": "1.23.1", "tracejs": "^0.1.8", "underscore": "^1.6.0" }, From 114f4738c60a140743e8c19e73b61b194309c7f6 Mon Sep 17 00:00:00 2001 From: Yomi Osamiluyi Date: Thu, 2 Jun 2016 13:42:23 -0400 Subject: [PATCH 25/28] rewrote all tests to accept the `assert` variable in callback and use the `assert.async()` method instead of `start()` and `stop()` --- test/fixtures/async-test.js | 26 ++++++++++++------------ test/fixtures/child-tests-global.js | 6 +++--- test/fixtures/child-tests-namespace.js | 8 ++++---- test/fixtures/coverage-test.js | 16 +++++++-------- test/fixtures/generators-test.js | 4 ++-- test/fixtures/infinite-loop-test.js | 4 ++-- test/fixtures/testrunner-tests.js | 28 +++++++++++++------------- 7 files changed, 46 insertions(+), 46 deletions(-) diff --git a/test/fixtures/async-test.js b/test/fixtures/async-test.js index 92843fa..7bf59d8 100644 --- a/test/fixtures/async-test.js +++ b/test/fixtures/async-test.js @@ -1,27 +1,27 @@ -test('1', 1, function (){ - ok(true, "tests intermixing sync and async tests #1"); +test('1', 1, function (assert){ + assert.ok(true, "tests intermixing sync and async tests #1"); }); -test('a', 2, function(){ - stop(); +test('a', 2, function(assert){ + var done = assert.async(); setTimeout(function() { - ok(true, 'test a1'); - ok(true, 'test a2'); - start(); + assert.ok(true, 'test a1'); + assert.ok(true, 'test a2'); + done(); }, 10000); }); test('2', 1, function (){ - ok(true, "tests intermixing sync and async tests #2"); + assert.ok(true, "tests intermixing sync and async tests #2"); }); -test('b', 2, function(){ - stop(); +test('b', 2, function(assert){ + var done = assert.async(); setTimeout(function() { - ok(true, 'test b1'); - ok(true, 'test b2'); - start(); + assert.ok(true, 'test b1'); + assert.ok(true, 'test b2'); + done(); }, 10); }); diff --git a/test/fixtures/child-tests-global.js b/test/fixtures/child-tests-global.js index 7fbc84d..62996d4 100644 --- a/test/fixtures/child-tests-global.js +++ b/test/fixtures/child-tests-global.js @@ -1,4 +1,4 @@ -test("Dependency file required as global", function() { - equal(typeof whereFrom, "function"); - equal(whereFrom(), "I was required as global"); +test("Dependency file required as global", function(assert) { + assert.equal(typeof whereFrom, "function"); + assert.equal(whereFrom(), "I was required as global"); }); diff --git a/test/fixtures/child-tests-namespace.js b/test/fixtures/child-tests-namespace.js index 9857ed1..d3ba068 100644 --- a/test/fixtures/child-tests-namespace.js +++ b/test/fixtures/child-tests-namespace.js @@ -1,5 +1,5 @@ -test("Dependency file required as a namespace object", function() { - strictEqual(typeof testns != "undefined", true); - equal(typeof testns.whereFrom, "function", "right method attached to right object"); - equal(testns.whereFrom(), "I was required as a namespace object"); +test("Dependency file required as a namespace object", function(assert) { + assert.strictEqual(typeof testns != "undefined", true); + assert.equal(typeof testns.whereFrom, "function", "right method attached to right object"); + assert.equal(testns.whereFrom(), "I was required as a namespace object"); }); diff --git a/test/fixtures/coverage-test.js b/test/fixtures/coverage-test.js index 52c67da..b94c2f6 100644 --- a/test/fixtures/coverage-test.js +++ b/test/fixtures/coverage-test.js @@ -1,15 +1,15 @@ -test('myMethod test', function() { - equal(myMethod(), 123, 'myMethod returns right result'); +test('myMethod test', function(assert) { + assert.equal(myMethod(), 123, 'myMethod returns right result'); }); -test('myAsyncMethod test', function() { - ok(true, 'myAsyncMethod started'); +test('myAsyncMethod test', function(assert) { + assert.ok(true, 'myAsyncMethod started'); - stop(); - expect(2); + var done = assert.async(); + assert.expect(2); myAsyncMethod(function(data) { - equal(data, 123, 'myAsyncMethod returns right result'); - start(); + assert.equal(data, 123, 'myAsyncMethod returns right result'); + done(); }); }); diff --git a/test/fixtures/generators-test.js b/test/fixtures/generators-test.js index 3d96e0a..1709d89 100644 --- a/test/fixtures/generators-test.js +++ b/test/fixtures/generators-test.js @@ -1,4 +1,4 @@ -test('generators', function* () { +test('generators', function* (assert) { var data = yield thunk(); - deepEqual(data, {a: 1}, 'woks'); + assert.deepEqual(data, {a: 1}, 'woks'); }); diff --git a/test/fixtures/infinite-loop-test.js b/test/fixtures/infinite-loop-test.js index a43d419..bcd690a 100644 --- a/test/fixtures/infinite-loop-test.js +++ b/test/fixtures/infinite-loop-test.js @@ -1,3 +1,3 @@ -test('infinite loop', function() { - ok(true) +test('infinite loop', function(assert) { + assert.ok(true) }) diff --git a/test/fixtures/testrunner-tests.js b/test/fixtures/testrunner-tests.js index b5b3fc3..d4b1967 100644 --- a/test/fixtures/testrunner-tests.js +++ b/test/fixtures/testrunner-tests.js @@ -1,29 +1,29 @@ -test('myMethod test', function() { - equal(myMethod(), 123, 'myMethod returns right result'); - equal(myMethod(), 321, 'this should trigger an error'); +test('myMethod test', function(assert) { + assert.equal(myMethod(), 123, 'myMethod returns right result'); + assert.equal(myMethod(), 321, 'this should trigger an error'); }); -test('myAsyncMethod test', function() { - ok(true, 'myAsyncMethod started'); +test('myAsyncMethod test', function(assert) { + var done = assert.async(); + assert.expect(3); - stop(); - expect(3); + assert.ok(true, 'myAsyncMethod started'); myAsyncMethod(function(data) { - equal(data, 123, 'myAsyncMethod returns right result'); - equal(data, 321, 'this should trigger an error'); - start(); + assert.equal(data, 123, 'myAsyncMethod returns right result'); + assert.equal(data, 321, 'this should trigger an error'); + done(); }); }); -test('circular reference', function() { - equal(global, global, 'test global'); +test('circular reference', function(assert) { + assert.equal(global, global, 'test global'); }); -test('use original Date', function() { +test('use original Date', function(assert) { var timekeeper = require('timekeeper'); timekeeper.travel(Date.now() - 1000000); - ok(true, 'date modified'); + assert.ok(true, 'date modified'); }); From ec18f72dec6c7e21337c0920e6fea5fcf98c691f Mon Sep 17 00:00:00 2001 From: Yomi Osamiluyi Date: Thu, 2 Jun 2016 13:43:59 -0400 Subject: [PATCH 26/28] Changed `test()` invocations to `QUnit.test()` --- test/fixtures/async-test.js | 8 ++++---- test/fixtures/coverage-test.js | 4 ++-- test/fixtures/generators-test.js | 2 +- test/fixtures/infinite-loop-test.js | 2 +- test/fixtures/testrunner-tests.js | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/fixtures/async-test.js b/test/fixtures/async-test.js index 7bf59d8..5733e2f 100644 --- a/test/fixtures/async-test.js +++ b/test/fixtures/async-test.js @@ -1,8 +1,8 @@ -test('1', 1, function (assert){ +QUnit.test('1', 1, function (assert){ assert.ok(true, "tests intermixing sync and async tests #1"); }); -test('a', 2, function(assert){ +QUnit.test('a', 2, function(assert){ var done = assert.async(); setTimeout(function() { @@ -12,11 +12,11 @@ test('a', 2, function(assert){ }, 10000); }); -test('2', 1, function (){ +QUnit.test('2', 1, function (){ assert.ok(true, "tests intermixing sync and async tests #2"); }); -test('b', 2, function(assert){ +QUnit.test('b', 2, function(assert){ var done = assert.async(); setTimeout(function() { diff --git a/test/fixtures/coverage-test.js b/test/fixtures/coverage-test.js index b94c2f6..36c72e6 100644 --- a/test/fixtures/coverage-test.js +++ b/test/fixtures/coverage-test.js @@ -1,8 +1,8 @@ -test('myMethod test', function(assert) { +QUnit.test('myMethod test', function(assert) { assert.equal(myMethod(), 123, 'myMethod returns right result'); }); -test('myAsyncMethod test', function(assert) { +QUnit.test('myAsyncMethod test', function(assert) { assert.ok(true, 'myAsyncMethod started'); var done = assert.async(); diff --git a/test/fixtures/generators-test.js b/test/fixtures/generators-test.js index 1709d89..20cd6e3 100644 --- a/test/fixtures/generators-test.js +++ b/test/fixtures/generators-test.js @@ -1,4 +1,4 @@ -test('generators', function* (assert) { +QUnit.test('generators', function* (assert) { var data = yield thunk(); assert.deepEqual(data, {a: 1}, 'woks'); }); diff --git a/test/fixtures/infinite-loop-test.js b/test/fixtures/infinite-loop-test.js index bcd690a..f9df9b7 100644 --- a/test/fixtures/infinite-loop-test.js +++ b/test/fixtures/infinite-loop-test.js @@ -1,3 +1,3 @@ -test('infinite loop', function(assert) { +QUnit.test('infinite loop', function(assert) { assert.ok(true) }) diff --git a/test/fixtures/testrunner-tests.js b/test/fixtures/testrunner-tests.js index d4b1967..cd21d2d 100644 --- a/test/fixtures/testrunner-tests.js +++ b/test/fixtures/testrunner-tests.js @@ -1,9 +1,9 @@ -test('myMethod test', function(assert) { +QUnit.test('myMethod test', function(assert) { assert.equal(myMethod(), 123, 'myMethod returns right result'); assert.equal(myMethod(), 321, 'this should trigger an error'); }); -test('myAsyncMethod test', function(assert) { +QUnit.test('myAsyncMethod test', function(assert) { var done = assert.async(); assert.expect(3); @@ -16,11 +16,11 @@ test('myAsyncMethod test', function(assert) { }); }); -test('circular reference', function(assert) { +QUnit.test('circular reference', function(assert) { assert.equal(global, global, 'test global'); }); -test('use original Date', function(assert) { +QUnit.test('use original Date', function(assert) { var timekeeper = require('timekeeper'); timekeeper.travel(Date.now() - 1000000); From 2d8ce66e5e4d22e5cdbd8c343e823fab9dcd1501 Mon Sep 17 00:00:00 2001 From: Yomi Osamiluyi Date: Thu, 2 Jun 2016 17:12:23 -0400 Subject: [PATCH 27/28] Fixed bugs due to upgrade in `child.js` --- lib/child.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/child.js b/lib/child.js index a4a3411..aa20d1b 100644 --- a/lib/child.js +++ b/lib/child.js @@ -27,7 +27,6 @@ setInterval(function() { process.on('uncaughtException', function(err) { if (QUnit.config.current) { QUnit.ok(false, 'Test threw unexpected exception: ' + err.message); - QUnit.start(); } process.send({ event: 'uncaughtException', @@ -38,9 +37,6 @@ process.on('uncaughtException', function(err) { }); }); -QUnit.config.autorun = false; -QUnit.config.autostart = false; - // make qunit api global, like it is in the browser _.extend(global, QUnit); @@ -62,8 +58,6 @@ function _require(res, addToGlobal) { _.extend(global, exports); } } - - QUnit.start(); } /** @@ -83,7 +77,7 @@ QUnit.testStart(function(test) { * @param {Object} data */ QUnit.log(function(data) { - data.test = this.config.current.testName; + data.test = QUnit.config.current.testName; data.module = currentModule; process.send({ event: 'assertionDone', @@ -177,3 +171,4 @@ options.tests.forEach(function(test) { _require(test, false); }); +QUnit.load(); \ No newline at end of file From 841531a7650bb75fd6b4f2effcc6eb0e301f87e8 Mon Sep 17 00:00:00 2001 From: Yomi Osamiluyi Date: Fri, 3 Jun 2016 12:43:41 -0400 Subject: [PATCH 28/28] reverted back to using `test()` already in global instead of `QUnit.test()` --- test/fixtures/async-test.js | 8 ++++---- test/fixtures/coverage-test.js | 4 ++-- test/fixtures/generators-test.js | 2 +- test/fixtures/infinite-loop-test.js | 2 +- test/fixtures/testrunner-tests.js | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/fixtures/async-test.js b/test/fixtures/async-test.js index 5733e2f..7bf59d8 100644 --- a/test/fixtures/async-test.js +++ b/test/fixtures/async-test.js @@ -1,8 +1,8 @@ -QUnit.test('1', 1, function (assert){ +test('1', 1, function (assert){ assert.ok(true, "tests intermixing sync and async tests #1"); }); -QUnit.test('a', 2, function(assert){ +test('a', 2, function(assert){ var done = assert.async(); setTimeout(function() { @@ -12,11 +12,11 @@ QUnit.test('a', 2, function(assert){ }, 10000); }); -QUnit.test('2', 1, function (){ +test('2', 1, function (){ assert.ok(true, "tests intermixing sync and async tests #2"); }); -QUnit.test('b', 2, function(assert){ +test('b', 2, function(assert){ var done = assert.async(); setTimeout(function() { diff --git a/test/fixtures/coverage-test.js b/test/fixtures/coverage-test.js index 36c72e6..b94c2f6 100644 --- a/test/fixtures/coverage-test.js +++ b/test/fixtures/coverage-test.js @@ -1,8 +1,8 @@ -QUnit.test('myMethod test', function(assert) { +test('myMethod test', function(assert) { assert.equal(myMethod(), 123, 'myMethod returns right result'); }); -QUnit.test('myAsyncMethod test', function(assert) { +test('myAsyncMethod test', function(assert) { assert.ok(true, 'myAsyncMethod started'); var done = assert.async(); diff --git a/test/fixtures/generators-test.js b/test/fixtures/generators-test.js index 20cd6e3..1709d89 100644 --- a/test/fixtures/generators-test.js +++ b/test/fixtures/generators-test.js @@ -1,4 +1,4 @@ -QUnit.test('generators', function* (assert) { +test('generators', function* (assert) { var data = yield thunk(); assert.deepEqual(data, {a: 1}, 'woks'); }); diff --git a/test/fixtures/infinite-loop-test.js b/test/fixtures/infinite-loop-test.js index f9df9b7..bcd690a 100644 --- a/test/fixtures/infinite-loop-test.js +++ b/test/fixtures/infinite-loop-test.js @@ -1,3 +1,3 @@ -QUnit.test('infinite loop', function(assert) { +test('infinite loop', function(assert) { assert.ok(true) }) diff --git a/test/fixtures/testrunner-tests.js b/test/fixtures/testrunner-tests.js index cd21d2d..d4b1967 100644 --- a/test/fixtures/testrunner-tests.js +++ b/test/fixtures/testrunner-tests.js @@ -1,9 +1,9 @@ -QUnit.test('myMethod test', function(assert) { +test('myMethod test', function(assert) { assert.equal(myMethod(), 123, 'myMethod returns right result'); assert.equal(myMethod(), 321, 'this should trigger an error'); }); -QUnit.test('myAsyncMethod test', function(assert) { +test('myAsyncMethod test', function(assert) { var done = assert.async(); assert.expect(3); @@ -16,11 +16,11 @@ QUnit.test('myAsyncMethod test', function(assert) { }); }); -QUnit.test('circular reference', function(assert) { +test('circular reference', function(assert) { assert.equal(global, global, 'test global'); }); -QUnit.test('use original Date', function(assert) { +test('use original Date', function(assert) { var timekeeper = require('timekeeper'); timekeeper.travel(Date.now() - 1000000);