#!/bin/sh -e

biocname=snpStats
pkg=r-bioc-`echo $biocname | tr '[A-Z]' '[a-z]'`

if [ "$AUTOPKGTEST_TMP" = "" ] ; then
  AUTOPKGTEST_TMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
fi
cd $AUTOPKGTEST_TMP
cp /usr/share/doc/$pkg/examples/vignettes/* $AUTOPKGTEST_TMP
find . -name "*.gz" -exec gunzip \{\} \;
export LC_ALL=C
for rnw in *.Rnw ; do
    echo "====================== $rnw ============================"
    rfile=`basename $rnw nw`
    if [ "$rnw" = "imputation-vignette.Rnw" ] ; then # -o "$rnw" = "ld-vignette.Rnw" ]
        echo "Test "$rnw" needs r-cran-hexbin which is not yet packaged."
    else
        if [ "$rnw" = "snpStats-vignette.Rnw" ] ; then
            echo "Test $rnw needs allest[""rs10882596""] but it is not clear where to get this."
        else
            R --no-save <<EOT
                Stangle("$rnw")
                source("$rfile", echo=TRUE)
EOT
        fi
    fi
done

