-
Notifications
You must be signed in to change notification settings - Fork 443
docs: add usage guide #94
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
Conversation
It should be noted that the tests fail when run in the manner suggested: ```bash docker run -it \ -v $(pwd)/test:/test \ bats:latest \ /test ``` I believe that this should be a valid use case for testing, and that this will be solved by resolving the bats directory and support files as per the issues under discussion in bats-core#91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wiki/usage.md
Outdated
$ docker run -it bats:latest --tap /opt/bats/test | ||
``` | ||
|
||
To mount your tests into the container, first built the image as above. Then: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"built" => "build"
wiki/usage.md
Outdated
```bash | ||
$ docker run -v $(pwd)/test:/test bats /test | ||
``` | ||
This has run the `test/` directory from the bats-core repository inside the bats Docker container. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"has run" => "runs"
wiki/usage.md
Outdated
|
||
To mount your tests into the container, first built the image as above. Then: | ||
```bash | ||
$ docker run -v $(pwd)/test:/test bats /test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted in #93, this should be something like:
docker run -it -v $(pwd):/opt/bats-dev bats:latest /opt/bats-dev/test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take this back slightly; the /opt/bats-dev
dir should be /opt/bats
, i.e.:
docker run -it -v $(pwd):/opt/bats bats:latest /opt/bats/test
And I'm suddenly finding this command extremely useful. 🙂
As per conversation in bats-core#93 (comment)
wiki/usage.md
Outdated
```bash | ||
$ docker run -v $(pwd)/test:/test bats /test | ||
$ docker run -it -v $(pwd):/opt/bats bats:latest /opt/bats/test | ||
``` | ||
This has run the `test/` directory from the bats-core repository inside the bats Docker container. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This "has run" still reads funny.
wiki/usage.md
Outdated
``` | ||
This has run the `test/` directory from the bats-core repository inside the bats Docker container. | ||
|
||
|
||
Or for test files without any dependencies: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I understand now what you're saying... It would help to explain some more, something like: "For test suites that are intended to run in isolation from the project (i.e. no tests depend on project files outside of the test directory), you can mount the test directory in isolation and execute them like so:"
Thanks for the reviews on this @mbland |
wiki/usage.md
Outdated
|
||
For test suites that are intended to run in isolation from the project (i.e. tests do not depend on project files outside of the test directory), you can mount the test directory by iteself and execute the tests like so: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "iteself" => "itself"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D'oh
wiki/usage.md
Outdated
|
||
Or for test files without any dependencies: | ||
```bash | ||
$ docker run -v $(pwd)/test:/test bats /test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two nits, one substantial comment.
I'd prefer -v "$PWD:/opt/bats"
(including double quotes). Though it doesn't matter in terms of performance, it seems folks aren't aware that in Bash, many times you can use $PWD
where you would commonly use $(pwd)
, so I like to promote its use.
Should bats
be bats:latest
?
Finally, I don't think -it
is necessary for any of these commands. If you agree, mind not only updating this document, but the .travis.yml
command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$PWD
- good point!
bats
and bats:latest
are equivalent, but probably more obvious the include the tag. Will update.
-i
is useful to kill hanging processes (otherwise has to be done via docker stop
command), and -t
to simulate a tty (often not used, but most similar to most test runs). Former important to a user, not a build, and latter probably the inverse. Everything's least-surprising to a new Docker use if both are used I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh...that makes perfect sense re: -it
. Thanks for educating me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh all good 🙏
Further changes pushed @mbland |
So I've approved, but will leave merging up to you, since it seemed you weren't sure you wanted to add this to the repo or just port it to the wiki. One more thing up to you: Want to add |
Nice! Approval stands. Again I'll leave it up to you whether to merge or not. |
It should be noted that the tests fail when run in the manner suggested in this help guide.
docker run -it \ -v $(pwd)/test:/test \ bats:latest \ /test
I believe that this should be a valid use case for testing, and that
this will be solved by resolving the bats directory and support files as
per the issues under discussion in #91
Once this is merged I'll paste it into the GitHub wiki, or remove it from this tree - would just like it to be reviewed first.
closes #30