Skip to content

Instantly share code, notes, and snippets.

@josefdlange
Last active December 10, 2015 23:41
Show Gist options
  • Select an option

  • Save josefdlange/32be51f1efa9ec28bbba to your computer and use it in GitHub Desktop.

Select an option

Save josefdlange/32be51f1efa9ec28bbba to your computer and use it in GitHub Desktop.
Show an OS X Notification when tests are complete
#!/bin/bash
# Run your tests and throw the return code into a variable.
RESULT=$(python -m tests.__init__ $1)
# Only if osascript exists (AKA only on OS X)
if type "osascript" > /dev/null; then
SUCCESS="Successful"
MESSAGE="All Tests Complete"
# If there were test parameters passed in via args..
if ! [ -z "$1" ]; then
MESSAGE="Tests ($1) Complete.";
fi
# Check success (a well-behaved test runner of course exits 0 on success, non-zero on fail)
if [ $TEST_RESULT -ne 0 ]; then
SUCCESS="FAILED"
fi
osascript -e "display notification with title \"Tests $SUCCESS\" subtitle \"$MESSAGE\" sound name \"Glass\""
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment