{"action":"created","issue":{"url":"https://api.github.com/repos/sstephenson/bats/issues/107","labels_url":"https://api.github.com/repos/sstephenson/bats/issues/107/labels{/name}","comments_url":"https://api.github.com/repos/sstephenson/bats/issues/107/comments","events_url":"https://api.github.com/repos/sstephenson/bats/issues/107/events","html_url":"https://github.com/sstephenson/bats/issues/107","id":85640848,"number":107,"title":"Running a something directly much slower than running it with the run command?","user":{"login":"brikis98","id":711908,"avatar_url":"https://avatars.githubusercontent.com/u/711908?v=3","gravatar_id":"","url":"https://api.github.com/users/brikis98","html_url":"https://github.com/brikis98","followers_url":"https://api.github.com/users/brikis98/followers","following_url":"https://api.github.com/users/brikis98/following{/other_user}","gists_url":"https://api.github.com/users/brikis98/gists{/gist_id}","starred_url":"https://api.github.com/users/brikis98/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brikis98/subscriptions","organizations_url":"https://api.github.com/users/brikis98/orgs","repos_url":"https://api.github.com/users/brikis98/repos","events_url":"https://api.github.com/users/brikis98/events{/privacy}","received_events_url":"https://api.github.com/users/brikis98/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-05T21:56:17Z","updated_at":"2015-06-06T03:19:30Z","closed_at":null,"body":"I have a shell script called `foo.sh` that defines a function `bar`:\r\n\r\n```sh\r\nfunction bar {\r\n  # Do some stuff\r\n}\r\n```\r\n\r\nIf I use the `source` command to bring `foo.sh` into my test script and use the `run` command to execute `bar`, everything works great:\r\n\r\n```sh\r\nsource foo.sh\r\n\r\n@test \"Test bar\" {\r\n  run bar\r\n  [ \"$status\" -eq 0 ]\r\n}\r\n```\r\n\r\n```\r\n> time bats foo-test.bats \r\n ✓ Test bar\r\n\r\n1 test, 0 failures\r\n\r\nreal\t0m0.182s\r\nuser\t0m0.103s\r\nsys\t0m0.088s\r\n```\r\n\r\nIf I call `bar` directly, it still works, but the test takes *much* longer to run:\r\n\r\n```sh\r\nsource foo.sh\r\n\r\n@test \"Test bar\" {\r\n  bar\r\n  [ \"$?\" -eq 0 ]\r\n}\r\n```\r\n\r\n```\r\n> time bats foo-test.bats \r\n ✓ Test bar\r\n\r\n1 test, 0 failures\r\n\r\nreal\t0m1.089s\r\nuser\t0m0.470s\r\nsys\t0m0.599s\r\n```\r\n\r\nWhat is `run` doing that accounts for the 1 second vs 0.18 seconds difference in run time?"},"comment":{"url":"https://api.github.com/repos/sstephenson/bats/issues/comments/109514467","html_url":"https://github.com/sstephenson/bats/issues/107#issuecomment-109514467","issue_url":"https://api.github.com/repos/sstephenson/bats/issues/107","id":109514467,"user":{"login":"brikis98","id":711908,"avatar_url":"https://avatars.githubusercontent.com/u/711908?v=3","gravatar_id":"","url":"https://api.github.com/users/brikis98","html_url":"https://github.com/brikis98","followers_url":"https://api.github.com/users/brikis98/followers","following_url":"https://api.github.com/users/brikis98/following{/other_user}","gists_url":"https://api.github.com/users/brikis98/gists{/gist_id}","starred_url":"https://api.github.com/users/brikis98/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brikis98/subscriptions","organizations_url":"https://api.github.com/users/brikis98/orgs","repos_url":"https://api.github.com/users/brikis98/repos","events_url":"https://api.github.com/users/brikis98/events{/privacy}","received_events_url":"https://api.github.com/users/brikis98/received_events","type":"User","site_admin":false},"created_at":"2015-06-06T03:19:30Z","updated_at":"2015-06-06T03:19:30Z","body":"@mislav: [here is an example test case](https://github.com/brikis98/docker-osx-dev/blob/master/test/docker-osx-dev.bats#L105). All the ones that call `configure_xxx` directly take around 1 second. If I call `run configure_xxx` it takes 0.1 seconds. And [here is one of the configure_xxx methods](https://github.com/brikis98/docker-osx-dev/blob/master/src/docker-osx-dev#L817). "}}