Skip to content

Conversation

sublimino
Copy link
Member

@sublimino sublimino commented Jun 8, 2018

This is to cover the use case of developing against bats in a container
with a watch command.

It currently fails due to issues resolving bats' own path as per the issues under discussion in #91


This is to cover the use case of developing against bats in a container
with a watch command
@sublimino sublimino requested a review from a team as a code owner June 8, 2018 14:36
@ghost ghost assigned sublimino Jun 8, 2018
@ghost ghost added the review label Jun 8, 2018
@mbland
Copy link
Contributor

mbland commented Jun 8, 2018

Odd...the failure is due to a violation of unofficial Bash strict mode. Will look a little later.

@mbland
Copy link
Contributor

mbland commented Jun 8, 2018

Ah, now I see it, plain as day (from https://travis-ci.org/bats-core/bats-core/jobs/389756078):

not ok 42 ensure compatibility with unofficial Bash strict mode
[...snip...]
# output:
# bash: //libexec/bats: No such file or directory

This because the test case runs Bats thus:

  run bash -u "${BATS_TEST_DIRNAME%/*}/libexec/bats" \
    "$FIXTURE_ROOT/unofficial_bash_strict_mode.bats"

So ${BATS_TEST_DIRNAME%/*}/libexec/bats resolves to //libexec/bats, when it should resolve to /opt/bats/libexec/bats. (Also, it should be ${BATS_TEST_DIRNAME}/bin/bats. Pushed a commit to #92 for that.)

So I'd suggest the command should be some variation of the following:

docker run -it -v $(pwd):/opt/bats-dev bats:latest /opt/bats-dev/test

Yep, that runs very nicely!

@mbland mbland mentioned this pull request Jun 8, 2018
2 tasks
@mbland
Copy link
Contributor

mbland commented Jun 8, 2018

I should add, to be clear: the failure was due to the /test directory being isolated from the rest of Bats. It's reasonable for those file to expect to access files in the same project, so I'd recommend mounting the root of the project in the container, not just the test directory alone.

@mbland
Copy link
Contributor

mbland commented Jun 8, 2018

And actually, I'm beginning to wonder if the extra build step is of any value to our build, given the documented technique in #94. What do you think?

sublimino added a commit to sublimino/bats-core that referenced this pull request Jun 11, 2018
@sublimino
Copy link
Member Author

sublimino commented Jun 11, 2018

I'd prefer to have the tests runnable in isolation as they're testing the application in the container, but I understand that adding code to do so may be un-intuitive for maintainers.

I've updated the PR to reflect requested changes in #93 (comment)

@mbland
Copy link
Contributor

mbland commented Jun 11, 2018

Just added a comment to your latest update in #93. I think I understand what you're saying now, and suggested more explicit wording.

Copy link
Contributor

@mbland mbland left a comment

Choose a reason for hiding this comment

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

Just noticed this is still open...and the second command is still failing because bats-core/test is still getting mounted in isolation from bats-core.

Did you still want to fix this up and get it in, @sublimino?

@sublimino
Copy link
Member Author

I re-tested it earlier today and your assertion is correct @mbland. Will get it fixed

@martin-schulze-vireso
Copy link
Member

I am closing this since we don't use travis anymore. The usecase might still be valid. If so, we should put up an issue for that.

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

Successfully merging this pull request may close these issues.

3 participants