Skip to content

Instantly share code, notes, and snippets.

@teepark
Created April 7, 2017 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teepark/889bc351c0e953b738377da45e70919a to your computer and use it in GitHub Desktop.
Save teepark/889bc351c0e953b738377da45e70919a to your computer and use it in GitHub Desktop.
colorful nosetests wrapper
#!/usr/bin/env bash
set -euo pipefail
simple() {
sed -E \
-e "1 s/\./$(printf '\033[32m.\033[0m')/g" \
-e "1 s/S/$(printf '\033[33mS\033[0m')/g" \
-e "1 s/F/$(printf '\033[31mF\033[0m')/g" \
-e "s/^(FAILED.*)$/$(printf '\033[31m\\1\033[0m')/" \
-e "s/^(OK.*)$/$(printf '\033[32m\\1\033[0m')/"
}
verbose() {
sed -E \
-e "s/^(.*\.\.\. ok)$/$(printf '\033[32m\\1\033[0m')/" \
-e "s/^(.*\.\.\. SKIP: .*)$/$(printf '\033[33m\\1\033[0m')/" \
-e "s/^(.*\.\.\. FAIL)$/$(printf '\033[31m\\1\033[0m')/" \
-e "s/^(FAILED.*)$/$(printf '\033[31m\\1\033[0m')/" \
-e "s/^(OK.*)$/$(printf '\033[32m\\1\033[0m')/"
}
VERBOSE=
for arg in $@; do
if [[ "$arg" = "-v" ]]; then
VERBOSE=1
fi
done
if [[ "$VERBOSE" ]]; then
nosetests "$@" 2>&1| verbose
else
nosetests "$@" 2>&1| simple
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment