Commit e1c180ad authored by Liubov Chuprikova's avatar Liubov Chuprikova
Browse files

Add an autopkgtest

parent eb8ce738
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
Tests: run-unit-test
Depends: @
Depends: @, unicycler-data
Restrictions: allow-stderr
+30 −8
Original line number Diff line number Diff line
#!/bin/bash
set -e

pkg=#PACKAGENAME#
test_pkg=dnaio
# using these data for testing
source_pkg=unicycler-data

if [ "${AUTOPKGTEST_TMP}" = "" ] ; then
  AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
  # Double quote below to expand the temporary directory variable now versus
  # later is on purpose.
  # shellcheck disable=SC2064
  AUTOPKGTEST_TMP=$(mktemp -d /tmp/${test_pkg}-test.XXXXXX)
  trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
fi

cp -a /usr/share/doc/${pkg}/examples/* "${AUTOPKGTEST_TMP}"
if [ -d /usr/share/${source_pkg}/sample_data ] ; then
  cp -a /usr/share/${source_pkg}/sample_data/ ${AUTOPKGTEST_TMP}
else
  echo "Please install package unicycler-data to run this script"
  exit 1
fi

cd ${AUTOPKGTEST_TMP}

cat > simple_test.py << EOL
import os
import dnaio

dir = 'sample_data'

for filename in os.listdir(dir):
    print(filename)
    with dnaio.open(dir + '/' + filename) as inf:
        bp = 0
        for record in inf:
            bp += len(record)
    print(f'The input file contains {bp/1E6:.1f} Mbp')
EOL

cd "${AUTOPKGTEST_TMP}"
# run test
python3 ./simple_test.py

#do_stuff_to_test_package#
echo "PASS"