Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

TESTS: Don't use exec for testing stdin. Modify process.stdin directly. Fixes #547 #596

Closed
wants to merge 1 commit into from

Conversation

mrjoelkemp
Copy link
Member

Avoids using exec for stdin tests by manipulating process.stdin in the tests and emitting events on process.stdin to trigger stdin parsing in the cli. This speeds up the test suite considerably.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.29%) when pulling 04329b2 on mrjoelkemp:mock_stdin into 2fa147c on jscs-dev:master.


// Simulate buffered stdin by delaying before sending the next chunk
// of data. Note: this arbitrary timeout appears to be the only way
// to reliably trigger two 'data' events on cmd's stdin.
setTimeout(function() {
cmd.stdin.end('a = 1;\n');
process.stdin.emit('data', 'var a = 1;\n');
Copy link
Member Author

Choose a reason for hiding this comment

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

@benesch hey, since you can just do process.stdin.emit('data', ...), do we still need the timeout of half a second?

Seems like two things are going on here:

  1. The timeout simulates a delay in data buffering
  2. The timeout is stated to be used because of the lack of being able to trigger two 'data' events. I don't believe this is the case.

If it turns out that case 2 is no longer valid, and if you agree, I will decrease the timeout to avoid unnecessarily slowing down the suite.

@markelog
Copy link
Member

Awesome, can't wait to land it

@markelog
Copy link
Member

Merged, thank you

@markelog
Copy link
Member

Hm, after merging this and #594 one test is now falling, could you take a look?

@mrjoelkemp
Copy link
Member Author

Will do.

@mrjoelkemp
Copy link
Member Author

@markelog addressed in #607

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

Successfully merging this pull request may close these issues.

3 participants