Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Helpful test script #252

Open
lukechilds opened this issue Jan 11, 2018 · 2 comments
Open

Helpful test script #252

lukechilds opened this issue Jan 11, 2018 · 2 comments

Comments

@lukechilds
Copy link

lukechilds commented Jan 11, 2018

Great job on bats, it's really nice.

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/bash
set -euo pipefail

# Pull down bats
if [ ! -d "tests/bats" ] ; then
    echo "Pulling down github.com/sstephenson/bats test framework..."
    git clone --quiet https://github.com/sstephenson/bats.git tests/bats
fi

# Run tests
echo "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

This is the project I created it for if you're interested: https://github.com/lukechilds/chest

@Potherca
Copy link

This project is no longer being actively maintained by its original auther (see #236).

You might want to migrate to the community maintained fork bats-core and report your issue there.

@030
Copy link

030 commented May 9, 2018

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

No branches or pull requests

3 participants