Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Verify the shell option works properly on execFile #18384

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/parallel/test-child-process-execfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { getSystemErrorName } = require('util');
const fixtures = require('../common/fixtures');

const fixture = fixtures.path('exit.js');
const execOpts = { encoding: 'utf8', shell: process.env.SHELL };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process.env.SHELL is likely to not be set on Windows so this will end up being undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct mr @richardlau, i tested it on another pc running windows and process.env.SHELL was undefined.
Thanks for feedback I appreciate it.


{
execFile(
Expand Down Expand Up @@ -39,3 +40,10 @@ const fixture = fixtures.path('exit.js');
child.kill();
child.emit('close', code, null);
}

{
// Verify the shell option works properly
execFile(process.execPath, [fixture, 0], execOpts, common.mustCall((err) => {
assert.strictEqual(err, null);
Copy link
Member

@BridgeAR BridgeAR Jan 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a perfect place for assert.ifError.

}));
}
6 changes: 6 additions & 0 deletions test/sequential/test-child-process-execsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const TIMER = 200;
const SLEEP = 2000;

const start = Date.now();
const execOpts = { encoding: 'utf8', shell: process.env.SHELL };
let err;
let caught = false;

Expand Down Expand Up @@ -141,3 +142,8 @@ assert.strictEqual(ret, `${msg}\n`);
return true;
});
}

// Verify the shell option works properly
assert.doesNotThrow(() => {
execFileSync(process.execPath, [], execOpts);
});