Skip to content

Commit

Permalink
Adds tests for passing environment variables to spawned processes cor…
Browse files Browse the repository at this point in the history
…rectly
  • Loading branch information
cspotcode committed Dec 11, 2016
1 parent 90a7bc5 commit a284ab9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/fixtures/echoEnv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo "$FOO""$BAR"
2 changes: 2 additions & 0 deletions test/fixtures/echoEnv.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
echo %FOO%%BAR%
34 changes: 34 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,40 @@ extension\');', { mode: parseInt('0777', 8) });
});
});

describe('should preserve environment variables', function () {
before(function () {
process.env.FOO = 'foovalue';
});

it('when env dictionary is omitted', function (next) {
buffered(method, __dirname + '/fixtures/echoEnv', function (err, data, code) {
expect(err).to.not.be.ok();
expect(code).to.be(0);
expect(data.trim()).to.equal('foovalue');

next();
});
});

it('when env dictionary is passed', function (next) {
buffered(method, __dirname + '/fixtures/echoEnv', {
env: {
BAR: 'barvalue',
},
}, function (err, data, code) {
expect(err).to.not.be.ok();
expect(code).to.be(0);
expect(data.trim()).to.equal('barvalue');

next();
});
});

after(function () {
delete process.env.FOO;
});
});

it('should handle arguments with quotes', function (next) {
buffered(method, 'node', [
__dirname + '/fixtures/echo',
Expand Down

0 comments on commit a284ab9

Please sign in to comment.