Skip to content

Commit

Permalink
fixed testing for lower versions of node
Browse files Browse the repository at this point in the history
  • Loading branch information
richardgarnier committed Jun 4, 2016
1 parent 0841679 commit e63742a
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions test/cli.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
var test = require('tap').test
var execSync = require('child_process').execSync
var exec = require('child_process').exec

test('the command line using pipes or arguments produces the same output', function (t) {
var exec = 'node ./bin/semver ';
[[exec+'-i 1.0.0', 'echo 1.0.0 | '+exec+'-i'],
[exec+'-i major 1.0.0', 'echo 1.0.0 | '+exec+'-i major'],
[exec+'-i prerelease 1.0.0', 'echo 1.0.0 | '+exec+'-i prerelease'],
[exec+'-i preminor 1.0.0', 'echo 1.0.0 | '+exec+'-i preminor'],
[exec+'-i prepatch --preid alpha 1.0.0', 'echo 1.0.0 | '+exec+'-i prepatch --preid alpha'],
[exec+'-r \\>1.0.0 0.8.0 1.1.1', 'echo 0.8.0 1.1.1 | '+exec+'-r \\>1.0.0']
t.plan(6);
var bin = 'node ./bin/semver ';
[[bin+'-i 1.0.0', 'echo 1.0.0 | '+bin+'-i'],
[bin+'-i major 1.0.0', 'echo 1.0.0 | '+bin+'-i major'],
[bin+'-i prerelease 1.0.0', 'echo 1.0.0 | '+bin+'-i prerelease'],
[bin+'-i preminor 1.0.0', 'echo 1.0.0 | '+bin+'-i preminor'],
[bin+'-i prepatch --preid alpha 1.0.0', 'echo 1.0.0 | '+bin+'-i prepatch --preid alpha'],
[bin+'-r \\>1.0.0 0.8.0 1.1.1', 'echo 0.8.0 1.1.1 | '+bin+'-r \\>1.0.0']
].forEach(function(tab) {
var resCli = execSync(tab[0]);
var resPipe = execSync(tab[1]);
t.assert(resCli.equals(resPipe));
exec(tab[0], function(error, stdout, stderr) {
var resCli = stdout + stderr;
exec(tab[1], function(error, stdout, stderr) {
var resPipe = stdout + stderr;
t.assert(resCli === resPipe);
});
});
});
t.end()
})

0 comments on commit e63742a

Please sign in to comment.