{"action":"closed","number":15,"pull_request":{"url":"https://api.github.com/repos/vesln/nixt/pulls/15","id":56581786,"html_url":"https://github.com/vesln/nixt/pull/15","diff_url":"https://github.com/vesln/nixt/pull/15.diff","patch_url":"https://github.com/vesln/nixt/pull/15.patch","issue_url":"https://api.github.com/repos/vesln/nixt/issues/15","number":15,"state":"closed","locked":false,"title":"Wait for standard IO streams to close","user":{"login":"eush77","id":4472489,"avatar_url":"https://avatars.githubusercontent.com/u/4472489?v=3","gravatar_id":"","url":"https://api.github.com/users/eush77","html_url":"https://github.com/eush77","followers_url":"https://api.github.com/users/eush77/followers","following_url":"https://api.github.com/users/eush77/following{/other_user}","gists_url":"https://api.github.com/users/eush77/gists{/gist_id}","starred_url":"https://api.github.com/users/eush77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eush77/subscriptions","organizations_url":"https://api.github.com/users/eush77/orgs","repos_url":"https://api.github.com/users/eush77/repos","events_url":"https://api.github.com/users/eush77/events{/privacy}","received_events_url":"https://api.github.com/users/eush77/received_events","type":"User","site_admin":false},"body":"Currently test results are evaluated [in the listener for `exit` event](https://github.com/vesln/nixt/blob/4d178e69c02e20a79c23479dae7100b90bb278d5/lib/nixt/runner.js#L414) of the child process. However, [exit] event is not guaranteed to be emitted *after* standard output streams are closed, as demostrated by the program below:\r\n\r\n```js\r\nvar spawn = require('child_process').spawn;\r\n\r\nvar cp = spawn('echo', ['foo']);\r\ncp.stdout.on('data', console.log);\r\ncp.on('exit', () => console.log('exit'));\r\n```\r\n\r\n```\r\n$ node --version\r\nv5.0.0\r\n$ node example.js\r\nexit\r\n<Buffer 66 6f 6f 0a>\r\n```\r\n\r\nSee also [this warning][exit] from Node.js docs:\r\n\r\n> Note that when the 'exit' event is triggered, child process stdio streams might still be open.\r\n\r\nI can't come up with a failing test for this, but here's a failing example on the command line:\r\n\r\n```js\r\n$ node -e 'require(\"./\")().run(\"echo foo\").stdout(\"foo\").end(err => { if (err) console.log(err.toString()) })'\r\nAssertionError: `echo foo`: Expected stdout to match \"foo\". Actual: \"\"\r\n```\r\n\r\nThis patch listens for [close] event instead:\r\n\r\n> The 'close' event is emitted when the stdio streams of a child process have been closed.\r\n\r\n[exit]: https://nodejs.org/api/child_process.html#child_process_event_exit\r\n[close]: https://nodejs.org/api/child_process.html#child_process_event_close","created_at":"2016-01-20T09:20:28Z","updated_at":"2016-01-20T19:19:42Z","closed_at":"2016-01-20T19:19:42Z","merged_at":"2016-01-20T19:19:42Z","merge_commit_sha":"ab0db4b976002e63563d1d7cd241135a40bfc730","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/vesln/nixt/pulls/15/commits","review_comments_url":"https://api.github.com/repos/vesln/nixt/pulls/15/comments","review_comment_url":"https://api.github.com/repos/vesln/nixt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vesln/nixt/issues/15/comments","statuses_url":"https://api.github.com/repos/vesln/nixt/statuses/ff899cd1a5ce0b23fdb63ebe3139d080b460d9cc","head":{"label":"eush77:child-process-close","ref":"child-process-close","sha":"ff899cd1a5ce0b23fdb63ebe3139d080b460d9cc","user":{"login":"eush77","id":4472489,"avatar_url":"https://avatars.githubusercontent.com/u/4472489?v=3","gravatar_id":"","url":"https://api.github.com/users/eush77","html_url":"https://github.com/eush77","followers_url":"https://api.github.com/users/eush77/followers","following_url":"https://api.github.com/users/eush77/following{/other_user}","gists_url":"https://api.github.com/users/eush77/gists{/gist_id}","starred_url":"https://api.github.com/users/eush77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eush77/subscriptions","organizations_url":"https://api.github.com/users/eush77/orgs","repos_url":"https://api.github.com/users/eush77/repos","events_url":"https://api.github.com/users/eush77/events{/privacy}","received_events_url":"https://api.github.com/users/eush77/received_events","type":"User","site_admin":false},"repo":{"id":50016870,"name":"nixt","full_name":"eush77/nixt","owner":{"login":"eush77","id":4472489,"avatar_url":"https://avatars.githubusercontent.com/u/4472489?v=3","gravatar_id":"","url":"https://api.github.com/users/eush77","html_url":"https://github.com/eush77","followers_url":"https://api.github.com/users/eush77/followers","following_url":"https://api.github.com/users/eush77/following{/other_user}","gists_url":"https://api.github.com/users/eush77/gists{/gist_id}","starred_url":"https://api.github.com/users/eush77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eush77/subscriptions","organizations_url":"https://api.github.com/users/eush77/orgs","repos_url":"https://api.github.com/users/eush77/repos","events_url":"https://api.github.com/users/eush77/events{/privacy}","received_events_url":"https://api.github.com/users/eush77/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eush77/nixt","description":"Simple and elegant end-to-end testing for command-line apps","fork":true,"url":"https://api.github.com/repos/eush77/nixt","forks_url":"https://api.github.com/repos/eush77/nixt/forks","keys_url":"https://api.github.com/repos/eush77/nixt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eush77/nixt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eush77/nixt/teams","hooks_url":"https://api.github.com/repos/eush77/nixt/hooks","issue_events_url":"https://api.github.com/repos/eush77/nixt/issues/events{/number}","events_url":"https://api.github.com/repos/eush77/nixt/events","assignees_url":"https://api.github.com/repos/eush77/nixt/assignees{/user}","branches_url":"https://api.github.com/repos/eush77/nixt/branches{/branch}","tags_url":"https://api.github.com/repos/eush77/nixt/tags","blobs_url":"https://api.github.com/repos/eush77/nixt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eush77/nixt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eush77/nixt/git/refs{/sha}","trees_url":"https://api.github.com/repos/eush77/nixt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eush77/nixt/statuses/{sha}","languages_url":"https://api.github.com/repos/eush77/nixt/languages","stargazers_url":"https://api.github.com/repos/eush77/nixt/stargazers","contributors_url":"https://api.github.com/repos/eush77/nixt/contributors","subscribers_url":"https://api.github.com/repos/eush77/nixt/subscribers","subscription_url":"https://api.github.com/repos/eush77/nixt/subscription","commits_url":"https://api.github.com/repos/eush77/nixt/commits{/sha}","git_commits_url":"https://api.github.com/repos/eush77/nixt/git/commits{/sha}","comments_url":"https://api.github.com/repos/eush77/nixt/comments{/number}","issue_comment_url":"https://api.github.com/repos/eush77/nixt/issues/comments{/number}","contents_url":"https://api.github.com/repos/eush77/nixt/contents/{+path}","compare_url":"https://api.github.com/repos/eush77/nixt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eush77/nixt/merges","archive_url":"https://api.github.com/repos/eush77/nixt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eush77/nixt/downloads","issues_url":"https://api.github.com/repos/eush77/nixt/issues{/number}","pulls_url":"https://api.github.com/repos/eush77/nixt/pulls{/number}","milestones_url":"https://api.github.com/repos/eush77/nixt/milestones{/number}","notifications_url":"https://api.github.com/repos/eush77/nixt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eush77/nixt/labels{/name}","releases_url":"https://api.github.com/repos/eush77/nixt/releases{/id}","created_at":"2016-01-20T08:45:06Z","updated_at":"2016-01-20T08:45:07Z","pushed_at":"2016-01-20T09:07:28Z","git_url":"git://github.com/eush77/nixt.git","ssh_url":"git@github.com:eush77/nixt.git","clone_url":"https://github.com/eush77/nixt.git","svn_url":"https://github.com/eush77/nixt","homepage":"","size":94,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"vesln:master","ref":"master","sha":"4d178e69c02e20a79c23479dae7100b90bb278d5","user":{"login":"vesln","id":330048,"avatar_url":"https://avatars.githubusercontent.com/u/330048?v=3","gravatar_id":"","url":"https://api.github.com/users/vesln","html_url":"https://github.com/vesln","followers_url":"https://api.github.com/users/vesln/followers","following_url":"https://api.github.com/users/vesln/following{/other_user}","gists_url":"https://api.github.com/users/vesln/gists{/gist_id}","starred_url":"https://api.github.com/users/vesln/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vesln/subscriptions","organizations_url":"https://api.github.com/users/vesln/orgs","repos_url":"https://api.github.com/users/vesln/repos","events_url":"https://api.github.com/users/vesln/events{/privacy}","received_events_url":"https://api.github.com/users/vesln/received_events","type":"User","site_admin":false},"repo":{"id":13909919,"name":"nixt","full_name":"vesln/nixt","owner":{"login":"vesln","id":330048,"avatar_url":"https://avatars.githubusercontent.com/u/330048?v=3","gravatar_id":"","url":"https://api.github.com/users/vesln","html_url":"https://github.com/vesln","followers_url":"https://api.github.com/users/vesln/followers","following_url":"https://api.github.com/users/vesln/following{/other_user}","gists_url":"https://api.github.com/users/vesln/gists{/gist_id}","starred_url":"https://api.github.com/users/vesln/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vesln/subscriptions","organizations_url":"https://api.github.com/users/vesln/orgs","repos_url":"https://api.github.com/users/vesln/repos","events_url":"https://api.github.com/users/vesln/events{/privacy}","received_events_url":"https://api.github.com/users/vesln/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vesln/nixt","description":"Simple and elegant end-to-end testing for command-line apps","fork":false,"url":"https://api.github.com/repos/vesln/nixt","forks_url":"https://api.github.com/repos/vesln/nixt/forks","keys_url":"https://api.github.com/repos/vesln/nixt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vesln/nixt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vesln/nixt/teams","hooks_url":"https://api.github.com/repos/vesln/nixt/hooks","issue_events_url":"https://api.github.com/repos/vesln/nixt/issues/events{/number}","events_url":"https://api.github.com/repos/vesln/nixt/events","assignees_url":"https://api.github.com/repos/vesln/nixt/assignees{/user}","branches_url":"https://api.github.com/repos/vesln/nixt/branches{/branch}","tags_url":"https://api.github.com/repos/vesln/nixt/tags","blobs_url":"https://api.github.com/repos/vesln/nixt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vesln/nixt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vesln/nixt/git/refs{/sha}","trees_url":"https://api.github.com/repos/vesln/nixt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vesln/nixt/statuses/{sha}","languages_url":"https://api.github.com/repos/vesln/nixt/languages","stargazers_url":"https://api.github.com/repos/vesln/nixt/stargazers","contributors_url":"https://api.github.com/repos/vesln/nixt/contributors","subscribers_url":"https://api.github.com/repos/vesln/nixt/subscribers","subscription_url":"https://api.github.com/repos/vesln/nixt/subscription","commits_url":"https://api.github.com/repos/vesln/nixt/commits{/sha}","git_commits_url":"https://api.github.com/repos/vesln/nixt/git/commits{/sha}","comments_url":"https://api.github.com/repos/vesln/nixt/comments{/number}","issue_comment_url":"https://api.github.com/repos/vesln/nixt/issues/comments{/number}","contents_url":"https://api.github.com/repos/vesln/nixt/contents/{+path}","compare_url":"https://api.github.com/repos/vesln/nixt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vesln/nixt/merges","archive_url":"https://api.github.com/repos/vesln/nixt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vesln/nixt/downloads","issues_url":"https://api.github.com/repos/vesln/nixt/issues{/number}","pulls_url":"https://api.github.com/repos/vesln/nixt/pulls{/number}","milestones_url":"https://api.github.com/repos/vesln/nixt/milestones{/number}","notifications_url":"https://api.github.com/repos/vesln/nixt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vesln/nixt/labels{/name}","releases_url":"https://api.github.com/repos/vesln/nixt/releases{/id}","created_at":"2013-10-27T20:40:15Z","updated_at":"2016-01-20T16:49:49Z","pushed_at":"2016-01-20T19:19:42Z","git_url":"git://github.com/vesln/nixt.git","ssh_url":"git@github.com:vesln/nixt.git","clone_url":"https://github.com/vesln/nixt.git","svn_url":"https://github.com/vesln/nixt","homepage":"","size":561,"stargazers_count":168,"watchers_count":168,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":4,"forks":12,"open_issues":4,"watchers":168,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vesln/nixt/pulls/15"},"html":{"href":"https://github.com/vesln/nixt/pull/15"},"issue":{"href":"https://api.github.com/repos/vesln/nixt/issues/15"},"comments":{"href":"https://api.github.com/repos/vesln/nixt/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/vesln/nixt/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/vesln/nixt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vesln/nixt/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/vesln/nixt/statuses/ff899cd1a5ce0b23fdb63ebe3139d080b460d9cc"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"eush77","id":4472489,"avatar_url":"https://avatars.githubusercontent.com/u/4472489?v=3","gravatar_id":"","url":"https://api.github.com/users/eush77","html_url":"https://github.com/eush77","followers_url":"https://api.github.com/users/eush77/followers","following_url":"https://api.github.com/users/eush77/following{/other_user}","gists_url":"https://api.github.com/users/eush77/gists{/gist_id}","starred_url":"https://api.github.com/users/eush77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eush77/subscriptions","organizations_url":"https://api.github.com/users/eush77/orgs","repos_url":"https://api.github.com/users/eush77/repos","events_url":"https://api.github.com/users/eush77/events{/privacy}","received_events_url":"https://api.github.com/users/eush77/received_events","type":"User","site_admin":false},"comments":5,"review_comments":0,"commits":1,"additions":1,"deletions":1,"changed_files":1}}