view admin/mktests.sh @ 12718:1af86934c14e octave-forge

Make compatible with Octaves new exception-based error handling. Retain compatibility with Octaves old error handling based on error_state. * src/error_helpers.[h,cc]: Added. * src/Makefile.in: Integrate error-helpers.[h,cc]. * src/config.h.in: Added. * configure.ac, src/config.h.in: Test presence of 'error_state' and presence of 'verror (octave_execution_exception&, const char *, va_list)'. * src/__pq_connect__.cc, src/command.cc, src/command.h, src/converters.cc, src/converters_arr_comp.cc, src/pq_connection.cc, src/pq_conninfo.cc, src/pq_exec.cc, src/pq_lo.cc, src/pq_update_types.cc: If necessary, include error-helpers.h, replace error() with c_verror(), set and check a different error indicator than error_state, use CHECK_ERROR or SET_ERR, explicitely check for errors instead of relying on Octave checking error_state when returning to the prompt.
author i7tiol
date Sat, 27 Feb 2016 11:11:04 +0000
parents 185c49a73acc
children
line wrap: on
line source

#! /bin/sh

# Root of the search
root=`pwd`

# Create a new fntests.m file
echo "fid=fopen('fntests.log','wt');" > fntests.m
echo "if fid<0,error('could not open fntests.log for writing');end" >>fntests.m
echo "test('','explain',fid);" >> fntests.m
echo "passes=0; tests=0;" >>fntests.m

# Find all toplevel non-svn directories
DIRS="`find $* -type d ! -name .svn`"

# Find the tests in that directory
for dir in $DIRS; do
    dir=`echo $dir | sed -e "s-^\./--" `

    # skip the NOINSTALL directories
    if test -f "$dir/NOINSTALL"; then continue; fi

    # Build a list of possible test files
    FILES=""

    # Find all .cc files
    cxx_files=`echo $dir/*.cc`
    if test "$cxx_files" != "$dir/*.cc"; then FILES="$FILES $cxx_files"; fi

    # Find all m-files
    m_files=`echo $dir/*.m`
    if test "$m_files" != "$dir/*.m"; then FILES="$FILES $m_files"; fi

    # No C++ of m-files, so no testing
    if test -z "$FILES" ; then continue; fi

    # Find all files with %!test or %!assert in them
    # XXX FIXME XXX is there a system independent way of doing (test|assert)
    TESTS=`grep -l -E '^%![ta][es]s' $FILES`

    NUMFILES=`echo $FILES | wc -w`
    NUMTESTS=`echo $TESTS | wc -w`
    prompt="$dir [tests $NUMTESTS of $NUMFILES files]"

    # if no files have tests in them, skip
    echo "printf('%s','$prompt'); disp('');" >>fntests.m
    if test -z "$TESTS" ; then
	echo "printf('%-40s ---> success','');disp('');" >>fntests.m
    else 
	echo "dp=dn=0;" >>fntests.m
	for file in $TESTS ; do
            echo "[p,n] = test('$root/$file','quiet',fid);" >>fntests.m
            echo "dp += p; dn += n;" >>fntests.m
	done
	echo "if dp==dn, printf('%-40s ---> success',''); else" >>fntests.m
        echo "printf('%-40s ---> passes %d out of %d tests','',dp,dn); end" >>fntests.m
        echo "disp(''); passes += dp; tests += dn;" >>fntests.m
    fi

done

echo "printf('passes %d out of %d tests',passes,tests);disp('');" >> fntests.m
echo "fclose(fid);" >> fntests.m