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: refactor stdin-script-child #10321

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
14 changes: 7 additions & 7 deletions test/parallel/test-stdin-script-child.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';
require('../common');
var assert = require('assert');
const assert = require('assert');

var spawn = require('child_process').spawn;
var child = spawn(process.execPath, [], {
const spawn = require('child_process').spawn;
const child = spawn(process.execPath, [], {
env: Object.assign(process.env, {
NODE_DEBUG: process.argv[2]
})
});
var wanted = child.pid + '\n';
const wanted = child.pid + '\n';
var found = '';

child.stdout.setEncoding('utf8');
Expand All @@ -22,11 +22,11 @@ child.stderr.on('data', function(c) {
});

child.on('close', function(c) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you please wrap the callback with common.mustCall?

Copy link
Member

@Trott Trott Dec 21, 2016

Choose a reason for hiding this comment

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

We need butter better documentation for common.mustCall() for new contributors. I've just opened #10390 to slightly expand what we have.

@emanuelbuholzer If you need a little bit more information about common.mustCall(), it's at https://github.com/Trott/io.js/blob/bd2ae52fc3fbb9ce6c0e8c79ff5e67f8a742847b/test/README.md#mustcallfn-expected for now. You can also look at how it is used in other tests. And you can also ask questions here or on the #node-dev channel on Freenode IRC.

Copy link
Member

Choose a reason for hiding this comment

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

+1 for buttery documentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I also think it needs some better documentation. I'll add my thoughts and experiences to the opened issue. I just checked the function out in the source code and will try to make the changes in a bit.

assert(!c);
assert.equal(found, wanted);
assert.strictEqual(c, 0);
assert.strictEqual(found, wanted);
console.log('ok');
});

setTimeout(function() {
child.stdin.end('console.log(process.pid)');
});
}, 1);