#!/bin/sh

. ./test_helper.sh

top_source_dir=$(pwd)

# Executed either by debian/tests/control or by Makefile.
if [ -n "${AUTOPKGTEST_TMP:-}" ]; then
    tested_command='dh_builtusing -v'
    test_dir="$AUTOPKGTEST_TMP"
else
    rm -fr obj/unit-tests
    mkdir -p obj/unit-tests
    tested_command="perl $top_source_dir/dh_builtusing -v"
    test_dir="$top_source_dir/obj"
fi

for script in unit-tests/*; do
    case $script in
        *~) continue ;;
    esac

    echo "Running $script"

    test_subdir="$test_dir/$script"
    mkdir -p "$test_subdir"
    cd       "$test_subdir"

    . "$top_source_dir/$script"

    echo "OK: $script"
done
