{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/75205628","id":75205628,"diff_hunk":"@@ -464,49 +441,70 @@ func dockerCmdWithError(args ...string) (string, int, error) {\n \tif err := validateArgs(args...); err != nil {\n \t\treturn \"\", 0, err\n \t}\n-\tout, code, err := integration.DockerCmdWithError(dockerBinary, args...)\n-\tif err != nil {\n-\t\terr = fmt.Errorf(\"%v: %s\", err, out)\n+\tresult := icmd.RunCommand(dockerBinary, args...)\n+\tif result.Error != nil {\n+\t\treturn result.Combined(), result.ExitCode, result.Fails(icmd.Expected{})\n \t}\n-\treturn out, code, err\n+\treturn result.Combined(), result.ExitCode, result.Error\n }\n \n func dockerCmdWithStdoutStderr(c *check.C, args ...string) (string, string, int) {\n \tif err := validateArgs(args...); err != nil {\n \t\tc.Fatalf(err.Error())\n \t}\n-\treturn integration.DockerCmdWithStdoutStderr(dockerBinary, c, args...)\n+\n+\tresult := icmd.RunCommand(dockerBinary, args...)\n+\t// TODO: why is c ever nil?\n+\tif c != nil {\n+\t\tresult.Assert(c, icmd.Expected{})\n+\t}\n+\treturn result.Stdout(), result.Stderr(), result.ExitCode\n }\n \n func dockerCmd(c *check.C, args ...string) (string, int) {\n \tif err := validateArgs(args...); err != nil {\n \t\tc.Fatalf(err.Error())\n \t}\n-\treturn integration.DockerCmd(dockerBinary, c, args...)\n+\tresult := icmd.RunCommand(dockerBinary, args...)\n+\tresult.Assert(c, icmd.Expected{})\n+\treturn result.Combined(), result.ExitCode\n+}\n+\n+func dockerCmdWithResult(args ...string) *icmd.Result {\n+\treturn icmd.RunCommand(dockerBinary, args...)\n+}\n+\n+func binaryWithArgs(args []string) []string {","path":"integration-cli/docker_utils.go","position":136,"original_position":136,"commit_id":"0bceafb6ca93041c2611259d9cf61b28587d7fdb","original_commit_id":"0bceafb6ca93041c2611259d9cf61b28587d7fdb","user":{"login":"dnephin","id":442180,"avatar_url":"https://avatars.githubusercontent.com/u/442180?v=3","gravatar_id":"","url":"https://api.github.com/users/dnephin","html_url":"https://github.com/dnephin","followers_url":"https://api.github.com/users/dnephin/followers","following_url":"https://api.github.com/users/dnephin/following{/other_user}","gists_url":"https://api.github.com/users/dnephin/gists{/gist_id}","starred_url":"https://api.github.com/users/dnephin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dnephin/subscriptions","organizations_url":"https://api.github.com/users/dnephin/orgs","repos_url":"https://api.github.com/users/dnephin/repos","events_url":"https://api.github.com/users/dnephin/events{/privacy}","received_events_url":"https://api.github.com/users/dnephin/received_events","type":"User","site_admin":false},"body":"hmm, I'm not sure. I guess it would be easier to use as a `...string`. I'll make that change","created_at":"2016-08-17T20:57:23Z","updated_at":"2016-08-17T20:57:23Z","html_url":"https://github.com/docker/docker/pull/25426#discussion_r75205628","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/25426","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/75205628"},"html":{"href":"https://github.com/docker/docker/pull/25426#discussion_r75205628"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/25426"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/25426","id":80167854,"html_url":"https://github.com/docker/docker/pull/25426","diff_url":"https://github.com/docker/docker/pull/25426.diff","patch_url":"https://github.com/docker/docker/pull/25426.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/25426","number":25426,"state":"open","locked":false,"title":"Remove duplicate RunCommand functions used for integration-cli","user":{"login":"dnephin","id":442180,"avatar_url":"https://avatars.githubusercontent.com/u/442180?v=3","gravatar_id":"","url":"https://api.github.com/users/dnephin","html_url":"https://github.com/dnephin","followers_url":"https://api.github.com/users/dnephin/followers","following_url":"https://api.github.com/users/dnephin/following{/other_user}","gists_url":"https://api.github.com/users/dnephin/gists{/gist_id}","starred_url":"https://api.github.com/users/dnephin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dnephin/subscriptions","organizations_url":"https://api.github.com/users/dnephin/orgs","repos_url":"https://api.github.com/users/dnephin/repos","events_url":"https://api.github.com/users/dnephin/events{/privacy}","received_events_url":"https://api.github.com/users/dnephin/received_events","type":"User","site_admin":false},"body":"There are currently ~20 different functions that do essentially the same thing (running a command). Many of these are just single line wrappers around other commands. \r\n\r\nThis PR introduces a new function (`RunCmd()`) which:\r\n* handles all variations of the previous ~20 functions\r\n* provides a way to assert the expected result of the command, with a complete error message on failure\r\n\r\n\r\nAlso:\r\n* removes many (12) of the lesser used function and replaces them with direct calls to `RunCmd()`\r\n* updates the remaining functions to be thin wrappers around the new `RunCmd()`, and use `Result.Assert()` to provide better error messages\r\n* removes `unmarshalJSON()` which was just an alias for `json.Unmarshal`\r\n\r\nOnce this PR is merged I can continue to convert some of the lesser used functions to direct calls to `RunCmd()` to further reduce the number of functions.\r\n\r\nThe \"new\" canonical way looks something like this:\r\n\r\n```go\r\n\r\n// Expect the command to be successful \r\nresult := icmd.RunCommand(\"echo hello world\")\r\nresult.Assert(c, icmd.Expected{})\r\n\r\n// Expect the command to fail\r\nresult := icmd.RunCommand(\"bash -c 'echo oops; exit 3'\")\r\nresult.Assert(c, icmd.Expected{\r\n    ExitCode: 3,\r\n    Out: \"oops\",\r\n})\r\n```\r\n\r\nIf you need to set anything on the command (directory, env, timeout, stdin, stdout), you can use the `RunCmd()` call and pass a `Cmd{}` struct which accepts all of these options.\r\n\r\n","created_at":"2016-08-04T23:44:06Z","updated_at":"2016-08-17T20:57:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4de1ac52ac7bf11f901d976b909bbff40bc1cb1e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/docker/docker/pulls/25426/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/25426/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/25426/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/0bceafb6ca93041c2611259d9cf61b28587d7fdb","head":{"label":"dnephin:better-int-testing-cmd","ref":"better-int-testing-cmd","sha":"0bceafb6ca93041c2611259d9cf61b28587d7fdb","user":{"login":"dnephin","id":442180,"avatar_url":"https://avatars.githubusercontent.com/u/442180?v=3","gravatar_id":"","url":"https://api.github.com/users/dnephin","html_url":"https://github.com/dnephin","followers_url":"https://api.github.com/users/dnephin/followers","following_url":"https://api.github.com/users/dnephin/following{/other_user}","gists_url":"https://api.github.com/users/dnephin/gists{/gist_id}","starred_url":"https://api.github.com/users/dnephin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dnephin/subscriptions","organizations_url":"https://api.github.com/users/dnephin/orgs","repos_url":"https://api.github.com/users/dnephin/repos","events_url":"https://api.github.com/users/dnephin/events{/privacy}","received_events_url":"https://api.github.com/users/dnephin/received_events","type":"User","site_admin":false},"repo":{"id":24821004,"name":"docker","full_name":"dnephin/docker","owner":{"login":"dnephin","id":442180,"avatar_url":"https://avatars.githubusercontent.com/u/442180?v=3","gravatar_id":"","url":"https://api.github.com/users/dnephin","html_url":"https://github.com/dnephin","followers_url":"https://api.github.com/users/dnephin/followers","following_url":"https://api.github.com/users/dnephin/following{/other_user}","gists_url":"https://api.github.com/users/dnephin/gists{/gist_id}","starred_url":"https://api.github.com/users/dnephin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dnephin/subscriptions","organizations_url":"https://api.github.com/users/dnephin/orgs","repos_url":"https://api.github.com/users/dnephin/repos","events_url":"https://api.github.com/users/dnephin/events{/privacy}","received_events_url":"https://api.github.com/users/dnephin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dnephin/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/dnephin/docker","forks_url":"https://api.github.com/repos/dnephin/docker/forks","keys_url":"https://api.github.com/repos/dnephin/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dnephin/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dnephin/docker/teams","hooks_url":"https://api.github.com/repos/dnephin/docker/hooks","issue_events_url":"https://api.github.com/repos/dnephin/docker/issues/events{/number}","events_url":"https://api.github.com/repos/dnephin/docker/events","assignees_url":"https://api.github.com/repos/dnephin/docker/assignees{/user}","branches_url":"https://api.github.com/repos/dnephin/docker/branches{/branch}","tags_url":"https://api.github.com/repos/dnephin/docker/tags","blobs_url":"https://api.github.com/repos/dnephin/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dnephin/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dnephin/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/dnephin/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dnephin/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/dnephin/docker/languages","stargazers_url":"https://api.github.com/repos/dnephin/docker/stargazers","contributors_url":"https://api.github.com/repos/dnephin/docker/contributors","subscribers_url":"https://api.github.com/repos/dnephin/docker/subscribers","subscription_url":"https://api.github.com/repos/dnephin/docker/subscription","commits_url":"https://api.github.com/repos/dnephin/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/dnephin/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/dnephin/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/dnephin/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/dnephin/docker/contents/{+path}","compare_url":"https://api.github.com/repos/dnephin/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dnephin/docker/merges","archive_url":"https://api.github.com/repos/dnephin/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dnephin/docker/downloads","issues_url":"https://api.github.com/repos/dnephin/docker/issues{/number}","pulls_url":"https://api.github.com/repos/dnephin/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/dnephin/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/dnephin/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dnephin/docker/labels{/name}","releases_url":"https://api.github.com/repos/dnephin/docker/releases{/id}","deployments_url":"https://api.github.com/repos/dnephin/docker/deployments","created_at":"2014-10-05T17:10:26Z","updated_at":"2016-02-19T21:16:11Z","pushed_at":"2016-08-17T16:30:46Z","git_url":"git://github.com/dnephin/docker.git","ssh_url":"git@github.com:dnephin/docker.git","clone_url":"https://github.com/dnephin/docker.git","svn_url":"https://github.com/dnephin/docker","homepage":"http://www.docker.com","size":97110,"stargazers_count":0,"watchers_count":0,"language":"Go","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":"docker:master","ref":"master","sha":"2ae49a088718f675ec11c387072fe6de8b22f0c7","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":7691631,"name":"docker","full_name":"docker/docker","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/docker","description":"Docker - the open-source application container engine","fork":false,"url":"https://api.github.com/repos/docker/docker","forks_url":"https://api.github.com/repos/docker/docker/forks","keys_url":"https://api.github.com/repos/docker/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/docker/teams","hooks_url":"https://api.github.com/repos/docker/docker/hooks","issue_events_url":"https://api.github.com/repos/docker/docker/issues/events{/number}","events_url":"https://api.github.com/repos/docker/docker/events","assignees_url":"https://api.github.com/repos/docker/docker/assignees{/user}","branches_url":"https://api.github.com/repos/docker/docker/branches{/branch}","tags_url":"https://api.github.com/repos/docker/docker/tags","blobs_url":"https://api.github.com/repos/docker/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/docker/languages","stargazers_url":"https://api.github.com/repos/docker/docker/stargazers","contributors_url":"https://api.github.com/repos/docker/docker/contributors","subscribers_url":"https://api.github.com/repos/docker/docker/subscribers","subscription_url":"https://api.github.com/repos/docker/docker/subscription","commits_url":"https://api.github.com/repos/docker/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/docker/contents/{+path}","compare_url":"https://api.github.com/repos/docker/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/docker/merges","archive_url":"https://api.github.com/repos/docker/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/docker/downloads","issues_url":"https://api.github.com/repos/docker/docker/issues{/number}","pulls_url":"https://api.github.com/repos/docker/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/docker/labels{/name}","releases_url":"https://api.github.com/repos/docker/docker/releases{/id}","deployments_url":"https://api.github.com/repos/docker/docker/deployments","created_at":"2013-01-18T18:10:57Z","updated_at":"2016-08-17T20:26:58Z","pushed_at":"2016-08-17T20:41:43Z","git_url":"git://github.com/docker/docker.git","ssh_url":"git@github.com:docker/docker.git","clone_url":"https://github.com/docker/docker.git","svn_url":"https://github.com/docker/docker","homepage":"http://www.docker.com","size":206101,"stargazers_count":34091,"watchers_count":34091,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9956,"mirror_url":null,"open_issues_count":2130,"forks":9956,"open_issues":2130,"watchers":34091,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/25426"},"html":{"href":"https://github.com/docker/docker/pull/25426"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/25426"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/25426/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/25426/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/25426/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/0bceafb6ca93041c2611259d9cf61b28587d7fdb"}}}}
{"actor":{"display_login":"dnephin"}}