Skip to content

Instantly share code, notes, and snippets.

@konradkonrad
Last active May 8, 2019 10:42
Show Gist options
  • Save konradkonrad/7411fbb1ab0942d8495873dc2cc6b679 to your computer and use it in GitHub Desktop.
Save konradkonrad/7411fbb1ab0942d8495873dc2cc6b679 to your computer and use it in GitHub Desktop.
run tests and show coverage report html for raiden
#!/usr/bin/env sh
# pytest executable
PYTEST=${PYTEST:-$(which pytest)}
# specify non temp output directory
OUT_DIR=${OUT_DIR:-$(mktemp -d)}
# which tests to execute
SUITE=${SUITE:-raiden/tests/unit raiden/tests/fuzz}
# report only these files
ONLY=${ONLY:-*}
# open specific file
SHOW=${SHOW:-index.html}
# example:
## ONLY=raiden/transfer/node.py SHOW=raiden_transfer_node_py.html test_and_report.sh
if [[ "$ONLY" = "*" ]];
then
SHOW=${SHOW:-index.html}
else
SHOW=$(python -c "import sys; print(sys.argv[1].replace('/', '_').replace('.', '_') + '.html')" $ONLY)
fi
mkdir -p $OUT_DIR
rm .coverage
coverage run $PYTEST -x $SUITE && coverage html -d $OUT_DIR --include=$ONLY && xdg-open $OUT_DIR/$SHOW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment