Skip to content
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

Use BATS for tests #429

Closed
koenpunt opened this issue Jun 4, 2014 · 6 comments
Closed

Use BATS for tests #429

koenpunt opened this issue Jun 4, 2014 · 6 comments
Labels
testing Stuff related to testing nvm itself.

Comments

@koenpunt
Copy link
Contributor

koenpunt commented Jun 4, 2014

As BATS is better maintained and looks nicer than Urchin, I think we should try and see if it behaves better as well.

Its from @sstephenson, which is the creator of rbenv among other things.

Installation of BATS can be done by adding the following to .travis.yml

before_install:
  - sudo add-apt-repository ppa:duggan/bats --yes
  - sudo apt-get update
  - sudo apt-get install bats
script:
  - bats test/bats
@smikes
Copy link

smikes commented Dec 3, 2014

I'm looking for a small project to get oriented to nvm -- is this experiment (try porting tests to BATS) still desired? If so, I would do it on a branch in my fork.

@ljharb
Copy link
Member

ljharb commented Dec 3, 2014

It's definitely still worth investigating.

Any solution that can allow us to specify which shell to run tests on, to split up tests somehow, and to provide setup/teardown facility, would be worth evaluating.

@smikes
Copy link

smikes commented Dec 3, 2014

OK. I will take this on. I have a couple of plane flights coming up. ;-)

@smikes
Copy link

smikes commented Dec 8, 2014

This is currently in progress. I had some problems making bats play nicely with sourcing the nvm.sh file but eventually worked around them.

Early progress can be seen on the https://github.com/smikes/nvm/tree/bats branch

One useful snippet (that I will save here) is this:

find . -type f | while read f; do echo "@test '$f' {"; sed -e 's/^/#/' "$f"; echo "}"; echo ; done >> ../bats/fast2.bats

This converts a tree full of urchin style tests into a file full of bats style tests, where each bats test gets the name of the urchin test-file, and the contents of each bats test are the commented-out contents of the test file. (This saves switching between source-test and target-test when porting)

@smikes
Copy link

smikes commented Dec 23, 2014

Opened a PR (#601) for review of this work. About half-done; I have ported the tests from test/fast (50 tests) and approximately 30 remain.

@ljharb
Copy link
Member

ljharb commented Jan 19, 2024

Per #601 (comment), BATS is bash-specific and thus can’t work for our needs.

@ljharb ljharb closed this as not planned Won't fix, can't repro, duplicate, stale Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Stuff related to testing nvm itself.
Projects
None yet
Development

No branches or pull requests

3 participants