Skip to content

Commit

Permalink
windows compatible test
Browse files Browse the repository at this point in the history
make the test compatible with windows where grep is not exists
  • Loading branch information
speier committed Nov 6, 2012
1 parent e4e955a commit 9b5f06c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/spawn-command-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ var path = require('path'),
assertCalled = require('assert-called'),
spawnCommand = require('../');

var child = spawnCommand('grep commit < ' + path.join(__dirname, 'fixtures', 'commit')),
var win32 = (process.platform === 'win32'),
newln = win32 ? '\r\n' : '\n',
grep = win32 ? 'findstr' : 'grep',
child = spawnCommand(grep + ' commit < ' + path.join(__dirname, 'fixtures', 'commit')),
stderr = '',
stdout = '',
exited = false;
Expand All @@ -18,6 +21,6 @@ child.stderr.on('data', function (chunk) {

child.on('exit', assertCalled(function (exitCode) {
assert.equal(exitCode, 0);
assert.equal(stdout, 'commit 26b11915b1c16440468a4b5f4b07d2409b98c68c\n');
assert.equal(stdout, 'commit 26b11915b1c16440468a4b5f4b07d2409b98c68c' + newln);
assert.equal(stderr, '');
}));

0 comments on commit 9b5f06c

Please sign in to comment.