Skip to content

Commit

Permalink
Added helper script to run multiple tox environments
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker committed Jul 31, 2024
1 parent 6631e89 commit 2b1a120
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions scripts/runtox.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
#
# Usage:
# ./scripts/runtox.sh py312 <pytest-args>
#
# Runs all environments with substring "py312" and the given arguments for pytest
#

# Print commands and exit on first error
set -ex

# Find the right tox executable
if [ -n "$TOXPATH" ]; then
true
elif which tox &> /dev/null; then
TOXPATH=tox
else
TOXPATH=./.venv/bin/tox
fi

# Find the environments matching the searchstring
searchstring="$1"
ENV="$($TOXPATH -l | grep -- "$searchstring" | tr $'\n' ',')"

if [ -z "${ENV}" ]; then
echo "No targets found. Skipping."
exit 0
fi

# Run tox with all matching environments
exec $TOXPATH -e "$ENV" -- "${@:2}"

0 comments on commit 2b1a120

Please sign in to comment.