Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

`nodetest` executable tests runner

  • Loading branch information...
commit 3ef3d51eac1c9e2a75a15903d44e53c97665b1d8 1 parent bfb03fe
@joelplane joelplane authored
View
2  README.md
@@ -31,7 +31,7 @@ Example
node examples/basicTest.js
-OR *coming soon*:
+OR
testnode testsDirectory
View
29 bin/testnode.js
@@ -0,0 +1,29 @@
+#!/usr/bin/env node
+/*
+ * Suite runner.
+ *
+ * Run each test file in a directory one by one.
+ *
+ * To be called like:
+ *
+ * testnode TESTS_DIRECTORY
+ *
+ * The first argument must be a directory. It only looks at the first
+ * argument - ie. it does not support shell globbing.
+ *
+ */
+var sys = require('sys');
+var glob = require('glob');
+var runner = require('../runner');
+var dirArg = process.ARGV[2];
+var dir;
+
+if (!dirArg) {
+ sys.puts("Usage: testnode TESTS_DIRECTORY");
+ process.exit(0);
+}
+
+dir = (dirArg.charAt(dirArg.length-1)=='/') ? (dirArg + '**') : (dirArg + '/**');
+glob.glob(dir + '/**', null, function(error, files){
+ runner.run(files);
+});
View
5 package.json
@@ -1,7 +1,7 @@
{
"name": "testnode",
"description": "Testing library for Node",
- "version": "0.1.0",
+ "version": "0.1.1",
"dependencies" : {
"glob": "",
"ansi-color": ""
@@ -14,6 +14,9 @@
"directories": {
"lib": "."
},
+ "bin": {
+ "testnode": "bin/testnode.js"
+ },
"engines": {
"node": "*"
}
View
47 runner.js
@@ -1,42 +1,11 @@
-/*
- * Suite runner.
- * To be called like
- * node runner.js TESTS_DIRECTORY
- *
- * This currently very basic, and largely inadequate.
- * It simply runs each test file one by one.
- * It will need to:
- * + agregate contexts together when they are spread over multiple files.
- * + report on the results of running the test files
- * - including exiting with non-zero whenever any test fails
- */
var test = require('./testnode')();
var sys = require('sys');
-var glob = require('glob');
-var control = new (require('events').EventEmitter);
test.onFailureExitNonZero();
-test.suiteMode();
-
-var dir = process.ARGV[2];
-if (!dir) {
- sys.puts("Usage: node runner.js TESTS_DIRECTORY");
- process.exit(0);
-}
-var files;
-
-var getFiles = function() {
- dir = (dir.charAt(dir.length-1)=='/') ? (dir + '**') : (dir + '/**');
- glob.glob(dir + '/**', null, function(error, matches){
- files = matches;
- control.emit('getFilesDone');
- });
-};
-
-control.on('getFilesDone', function(){
- files.forEach(function(file){
- sys.puts('Loading file ' + file);
- require('./' + file);
- });
-});
-
-getFiles();
+module.exports = {
+ run: function(files) {
+ files.forEach(function(file){
+ sys.puts('Loading file ' + file);
+ require('./' + file);
+ });
+ }
+};
View
5 testnode.js
@@ -32,11 +32,6 @@ module.exports = (function(){
var Context = require('./context')(Test);
var main = new EventEmitter();
- main._suiteMode = false;
- main.suiteMode = function() {
- main._suiteMode = true;
- };
-
/* Relay events emitted by Test and Context instances to the main object */
Test.on('new', function(t){
events.relayEvents(t, main, ['assertionPassed', 'assertionFailed', 'testFlunk', 'testStarted', 'testTimeout', 'testDone']);
Please sign in to comment.
Something went wrong with that request. Please try again.