You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.
I was kind of confused on how to get my tests running everywhere.
On CI I was cloning bats then running it.
Locally I had bats installed with my package manager so could just call it directly
For contributors I had to point them to where to install bats to be able to run tests
It was kind of a pain.
Anyway, I just thew together this super simple script that pulls bats down into your tests directory, then runs your tests with it. Next time you run the script it won't pull bats down again if it's still there. tests/bats should be added to .gitignore so it's never included in the actual repo.
That means I can just run ./test everywhere; CI, locally and for end users. And it just works. Thought it might be worth sharing. Happy to submit a PR if you think it would be useful.
Script is just:
#!/bin/bashset -euo pipefail
# Pull down batsif [ !-d"tests/bats" ] ;thenecho"Pulling down github.com/sstephenson/bats test framework..."
git clone --quiet https://github.com/sstephenson/bats.git tests/bats
fi# Run testsecho"Running tests..."
tests/bats/bin/bats tests
And means anyone can just do:
$ ./test
Pulling down github.com/sstephenson/bats test framework...
Running tests...
✓ gpg is in PATH
✓ CHEST_DIR gets auto created
✓ Running with no commands returns usage with error status
✓ Option -e encrypts a file and sends it to the chest
✓ Option -d decrypts a file from the chest
✓ Option -z compresses data before/after sending to chest
✓ Option -r removes the original file after sending to the chest
✓ Option -l lists items in chest
✓ Option -k sets a custom key
✓ Directories with children can be added/retrieved form the chest
10 tests, 0 failures
Great job on bats, it's really nice.
I was kind of confused on how to get my tests running everywhere.
It was kind of a pain.
Anyway, I just thew together this super simple script that pulls bats down into your
tests
directory, then runs your tests with it. Next time you run the script it won't pull bats down again if it's still there.tests/bats
should be added to.gitignore
so it's never included in the actual repo.That means I can just run
./test
everywhere; CI, locally and for end users. And it just works. Thought it might be worth sharing. Happy to submit a PR if you think it would be useful.Script is just:
And means anyone can just do:
This is the project I created it for if you're interested: https://github.com/lukechilds/chest
The text was updated successfully, but these errors were encountered: