Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
4.3 kB · 177 lines
at develop
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178#!/bin/bash# vim: ft=sh ts=4 sw=4 et## usage: run-tests <prog> <suffix> [<dirname> ...]## Find the test cases in <dirname> ... and subdirectories thereof and run# them with 'run-test <prog> <testcase>'. Failing test cases are summarised# in a FAILURES.<prog> file.## A test case is either <model><suffix> or <model>.<testid>.dzn# where there is a corresponding <model><suffix> file.## Note that if a model file does not contain a comment of the form# 'RUNS ON <prog>' then the test case will be skipped. Ignored test# cases are summarised in an IGNORED.<prog> file.# If the environment variable FORCE_DELAY is set then a small delay# will be introduced between each test case. This is useful for# avoid resource limits on Mac OS X, usually indicated by the following# error message:## fork: Resource temporarily unavailable# Uncomment the next line for debugging:# set -x# The name of this program as invoked.#THIS=$(basename $0)THISDIR="$(pwd)"# if [ $# -lt 2 ]then echo "usage: $THIS <prog> <suffix> [<dirname> ...]" >&2 exit 1fiPROG=$1SUFFIX=$2shift 2DIRS=$@[ -z "$DIRS" ] && DIRS=.BASEPROG=$(basename $PROG)FAILURES="$(pwd)/FAILURES.$BASEPROG"IGNORES="$(pwd)/IGNORED.$BASEPROG"RUNSONREGEX="\<RUNS *ON *$BASEPROG\>"# Clear out any old IGNORES and FAILURES files.#rm -f "$IGNORES" "$FAILURES"NTESTS=0# Count number of testsfor FILENAME in $(find $DIRS -name '*'$SUFFIX -o -name '*.dzn' | sort)do # Skip this file if there's a corresponding .dzn file or # it is a .dzn file, but doesn't have the corresponding $SUFFIX file. # case $FILENAME in *.dzn) # Ignore .dzn files that don't have a model file with # the right suffix. MODELNAME=$(echo $FILENAME | sed 's/[.].*//')$SUFFIX if [ ! -e $MODELNAME ] then continue fi ;; *) # Ignore model files that have one or more .dzn files. BASENAME=$(basename $FILENAME $SUFFIX) if ls $BASENAME'*.dzn' >/dev/null 2>&1 then continue fi ;; esac NTESTS=$((NTESTS+1)) doneecho "<testsuite name=\"$BASEPROG\" tests=\"$NTESTS\">"NTESTS=0NFAIL=0# Find all applicable test cases.#for FILENAME in $(find $DIRS -name '*'$SUFFIX -o -name '*.dzn' | sort)do # Return to the directory where we began. # cd "$THISDIR" >/dev/null 2>&1 # cd to the directory of the problem file. # DIR=$(dirname $FILENAME) if [ -n "$DIR" ] then cd $DIR >/dev/null 2>&1 FILENAME=$(basename $FILENAME) fi # Skip this file if there's a corresponding .dzn file or # it is a .dzn file, but doesn't have the corresponding $SUFFIX file. # case $FILENAME in *.dzn) # Ignore .dzn files that don't have a model file with # the right suffix. MODELNAME=$(echo $FILENAME | sed 's/[.].*//')$SUFFIX if [ ! -e $MODELNAME ] then continue fi MODELFILE=$MODELNAME ;; *) # Ignore model files that have one or more .dzn files. BASENAME=$(basename $FILENAME $SUFFIX) if ls $BASENAME'*.dzn' >/dev/null 2>&1 then continue fi MODELFILE=$FILENAME ;; esac # Ignore model files that don't contain the # string 'RUNS ON $BASEPROG'. if ! grep -q "$RUNSONREGEX" $MODELFILE then echo "$DIR/$FILENAME" >> "$IGNORES" continue fi # Run the test. # echo "<testcase name=\"$FILENAME\" classname=\"none\" >" PASSFAIL=fail run-test $PROG $FILENAME >test_stdout 2>&1 && PASSFAIL=pass if [ $PASSFAIL = "fail" ] then echo "<failure message=\"test failed\"></failure>" fi echo "<system-out>" echo "<![CDATA[" cat test_stdout echo "]]>" echo "</system-out>" echo "</testcase>" NTESTS=$((NTESTS+1)) if test $FORCE_DELAY then sleep 1 fi # Return to the directory where we began. # cd "$THISDIR" >/dev/null 2>&1 if [ $PASSFAIL = "fail" ] then NFAIL=$((NFAIL+1)) echo "$DIR/$FILENAME ($PROG)" >> "$FAILURES" fidoneecho "</testsuite>"