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

Option to run tests names matching a pattern. #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dougm
Copy link

@dougm dougm commented Sep 2, 2015

The option can be set using the BATS_TEST_PATTERN env var.

TODO: Add bats cli option

Fixes issue #36

The option can be set using the BATS_TEST_PATTERN env var.

TODO: Add bats cli option
@dougm dougm mentioned this pull request Sep 2, 2015
@Anvil
Copy link

Anvil commented Sep 3, 2015

Shouldn't $(echo $quoted_name | tr -d '"') be the (double-quoted) expression "${quoted_name//"/}" instead ?

@dougm
Copy link
Author

dougm commented Sep 4, 2015

@Anvil indeed, thanks, changed + pushed.

@nevsan
Copy link

nevsan commented Mar 26, 2016

I would love to see this get merged in. I currently put something almost exactly like this in my 'setup' routine and use it to call 'skip'.

@tailhook
Copy link

tailhook commented Sep 5, 2016

Any chance this got merged? It's super useful for me too.

@ztombol ztombol mentioned this pull request Dec 13, 2016
18 tasks
yarikoptic pushed a commit to neurodebian/bats that referenced this pull request Aug 6, 2019
…x-bash

travis: Enable build with default Linux image Bash
yarikoptic added a commit to neurodebian/bats that referenced this pull request Aug 6, 2019
Bats 1.1.0 - 2018-07-08

This is the first release with new features relative to the original Bats 0.4.0.

Added:
* The `-r, --recursive` flag to scan directory arguments recursively for
  `*.bats` files (sstephenson#109)
* The `contrib/rpm/bats.spec` file to build RPMs (sstephenson#111)

Changed:
* Travis exercises latest versions of Bash from 3.2 through 4.4 (sstephenson#116, sstephenson#117)
* Error output highlights invalid command line options (sstephenson#45, sstephenson#46, sstephenson#118)
* Replaced `echo` with `printf` (sstephenson#120)

Fixed:
* Fixed `BATS_ERROR_STATUS` getting lost when `bats_error_trap` fired multiple
  times under Bash 4.2.x (sstephenson#110)
* Updated `bin/bats` symlink resolution, handling the case on CentOS where
  `/bin` is a symlink to `/usr/bin` (sstephenson#113, sstephenson#115)

* tag 'v1.1.0': (198 commits)
  Bats 1.1.0
  bats: Replace echo with printf
  Extract `abort()` function
  travis: Remove `bats -c` wrapper
  travis: Enable build with default Linux image Bash
  Add Bash version test to Travis job.
  Revert "Re-add Bash version check to Docker image build"
  Re-add Bash version check to Docker image build
  Move timing test to Docker run for Linux jobs
  Remove version check from Docker image build
  Bash version via build matrix instead of script loop
  Fix merge error.
  Add return code storage for Bash version loop
  Add Bash version output during 'docker build'
  Clean up Docker image tags
  Add default value for Bash version
  Cover more Bash versions with Docker
  BATS_ROOT: Elide options to reset shell options
  BATS_ROOT: Restore comment noting issue sstephenson#113
  BATS_ROOT: Use `set -P`, remove `PWD` resolution
  ...
pattern='^ *@test *([^ ].*) *\{ *(.*)$'

while IFS= read -r line; do
let index+=1
if [[ "$line" =~ $pattern ]]; then
quoted_name="${BASH_REMATCH[1]}"
if [ -n "$BATS_TEST_PATTERN" ]; then
if [[ "${quoted_name//\"/}" =~ $BATS_TEST_PATTERN ]]; then

Choose a reason for hiding this comment

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

I chasnged mine to if [[ "${BATS_TEST_PATTERN}" == *"${quoted_name//\"/}"* ]]; then which allows

BATS_TEST_PATTERN to be a list of tests instead of pattern matching. (then i renamed the Variables cause its a list not a pattern.) but I am just noting here in case oithers find this excellent solution for a current feature gap.

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

Successfully merging this pull request may close these issues.

5 participants