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

process is forked with a single JSON argument #319

Merged
merged 1 commit into from
Dec 10, 2015
Merged

process is forked with a single JSON argument #319

merged 1 commit into from
Dec 10, 2015

Conversation

jokeyrhyme
Copy link
Contributor

This PR attempts to fix #318 .

Initially, the JSON string is converted back into process.argv values in lib/babel.js. I'm happy to go further and actually try to eliminate --fail-fast and --serial altogether in the child process, but I figured it was worth sharing what I had so far.

var opts = {
file: file,
failFast: this.failFast,
serial: this.serial,
Copy link
Member

Choose a reason for hiding this comment

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

I think we should do this.options = options in the Api constructor so we can just pass the whole options object here instead of explicitly specify each option.

@jokeyrhyme
Copy link
Contributor Author

Okay, I've removed the direct dependency on "has-flag" (although istanbul still pulls it in), and the child process just uses the parsed JSON options instead of using hasFlag.

@sindresorhus
Copy link
Member

See: #319 (comment)

@jokeyrhyme
Copy link
Contributor Author

Okay, fork now has the signature: fork(file: String, opts?: Object) => Promise, which means I was able to undo the changes I had to make to tests previously.

@@ -18,7 +17,7 @@ function Api(files, options) {

EventEmitter.call(this);

assign(this, options);
Copy link
Member

Choose a reason for hiding this comment

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

You can't just remove this. The options are used directly on this in the code and needs to be changed to use this.options.x.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

assign(this, options); has been replaced with objectAssign(this, options);

@jokeyrhyme
Copy link
Contributor Author

I very thoroughly checked for "serial" and "failFast" property access before removing that assign(this, options); in api.js, but I've reverted as you suggested.

@sindresorhus
Copy link
Member

@jokeyrhyme It's for example used here: https://github.com/jokeyrhyme/ava/blob/af4e70377a2b0143005c5fad52913821fcbdfbeb/api.js#L150

I would like to remove it though, as I feel it's pretty dirty to have arbitrary options mixed into this. @vdemedes You ok with that? Any other places it's used?

@jokeyrhyme
Copy link
Contributor Author

It's weird that the tests were still passing when I dropped the assign(this, options) in api.js...

@@ -3,6 +3,11 @@
var debug = require('debug')('ava');

if (debug.enabled) {
// Forward the `time-require` `--sorted` flag.
// Intended for internal optimization tests only.
if (exports.opts._sorted) {
Copy link
Member

Choose a reason for hiding this comment

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

This is outdated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I completely drop the "time-require" module from package.json dependencies and the related --sorted stuff?

Copy link
Member

Choose a reason for hiding this comment

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

No, meant that exports.opts._sorted is outdated with the latest PR changes.

@sindresorhus
Copy link
Member

Very nice work @jokeyrhyme :) Can you squash it down to one commit?

@sindresorhus
Copy link
Member

LGTM

@jokeyrhyme
Copy link
Contributor Author

Done. :)

@jokeyrhyme
Copy link
Contributor Author

@sindresorhus I think your "LGTM" came before my squash :)

@jamestalmage
Copy link
Contributor

LGTM

@vadimdemedes
Copy link
Contributor

@jokeyrhyme
Copy link
Contributor Author

@vdemedes in my squashed commit, I include moving that over to this.options.serial:
https://github.com/jokeyrhyme/ava/blob/eeeec706c285ed30889c6bf602f7797f31720270/api.js#L150

@vadimdemedes
Copy link
Contributor

@jokeyrhyme Oh, my bad. Everything is fine then!

@vadimdemedes
Copy link
Contributor

LGTM

vadimdemedes pushed a commit that referenced this pull request Dec 10, 2015
process is forked with a single JSON argument
@vadimdemedes vadimdemedes merged commit 07dea76 into avajs:master Dec 10, 2015
@jokeyrhyme jokeyrhyme deleted the pass-single-json-to-forks branch December 10, 2015 09:17
@vadimdemedes
Copy link
Contributor

@jokeyrhyme Ron, thank you for your valuable contribution to AVA, we really appreciate it! We'd love to see your new PRs soon!

@sindresorhus
Copy link
Member

Thank you! :D

@jokeyrhyme
Copy link
Contributor Author

🎉 😺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve passing data to forked processes
4 participants