Gilad Arnold | 744da57 | 2012-10-03 23:21:28 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
Gilad Arnold | a9cf3c5 | 2013-02-12 18:42:54 | [diff] [blame] | 7 | # Runs *_unittest.py modules. |
Gilad Arnold | 744da57 | 2012-10-03 23:21:28 | [diff] [blame] | 8 | |
| 9 | set -e |
| 10 | |
| 11 | # Display help/usage message. |
| 12 | usage() { |
| 13 | cat <<EOF |
| 14 | Usage: ${0##*/} [OPTION]... |
| 15 | Options: |
| 16 | -f force running all unit test modules, regardless of failure |
| 17 | -h display this help and exit |
| 18 | EOF |
| 19 | } |
| 20 | |
| 21 | # Parse command-line options. |
| 22 | while getopts ":fh" opt; do |
| 23 | case $opt in |
| 24 | f) |
| 25 | force_all=1 |
| 26 | ;; |
| 27 | h) |
| 28 | usage |
| 29 | exit |
| 30 | ;; |
| 31 | \?) |
| 32 | echo "Invalid option: -$OPTARG" >&2 |
| 33 | exit 1 |
| 34 | ;; |
| 35 | esac |
| 36 | done |
| 37 | |
| 38 | shift $((OPTIND-1)) |
| 39 | if [[ $# > 0 ]]; then |
| 40 | echo "Invalid argument: $1" |
| 41 | exit 1 |
| 42 | fi |
| 43 | |
| 44 | # Invoke unit test scripts. |
| 45 | for unittest_script in *_unittest.py; do |
Chris Sosa | 1885d03 | 2012-11-30 01:07:27 | [diff] [blame] | 46 | echo "Running $unittest_script": |
Gilad Arnold | 744da57 | 2012-10-03 23:21:28 | [diff] [blame] | 47 | ./${unittest_script} || test ${force_all} || break |
| 48 | done |