Created
May 13, 2016 18:54
-
-
Save mikeerickson/4e11fe78f24a91ce8c4724f85d08b690 to your computer and use it in GitHub Desktop.
Test Runner (allows defining number of iterations and optional reporters)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # syntax | |
| # $ ./test.sh -n # -q # | true | |
| # script colors | |
| YELLOW='\033[1;33m' | |
| LIGHTBLUE='\033[1;36m' | |
| GREEN='\033[1;32m' | |
| NC='\033[0m' | |
| RESET='\033[0m' | |
| # set default values (will be updated by getopts) | |
| ITERATIONS=1 | |
| QUIET=-1 | |
| REPORTER='mocha' | |
| while getopts ":n:q:r:" opt; do | |
| case $opt in | |
| q) QUIET=$OPTARG;; | |
| n) ITERATIONS=$OPTARG;; | |
| r) REPORTER=$OPTARG;; | |
| \?) | |
| # echo "Invalid option: -$OPTARG" >&2 ;; | |
| esac | |
| done | |
| # coerce QUIET if we passed true | false | |
| if [ $QUIET = 'true' ]; then QUIET=1; fi | |
| if [ $QUIET = 'false' ]; then QUIET=0; fi | |
| printf "\n" | |
| for (( index=1; index<=ITERATIONS; index++ )) | |
| do | |
| if [ $QUIET -ne 1 ]; then | |
| if [ $REPORTER != 'dots' ]; then | |
| printf "\n\n [${LIGHTBLUE} running ${RESET}] ${YELLOW} Running Test $index of ${ITERATIONS} ... ${RESET}\n\n" | |
| fi | |
| fi | |
| if [ $REPORTER = 'dots' ]; then | |
| karma start --reporters super-dots | |
| else | |
| karma start | |
| fi | |
| if [ $QUIET -ne 1 ]; then | |
| if [ $REPORTER = 'dots' ]; then | |
| printf "\n\n" | |
| else | |
| printf "\n [${GREEN} complete ${RESET}] ${YELLOW} Completed $index of ${ITERATIONS} ... ${RESET}\n" | |
| fi | |
| fi | |
| done | |
| timestamp=`date +"%Y.%m.%d %H:%M:%S"` | |
| if [ $ITERATIONS > 0 ]; then | |
| printf "\n\n" | |
| printf "${GREEN}====================================================================================================\n\n" | |
| printf "${GREEN} === [${ITERATIONS}] Test(s) Processed [${timestamp}] ${RESET}\n\n" | |
| printf "\n" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment