From e144ede4ff5fa8f0f65be8b394398de03d52b034 Mon Sep 17 00:00:00 2001 From: Caolan McMahon Date: Sat, 18 Sep 2010 11:13:59 +0100 Subject: [PATCH] added a Makefile for running tests and installing or uninstalling the command-line tool --- Makefile | 14 ++++++++++++++ README.md | 24 ++++++++++++++++++++++-- bin/nodeunit | 11 +++-------- package.json | 2 +- test.js | 6 ------ 5 files changed, 40 insertions(+), 17 deletions(-) create mode 100644 Makefile delete mode 100755 test.js diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..3d4de4d66 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +PREFIX ?= /usr/local + +test: + ./bin/nodeunit test + +install: + cp -r ./ $(PREFIX)/lib/nodeunit + ln -s $(PREFIX)/lib/nodeunit/bin/nodeunit $(PREFIX)/bin/nodeunit + +uninstall: + rm -rf $(PREFIX)/lib/nodeunit + rm -f $(PREFIX)/bin/nodeunit + +.PHONY: test install uninstall diff --git a/README.md b/README.md index eee8a030c..a651e5a79 100644 --- a/README.md +++ b/README.md @@ -248,6 +248,26 @@ However, the module test-base.js first does some basic tests using the assert module to ensure that test functions are actually run, and a basic level of nodeunit functionality is available. -To run the nodeunit tests do: node test.js +To run the nodeunit tests do: + + make test -__Note:__ The tests hang when using node v0.2.0, upgrading to v0.2.1 fixes this. +__Note:__ There was a bug in node v0.2.0 causing the tests to hang, upgrading +to v0.2.1 fixes this. + + +Installing the command-line tool +-------------------------------- + +If you have installed nodeunit via npm, the command line tool should already be +available. Otherwise you can do: + + make install + +to install nodeunit to /usr/local. You can then use nodeunit on the command-line: + + nodeunit PATH + +To uninstall nodeunit, do: + + make uninstall diff --git a/bin/nodeunit b/bin/nodeunit index 16963de0e..e38c16d48 100755 --- a/bin/nodeunit +++ b/bin/nodeunit @@ -1,8 +1,3 @@ -#!/usr/bin/env node - -var path = require('path'); -var fs = require('fs'); -var lib = path.join(__dirname, '../lib'); - -var testrunner = require(lib + '/testrunner.js'); -testrunner.run(process.argv.slice(2)); +#!/bin/sh +REALPATH=`readlink -f $0` +node `dirname $REALPATH`/../lib/testrunner.js $@ diff --git a/package.json b/package.json index b31e4e65c..e7737d93c 100644 --- a/package.json +++ b/package.json @@ -13,5 +13,5 @@ , "url" : "http://github.com/caolan/nodeunit/raw/master/LICENSE" } ] - , "bin" : { "nodeunit" : "./bin/nodeunit" } + , "bin" : { "nodeunit" : "./lib/testrunner" } } diff --git a/test.js b/test.js deleted file mode 100755 index e4ec48227..000000000 --- a/test.js +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env node - -var testrunner = require('./lib/nodeunit').testrunner; - -process.chdir(__dirname); -testrunner.run(['test']);