#!/bin/bash function die { echo "$1" exit 1 } if [[ $# -ne 1 ]]; then die "$0 " fi BASE=mobuko0.pl PROG=$1 perl -c -w $BASE > /dev/null 2>&1 || die "$BASE contains contains syntax errors" perl -c -w $PROG > /dev/null 2>&1 || die "$PROG contains contains syntax errors" OUTPUT_BASE=$(perl $BASE testdata/test_00.txt) OUTPUT_TEST=$(perl $PROG testdata/test_00.txt) if [[ "$OUTPUT_BASE" != "$OUTPUT_TEST" ]]; then die "$LINENO: Single file test failed" fi OUTPUT_BASE=$(perl $BASE testdata/*.txt) OUTPUT_TEST=$(perl $PROG testdata/*.txt) if [[ "$OUTPUT_BASE" != "$OUTPUT_TEST" ]]; then die "$LINENO: Multi file test failed" fi OUTPUT_BASE=$(perl $BASE testdata/*.txt | perl $BASE -c) OUTPUT_TEST=$(perl $PROG testdata/*.txt | perl $PROG -c) if [[ "$OUTPUT_BASE" != "$OUTPUT_TEST" ]]; then die "$LINENO: Validation failed" fi OUTPUT_BASE=$(perl $BASE testdata/test_00.txt | sed -e 's/test_00/test_0f/' | perl $BASE -c 2>&1) OUTPUT_TEST=$(perl $PROG testdata/test_00.txt | sed -e 's/test_00/test_0f/' | perl $PROG -c 2>&1) if [[ "$OUTPUT_BASE" != "$OUTPUT_TEST" ]]; then die "$LINENO: Error detection failed" fi echo "$0: OK" exit 0