Skip to content

Commit

Permalink
test/usage.js no longer hangs
Browse files Browse the repository at this point in the history
  • Loading branch information
jfhbrook committed Mar 6, 2012
1 parent 015daa6 commit 88e5d32
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ test('usageFail', function (t) {
t.end();
});


test('usagePass', function (t) {
var r = checkUsage(function () {
return optimist('-x 10 -y 20'.split(' '))
Expand Down Expand Up @@ -237,9 +238,13 @@ test('rebase', function (t) {
});

function checkUsage (f) {
var _process = process;
process = Hash.copy(process);

var exit = false;

process._exit = process.exit;
process._env = process.env;
process._argv = process.argv;

process.exit = function (t) { exit = true };
process.env = Hash.merge(process.env, { _ : 'node' });
process.argv = [ './usage' ];
Expand All @@ -254,7 +259,10 @@ function checkUsage (f) {

var result = f();

process = _process;
process.exit = process._exit;
process.env = process._env;
process.argv = process._argv;

console.error = console._error;
console.log = console._log;

Expand Down

0 comments on commit 88e5d32

Please sign in to comment.