test.sh (1228B)
1 #!/bin/bash 2 3 # Copyright (c) Microsoft Corporation. 4 # Licensed under the MIT License. 5 6 # Synopsis: Simplifies test commands for the SFS Client. 7 # 8 # Description: This script will contain the test commands for the SFS Client. 9 # Use this on non-Windows platforms in a bash session. 10 # 11 # Example: 12 # $ ./scripts/test.sh 13 # 14 15 # Ensures script stops on errors 16 set -e 17 18 if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then 19 error "Script is being sourced, it should be executed instead." 20 return 1 21 fi 22 23 output_on_failure=false 24 25 usage() { echo "Usage: $0 [--output-on-failure]" 1>&2; exit 1; } 26 27 if ! opts=$(getopt \ 28 --longoptions "output-on-failure" \ 29 --name "$(basename "$0")" \ 30 --options "" \ 31 -- "$@" 32 ); then 33 usage 34 fi 35 36 eval set "--$opts" 37 38 while [ $# -gt 0 ]; do 39 case "$1" in 40 --output-on-failure) 41 output_on_failure=true 42 shift 1 43 ;; 44 *) 45 break 46 ;; 47 esac 48 done 49 50 script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" 51 git_root=$(git -C "$script_dir" rev-parse --show-toplevel) 52 build_folder="$git_root/build" 53 54 cmd="ctest --test-dir \"$build_folder/client\"" 55 56 if $output_on_failure ; then 57 cmd+=" --output-on-failure" 58 fi 59 60 eval "$cmd"