>From 965a01bfaf129b4d1da8d0927a9149e4c4145ff3 Mon Sep 17 00:00:00 2001 From: "A. Gordon" Date: Fri, 24 Jan 2014 13:39:14 -0500 Subject: [PATCH] scripts: add check_program, to run tests easily * scripts/check_program: New script, so you can easily run all tests relating to a certain program. Takes less time than checking all programs with 'make check', and quicker to type than 'make check TESTS=TEST1,TEST2,TEST3' for multiple tests. --- scripts/check_program | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 scripts/check_program diff --git a/scripts/check_program b/scripts/check_program new file mode 100755 index 0000000..f38e410 --- /dev/null +++ b/scripts/check_program @@ -0,0 +1,70 @@ +#!/bin/sh +# A small helper script to run multiple tests at once. +# example: +# ./scripts/check_program sort +# would run all 'sort' related tests under ./tests/ + +# Written by Assaf Gordon + +# allow the user to override 'make' +MAKE=${MAKE-make} + +VERSION='2014-01-24 00:37:51' # UTC + +prog_name=`basename $0` +die () { echo "$prog_name: $*" >&2; exit 1; } + +usage() { + echo >&2 "\ +Usage: $0 [OPTION] PROGRAM +Runs all tests for PROGRAM + +Options: + -e run EXPENSIVE tests + -v run EXPENSIVE and VERY_EXPENSIVE tests + -h display this help and exit + +Examples: +To run all (non-expensive) tests for 'uniq': + + $0 uniq + +To run all (including expensive and very expensive) tests for 'sort': + + $0 -v sort + +" +} + +RUN_EXPENSIVE_TESTS=no +RUN_VERY_EXPENSIVE_TESTS=no +while getopts :evh name +do + case $name in + (v) RUN_VERY_EXPENSIVE_TESTS=yes;RUN_EXPENSIVE_TESTS=yes;; + (e) RUN_EXPENSIVE_TESTS=yes;; + (h) usage; exit 0 ;; + (--) shift ; break ;; + (*) die "Unknown option '$OPTARG'" ;; + esac + shift +done + +PROGRAM=$1 +[ -z "$PROGRAM" ] && die "missing PROGRAM name. See '-h' for help." + + +[ -d "./tests" ] || die "'tests/' directory not found." \ + "Please run this script from the" \ + "main directory of 'Coreutils'." + +TESTS=$(find ./tests/ \( -name '*.sh' -o -name '*.pl' \) -print | \ + grep -w -- "$PROGRAM" | paste -s -d' ') +[ -z "$TESTS" ] && die "no tests found for '$PROGRAM'" + +echo "Running the following tests for '$PROGRAM':" +echo "$TESTS" | tr ' ' '\n' | sed 's/^/ /' + +$MAKE check TESTS="$TESTS" VERBOSE=yes SUBDIRS=. \ + RUN_EXPENSIVE_TESTS=$RUN_EXPENSIVE_TESTS \ + RUN_VERY_EXPENSIVE_TESTS=$RUN_VERY_EXPENSIVE_TESTS -- 1.8.4.3