#!/usr/bin/env bash
# -*- shell-script -*-
t=${0##*/}; TEST_NAME=${t:5}   # basename $0 with 'test-' stripped off

[[ -z "$builddir" ]] && export builddir=$PWD

. ${builddir}/check-common.sh

debugged_script="$top_srcdir/test/example/fib.sh"

FILTERED_TEST_FILE="/tmp/${TEST_NAME}-filtered.check"

typeset short_test_name='bug-break'

typeset dbg_opts="-L ${top_srcdir} $run_debugger_opts"
typeset cmdfile="${top_srcdir}/test/data/${short_test_name}.cmd"

(cd $srcdir && run_debugger "$debugged_script" "$dbg_opts" "$cmdfile" 2>&1 >$TEST_FILE </dev/null)

cat $TEST_FILE | @SED@ -e "s:main(.*) called from file \`bashdb' at line 0:main() called from file \`bashdb' at line 0:" \
 >${FILTERED_TEST_FILE}

check_output $FILTERED_TEST_FILE $RIGHT_FILE
rc=$?

((0 != rc)) && exit $rc
rm $TEST_FILE

# Return code tells testing mechanism whether passed or not.
exit 0
