Some (about 20%) of .spkg files in Sage have a file spkg-check, which runs a test suite if one runs

$ export SAGE_CHECK=yes
$ make

About 80% of Sage packages do not have an spkg-check file, which means the code can't be tested even if there is a test suite. I added a few spkg-check files which got merged in 4.4.4, but there are still tons missing, and adding them is really boring. But if you are updating a package, it is not so bad to spend a few minutes and add it.

Not all the upstream code has test code unfortunately.

A typical content would be that below. Running just 'make test' will sometimes fail unless the compiler flags are set correctly. On other packages, it does not matter, but it is safest to assume it does matter - it depends on whether or not 'make test' or 'make check' needs anything to be compiled or not.

Of course, doc tests do perform tests in Sage, but they rarely extend to testing much of the packages in Sage.

Dave

--------------
A typical spkg-check, which needs to go into the same directory as spkg-install and SPKG.txt is below.

#!/usr/bin/env bash


if [ -z $SAGE_LOCAL ]; then
   echo "SAGE_LOCAL undefined ... exiting";
   echo "Maybe run 'sage -sh'?"
   exit 1
fi


# Let the user set an environment variable CFLAG64 to indicate the flag
# for the C compiler to build 64-bit code. If not set, assume it is -m64
# as that is what is used by both GCC and SunStudio, but -m64 is not used
# by IBM's compiler on AIX or HP's compiler on HP-UX

if [ -z $CFLAG64 ] ; then
  CFLAG64=-m64 # -m64 is used by gcc and SunStudio.
fi

# Likewise to build C++ code.
if [ -z $CXXFLAG64 ] ; then
  CXXFLAG64=-m64 # -m64 is used by gcc and SunStudio.
fi

if [ "x$SAGE64" = xyes ] ; then
   CFLAGS="$CFLAGS $CFLAG64" && export CFLAGS
   CXXFLAGS="$CXXFLAGS $CXXFLAG64" && export CXXFLAGS
   LDFLAGS="$LDFLAGS $CFLAG64" && export LDFLAGS
   CPPFLAGS="$CPPFLAGS $CFLAG64" && export CPPFLAGS # Very rare is CPPFLAGS nee
ded, but sometimes it is.
fi

cd src

echo "FOOBAR will now be tested"

make check # It might be 'make test' in some cases.

if [ $? -ne 0 ]; then
    echo "An error occurred whilst testing FOOBAR"
    exit 1
fi

--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to