[med-svn] [Git][med-team/andi][master] 3 commits: Adds autopkgtest

Fabian Klötzl gitlab at salsa.debian.org
Sun Apr 5 17:18:18 BST 2020



Fabian Klötzl pushed to branch master at Debian Med / andi


Commits:
d8d6a488 by Samyak Jain at 2020-03-07T18:23:04+05:30
Adds autopkgtest

- - - - -
c8fcfded by Fabian Klötzl at 2020-04-05T17:30:32+02:00
Merge branch 'master' of https://salsa.debian.org/med-team/andi

- - - - -
c7d25761 by Fabian Klötzl at 2020-04-05T18:14:58+02:00
add autopkgtest

The shell scripts from test/*.sh can be used as autopkgtests. Some
modifications had to be made to adapt them to the different directory
layout.

- - - - -


7 changed files:

- debian/changelog
- + debian/tests/control
- + debian/tests/extra.sh
- + debian/tests/join.sh
- + debian/tests/lowhomo.sh
- + debian/tests/nan.sh
- + debian/tests/random.sh


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,12 @@
+andi (0.13-2) UNRELEASED; urgency=medium
+
+  * Team upload
+
+  [Fabian Klötzl]
+  * Adds autopkgtests
+
+ -- Fabian Klötzl <kloetzl at evolbio.mpg.de>  Sun, 05 Apr 2020 18:00:44 +0200
+
 andi (0.13-1) unstable; urgency=medium
 
   * Team upload
@@ -9,6 +18,7 @@ andi (0.13-1) unstable; urgency=medium
   * New upstream version 0.13
   * Bumps standard version and remove d/compat (use debhelper-compat instead)
   * Drop unwanted patches
+  * Adds autopkgtest
 
   [ Andreas Tille ]
   * Fix edam syntax input+output is singular


=====================================
debian/tests/control
=====================================
@@ -0,0 +1,3 @@
+Tests: extra.sh join.sh lowhomo.sh nan.sh random.sh
+Depends: @
+Restrictions: allow-stderr


=====================================
debian/tests/extra.sh
=====================================
@@ -0,0 +1,60 @@
+#!/bin/sh -f
+
+# copied and enhanced from upstream
+
+set -e
+pkg=andi
+
+export LC_ALL=C.UTF-8
+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
+  trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
+fi
+
+cp test/test_fasta.cxx "${AUTOPKGTEST_TMP}"
+
+cd "${AUTOPKGTEST_TMP}"
+
+g++ -O2 -Wall -o test_fasta test_fasta.cxx
+RANDOM_SEED=1729
+
+
+
+#--- only small changes below ---
+
+# Test if andi exists, and can be executed
+andi --version > /dev/null || exit 1
+
+SEED=${RANDOM_SEED:-0}
+SEED2=0
+SEED3=0
+if test $SEED -ne 0; then
+        SEED=$((SEED + 1))
+        SEED2=$((SEED + 2))
+        SEED3=$((SEED + 3))
+fi
+
+# Test andi for more than just two sequences at a time
+./test_fasta -s $SEED -l 100000 -d 0.01 -d 0.01 -d 0.01 -d 0.01 | andi > /dev/null || exit 1
+
+# Test low-memory mode
+./test_fasta -s $SEED2 -l 10000 > test_extra.fasta
+andi test_extra.fasta > extra.out
+andi test_extra.fasta --low-memory > extra_low_memory.out
+diff extra.out extra_low_memory.out || exit 1
+
+# Test file of filenames
+./test_fasta -s $SEED3 -l 10000 > test_extra.fasta
+echo "$PWD/test_extra.fasta" > fof.txt
+andi test_extra.fasta > extra.out
+andi --file-of-filenames fof.txt > fof.out
+cat fof.txt | andi --file-of-filenames - > fof2.out
+diff extra.out fof.out || exit 1
+diff extra.out fof2.out || exit 1
+
+
+rm -f test_extra.fasta extra.out extra_low_memory.out fof.out fof2.out fof.txt
+


=====================================
debian/tests/join.sh
=====================================
@@ -0,0 +1,124 @@
+#!/bin/sh -f
+
+# copied and enhanced from upstream
+
+set -e
+pkg=andi
+
+export LC_ALL=C.UTF-8
+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
+  trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
+fi
+
+cp test/test_fasta.cxx "${AUTOPKGTEST_TMP}"
+
+cd "${AUTOPKGTEST_TMP}"
+
+g++ -O2 -Wall -o test_fasta test_fasta.cxx
+RANDOM_SEED=1729
+
+
+
+#--- only small changes below ---
+
+andi --help > /dev/null || exit 1
+
+SEED=${RANDOM_SEED:-0}
+SEED2=0
+SEED3=0
+if test $SEED -ne 0; then
+        SEED=$((SEED + 1))
+        SEED2=$((SEED + 2))
+        SEED3=$((SEED + 3))
+fi
+
+# Simple join test
+./test_fasta -s $SEED -l 1000 -L 1000 -d 0.1 > p1_join.fasta
+./test_fasta -s $SEED2 -l 1000 -L 1000 -d 0.1 > p2_join.fasta
+./test_fasta -s $SEED3 -l 10000 -L 10000 -d 0.1 > p3_join.fasta
+
+head -qn 2 p1_join.fasta p2_join.fasta p3_join.fasta > S0_join.fasta
+tail -qn 2 p1_join.fasta p2_join.fasta p3_join.fasta > S1_join.fasta
+
+rm p1_join.fasta p2_join.fasta p3_join.fasta;
+
+
+RES=$(andi -m RAW -t 1 -j S0_join.fasta S1_join.fasta |
+	tail -n 1 |
+	awk '{print ($2 - 0.1)}' |
+	awk 'function abs(x){return ((x < 0.0) ? -x : x)} {print abs($1-$2) < 0.03}'
+	)
+
+if test $RES -ne 1; then
+	echo "The last test computed a distance deviating more than three percent from its intended value."
+	echo "See S0_join.fasta and S1_join.fasta for the used sequences."
+	exit 1;
+fi
+
+SEED=${RANDOM_SEED:-0}
+SEED2=0
+if test $SEED -ne 0; then
+        SEED=$((SEED + 5))
+        SEED2=$((SEED + 6))
+fi
+
+#unbalanced number of contigs
+./test_fasta -s $SEED -l 1000 -L 1000 -d 0.1 > p2_join.fasta
+./test_fasta -s $SEED2 -l 10000 -L 10000 -d 0.1 > p3_join.fasta
+
+head -qn 2 p3_join.fasta > S0_join.fasta
+tail -qn 2 p2_join.fasta p3_join.fasta > S1_join.fasta
+
+rm p2_join.fasta p3_join.fasta;
+
+
+RES=$(andi -m RAW -t1 -j S0_join.fasta S1_join.fasta |
+        tail -n 1 |
+        awk '{print ($2 - 0.1)}' |
+        awk 'function abs(x){return ((x < 0.0) ? -x : x)} {print abs($1-$2) < 0.03}'
+        )
+
+if test $RES -ne 1; then
+        echo "The last test computed a distance deviating more than three percent from its intended value."
+        echo "See S0_join.fasta and S1_join.fasta for the used sequences."
+        exit 1;
+fi
+
+SEED=${RANDOM_SEED:-0}
+SEED2=0
+SEED3=0
+if test $SEED -ne 0; then
+        SEED=$((SEED + 11))
+        SEED2=$((SEED + 12))
+        SEED3=$((SEED + 13))
+fi
+
+#unbalanced number of contigs 2
+./test_fasta -s $SEED -l 1000 -L 1000 -d 0.1 > p1_join.fasta
+./test_fasta -s $SEED2 -l 1000 -L 1000 -d 0.1 > p2_join.fasta
+./test_fasta -s $SEED3 -l 10000 -L 10000 -d 0.1 > p3_join.fasta
+
+head -qn 2 p1_join.fasta p3_join.fasta > S0_join.fasta
+tail -qn 2 p1_join.fasta p2_join.fasta p3_join.fasta > S1_join.fasta
+
+rm p1_join.fasta p2_join.fasta p3_join.fasta;
+
+
+RES=$(andi -mRAW -t 1 -j S0_join.fasta S1_join.fasta |
+        tail -n 1 |
+        awk '{print ($2 - 0.1)}' |
+        awk 'function abs(x){return ((x < 0.0) ? -x : x)} {print abs($1-$2) < 0.03}'
+        )
+
+if test $RES -ne 1; then
+        echo "The last test computed a distance deviating more than three percent from its intended value."
+        echo "See S0_join.fasta and S1_join.fasta for the used sequences."
+        exit 1;
+fi
+
+
+rm S0_join.fasta S1_join.fasta


=====================================
debian/tests/lowhomo.sh
=====================================
@@ -0,0 +1,54 @@
+#!/bin/sh -f
+
+# copied and enhanced from upstream
+
+set -e
+pkg=andi
+
+export LC_ALL=C.UTF-8
+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
+  trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
+fi
+
+cp test/test_fasta.cxx "${AUTOPKGTEST_TMP}"
+
+cd "${AUTOPKGTEST_TMP}"
+
+g++ -O2 -Wall -o test_fasta test_fasta.cxx
+RANDOM_SEED=1729
+
+
+
+#--- only small changes below ---
+
+SEED=${RANDOM_SEED:-0}
+SEED2=0
+SEED3=0
+if test $SEED -ne 0; then
+	SEED=$((SEED + 1))
+	SEED2=$((SEED + 2))
+	SEED3=$((SEED + 3))
+fi
+
+./test_fasta -s $SEED -l 100000 > a_low.fa
+./test_fasta -s $SEED2 -l 100000 > b_low.fa
+./test_fasta -s $SEED3 -l 100 > both_low.fa
+
+cat both_low.fa a_low.fa | awk -v RS='>' '{if($1 == "S0")print ">"$0 > "S0_low.fa"}'
+cat both_low.fa b_low.fa | awk -v RS='>' '{if($1 == "S1")print ">"$0 > "S1_low.fa"}'
+
+# this is expected to trigger the low homology warning
+andi -j S0_low.fa S1_low.fa 2>&1 | grep 'homology'
+EXIT_VAL=$?
+
+if [[ EXIT_VAL -ge 1 ]]; then
+	echo "Triggering low homology failed" >&2
+	grep '^>' a_low.fa b_low.fa both_low.fa
+fi
+
+rm -f a_low.fa b_low.fa both_low.fa S0_low.fa S1_low.fa
+exit $EXIT_VAL


=====================================
debian/tests/nan.sh
=====================================
@@ -0,0 +1,50 @@
+#!/bin/sh -f
+
+# copied and enhanced from upstream
+
+set -e
+pkg=andi
+
+export LC_ALL=C.UTF-8
+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
+  trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
+fi
+
+cp test/test_fasta.cxx "${AUTOPKGTEST_TMP}"
+
+cd "${AUTOPKGTEST_TMP}"
+
+g++ -O2 -Wall -o test_fasta test_fasta.cxx
+RANDOM_SEED=1729
+
+
+
+#--- only small changes below ---
+
+SEED=${RANDOM_SEED:-0}
+SEED2=0
+if test $SEED -ne 0; then
+	SEED=$((SEED + 1))
+	SEED2=$((SEED + 2))
+fi
+
+
+./test_fasta -s $SEED -l 10000 > a_nan.fa
+./test_fasta -s $SEED2 -l 10000 > b_nan.fa
+
+# this is expected to trigger the nan warning
+andi -j a_nan.fa b_nan.fa 2>&1 | grep 'nan'
+EXIT_VAL=$?
+
+
+if [ $EXIT_VAL -ge 1 ]; then
+	echo "Triggering nan failed" >&2
+	grep '^>' a_nan.fa b_nan.fa
+fi
+
+rm -f a_nan.fa b_nan.fa
+exit $EXIT_VAL


=====================================
debian/tests/random.sh
=====================================
@@ -0,0 +1,96 @@
+#!/bin/sh -f
+
+# copied and enhanced from upstream
+
+set -e
+pkg=andi
+
+export LC_ALL=C.UTF-8
+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
+  trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
+fi
+
+cp test/test_fasta.cxx "${AUTOPKGTEST_TMP}"
+
+cd "${AUTOPKGTEST_TMP}"
+
+g++ -O2 -Wall -o test_fasta test_fasta.cxx
+RANDOM_SEED=1729
+
+
+
+#--- only small changes below ---
+
+# This scripts test the accuracy of andi with random inputs. For that
+# it uses the small program test_random to generate pairs of sequences
+# with a given distance. By default, test_random creates a new set of
+# sequences each time it is called. Thus, this test has a small, but
+# non-zero probability of failing. That is a problem with Debian's
+# reproducible builds effort. So this script acts as a wrapper around
+# this issue.
+#
+# Simply calling this script via
+#     % ./test/test_random.sh
+# checks a new test-case every time. But with the right parameter
+#     % RANDOM_SEED=1729 ./test/test_random.sh
+# one specific set of sequences is validated.
+
+andi --help > /dev/null || exit 1
+
+LENGTH=100000
+
+# If RANDOM_SEED is set, use its value. Otherwise 0 is used to signal
+# to test_random that a new set of sequences shall be generated.
+SEED=${RANDOM_SEED:-0}
+
+for dist in 0.0 0.001 0.01 0.02 0.05 0.1 0.2 0.3
+do
+	for n in $(seq 10)
+	do
+		if test $SEED -ne 0; then
+			SEED=$((SEED + 1))
+		fi
+
+		res=$(./test_fasta -s $SEED -l $LENGTH -d $dist |
+			tee test_random.fasta |
+			andi -t 1 |
+			tail -n 1 |
+			awk -v dist=$dist '{print $2, dist}' |
+			awk 'function abs(x){return ((x < 0.0) ? -x : x)} {print abs($1-$2) <= 0.055 && abs($1-$2) <= 0.055 * $2}')
+		if test $res -ne 1; then
+			echo "The last test computed a distance deviating more than five percent from its intended value."
+			echo "See test_random.fasta for the used sequences."
+			echo "./test_fasta -s $SEED -l $LENGTH -d $dist"
+			head -n 1 test_random.fasta
+			exit 1;
+		fi
+	done
+
+	# raw
+	for n in $(seq 10)
+	do
+		if test $SEED -ne 0; then
+			SEED=$((SEED + 1))
+		fi
+
+		res=$(./test_fasta -r -s $SEED -l $LENGTH -d $dist |
+			tee test_random.fasta |
+			andi -m RAW -t 1 |
+			tail -n 1 |
+			awk -v dist=$dist '{print $2, dist}' |
+			awk 'function abs(x){return ((x < 0.0) ? -x : x)} {print abs($1-$2) <= 0.055 && abs($1-$2) <= 0.055 * $2}')
+		if test $res -ne 1; then
+			echo "The last test computed a distance deviating more than five percent from its intended value."
+			echo "See test_random.fasta for the used sequences."
+			echo "./test_fasta -r -s $SEED -l $LENGTH -d $dist"
+			head -n 1 test_random.fasta
+			exit 1;
+		fi
+	done
+done
+
+rm test_random.fasta



View it on GitLab: https://salsa.debian.org/med-team/andi/-/compare/baa55f4104ca09dae32812612c3b024bc609ca4a...c7d25761d2caaa216171c231c311febaef834ca6

-- 
View it on GitLab: https://salsa.debian.org/med-team/andi/-/compare/baa55f4104ca09dae32812612c3b024bc609ca4a...c7d25761d2caaa216171c231c311febaef834ca6
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20200405/a0107a69/attachment-0001.html>


More information about the debian-med-commit mailing list