#!/bin/sh

for test_file in "$@"; do
    test -f "$test_file" || continue
    while IFS= read -r line; do
        case "$line" in
            bats_load_library\ bats-*)
                library=${line#bats_load_library }
                found=no
                old_ifs=$IFS
                IFS=:
                for directory in $BATS_LIB_PATH; do
                    test -f "$directory/$library/load.bash" || continue
                    found=yes
                    break
                done
                IFS=$old_ifs
                test "$found" = yes || exit 1
                ;;
        esac
    done < "$test_file"
done

exit 0
