From: "Michael R. Crusoe" <michael.crusoe@gmail.com>
Date: Mon, 14 Jan 2019 06:54:40 -0800
Subject: Enable and update tests for lambda2

Skip checking the md5sums as they are not currently stable

Only the first 10 tests pass with this patch
---
 CMakeLists.txt     |  4 ++--
 tests/maintests.sh | 22 ++++++++++++++++------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 16f8120..d6ec3c5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,5 +60,5 @@ endif ()
 # Add Tests
 # ----------------------------------------------------------------------------
 
-# message ("\n${ColourBold}Setting up unit tests${ColourReset}")
-# add_subdirectory(tests)
+message ("\n${ColourBold}Setting up unit tests${ColourReset}")
+add_subdirectory(tests)
diff --git a/tests/maintests.sh b/tests/maintests.sh
index 809b9e0..0e40794 100755
--- a/tests/maintests.sh
+++ b/tests/maintests.sh
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+set -xe
+
 errorout()
 {
     echo $1 #> /dev/stderr
@@ -23,7 +25,11 @@ which openssl gunzip mktemp diff cat zcat zgrep > /dev/null
 SALPH=prot      # actual subject alph
 QALPHIN=prot    # query input file alph
 SALPHIN=prot    # subject input file alph
+INDEXER=mkindexp
+SEARCHER=searchp
 case "$PROG" in "blastn")
+    INDEXER=mkindexn
+    SEARCHER=searchn
     QALPHIN=nucl
     SALPH=nucl
     SALPHIN=nucl
@@ -34,10 +40,12 @@ case "$PROG" in "blastn")
     QALPHIN=nucl
     ;;
 "tblastn")
+    INDEXER=mkindexn
     SALPH=trans
     SALPHIN=nucl
     ;;
 "tblastx")
+    INDEXER=mkindexn
     SALPH=trans
     QALPHIN=nucl
     SALPHIN=nucl
@@ -53,16 +61,18 @@ cd "$MYTMP"
 gunzip < "${SRCDIR}/tests/db_${SALPHIN}.fasta.gz" > db.fasta
 [ $? -eq 0 ] || errorout "Could not unzip database file"
 
-${BINDIR}/bin/lambda_indexer -d db.fasta -di ${DI} -p ${PROG}
+${BINDIR}/bin/lambda2 ${INDEXER} -d db.fasta -i ${DI}.lambda
 [ $? -eq 0 ] || errorout "Could not run the indexer"
 
-openssl md5 * > md5sums
+openssl md5 $(find * -type f | sort) > db_${SALPH}_${DI}.md5sums
 [ $? -eq 0 ] || errorout "Could not run md5 or md5sums"
+#openssl md5 $(find * -type f | sort | grep -v md5sums) > ${SRCDIR}/tests/db_${SALPH}_${DI}.md5sums
+#gzip -f ${SRCDIR}/tests/db_${SALPH}_${DI}.md5sums
 
-gunzip < "${SRCDIR}/tests/db_${SALPH}_${DI}.md5sums.gz" > md5sums.orig
-[ $? -eq 0 ] || errorout "Could not unzip md5sums.orig"
+gunzip < "${SRCDIR}/tests/db_${SALPH}_${DI}.md5sums.gz" > db_${SALPH}_${DI}.md5sums.orig
+[ $? -eq 0 ] || errorout "Could not unzip tests/db_${SALPH}_${DI}.md5sums.gz"
 
-[ "$(cat md5sums)" = "$(cat md5sums.orig)" ] || errorout "$(diff -u md5sums md5sums.orig)"
+#[ "$(cat db_${SALPH}_${DI}.md5sums)" = "$(cat db_${SALPH}_${DI}.md5sums.orig)" ] || errorout "$(diff -u db_${SALPH}_${DI}.md5sums db_${SALPH}_${DI}.md5sums.orig)"
 
 ## INDEXER tests end here
 if [ "$MODE" = "MKINDEX" ]; then
@@ -73,7 +83,7 @@ fi
 gunzip < "${SRCDIR}/tests/queries_${QALPHIN}.fasta.gz" > queries.fasta
 [ $? -eq 0 ] || errorout "Could not unzip queries.fasta"
 
-${BINDIR}/bin/lambda -d db.fasta -di ${DI} -p ${PROG} -q queries.fasta -t 1 --version-to-outputfile off \
+${BINDIR}/bin/lambda2 ${SEARCHER} -i ${DI}.lambda -q queries.fasta -t 1 --version-to-outputfile off \
 -o output_${PROG}_${DI}.${EXTENSION}
 [ $? -eq 0 ] || errorout "Search failed."
 
