-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
216 additions
and
8 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
# Minimal test suite for fasten (telatin 2024) | ||
|
||
THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
THIS_SCRIPT_NAME=$(basename "$0" | sed 's/\.sh//g') | ||
source "${THIS_SCRIPT_DIR}/test_functions.sh" | ||
|
||
IN_FILE="${THIS_SCRIPT_DIR}/../testdata/four_reads.fastq" | ||
|
||
"$BIN" --out-format FASTA < "$IN_FILE" > "$TEST_TMP_FILE" | ||
FASTA_COUNT=$(grep -c ">" "$TEST_TMP_FILE") | ||
FASTQ_COUNT=$(grep -c "^@" "$TEST_TMP_FILE") | ||
equal "$FASTA_COUNT" "4" "Testing that the output is in FASTA format" | ||
equal "$FASTQ_COUNT" "0" "Testing that the output is in not FASTQ format" | ||
|
||
"$BIN" --out-format FASTQ --in-format FASTA < "$TEST_TMP_FILE" > "$TEST_TMP_FILE.2" | ||
|
||
FASTA_COUNT=$(grep -c "^>" "$TEST_TMP_FILE.2") | ||
FASTQ_COUNT=$(grep -c "^@r" "$TEST_TMP_FILE.2") | ||
|
||
equal "$FASTQ_COUNT" "4" "Testing that the output is in not FASTA format" | ||
equal "$FASTQ_COUNT" "4" "Testing that the output is in FASTQ format" | ||
rm "$TEST_TMP_FILE.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
# Minimal test suite for fasten (telatin 2024) | ||
|
||
THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
THIS_SCRIPT_NAME=$(basename "$0" | sed 's/\.sh//g') | ||
source "${THIS_SCRIPT_DIR}/test_functions.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
# Minimal test suite for fasten mutate (telatin 2024) | ||
|
||
THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
THIS_SCRIPT_NAME=$(basename "$0" | sed 's/\.sh//g') | ||
source "${THIS_SCRIPT_DIR}/test_functions.sh" | ||
|
||
INFILE="${THIS_SCRIPT_DIR}/../testdata/four_reads.fastq" | ||
|
||
|
||
"$BIN" --snps 1 < "$INFILE" > "$TEST_TMP_FILE" | ||
|
||
MD5_IN_EXPECTED="8a08ae75226dfacd60f6fe2a1000f100" | ||
MD5=$(getmd5 "$TEST_TMP_FILE" | cut -f 1 -d " ") | ||
MD5_IN=$(getmd5 "$INFILE" | cut -f 1 -d " ") | ||
|
||
equal "$MD5_IN" "$MD5_IN_EXPECTED" "Testing that the input file wasnt changed" | ||
different "$MD5" "$MD5_IN" "Testing that the output is different from the input" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
# Minimal test suite for fasten normalise (telatin 2024) | ||
|
||
THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
THIS_SCRIPT_NAME=$(basename "$0" | sed 's/\.sh//g') | ||
source "${THIS_SCRIPT_DIR}/test_functions.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
# Minimal test suite for fasten progress (telatin 2024) | ||
|
||
THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
THIS_SCRIPT_NAME=$(basename "$0" | sed 's/\.sh//g') | ||
source "${THIS_SCRIPT_DIR}/test_functions.sh" | ||
|
||
GOT_PERL=$(which perl) | ||
|
||
if [ -z "$GOT_PERL" ]; then | ||
echo "Perl not found, skipping test" | ||
exit 0 | ||
fi | ||
|
||
|
||
## Here we test that STDOUT is passed using --print | ||
|
||
# shellcheck disable=SC2016 | ||
TOT=$("$GOT_PERL" -e 'my $c=0;for (1..1000) { | ||
$c++; | ||
print "\@fasten_test$c\nAAA\n+\nIII\n"; | ||
sleep 0.1; | ||
}' | "$BIN" --id "test-suite" --print | grep -c 'fasten_test' | grep -w 1000) | ||
|
||
equal "$TOT" "1000" "Testing sort order of 1000 reads" | ||
|
||
|
||
## Here we test the final message | ||
# shellcheck disable=SC2016 | ||
"$GOT_PERL" -e 'my $c=0;for (1..1000) { | ||
$c++; | ||
print "\@fasten_test$c\nAAA\n+\nIII\n"; | ||
sleep 0.1; | ||
}' | "$BIN" --id "test-suite" 2> "$TEST_TMP_FILE" | ||
|
||
END=$(grep "Finished" "$TEST_TMP_FILE" | cut -f 3 -d ":") | ||
equal "$END" " Finished progress on 4000 reads" "Testing progress output" | ||
|
||
done_testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
# Minimal test suite for fasten sort (telatin 2024) | ||
|
||
THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
THIS_SCRIPT_NAME=$(basename "$0" | sed 's/\.sh//g') | ||
source "${THIS_SCRIPT_DIR}/test_functions.sh" | ||
|
||
# Test fasten_sort with two reads | ||
FIRST=$(echo -e "@ciao\nAAA\n+\nIII\n@andrea\nCCC\n+\nEEE" | $BIN | head -n 1) | ||
equal "$FIRST" "@andrea" "Testing sort order of two reads" | ||
|
||
done_testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This should be sourced by other test scripts: die if not | ||
if [ -z "$THIS_SCRIPT_DIR" ]; then | ||
echo "ERROR: test_functions.sh should be sourced by other test scripts" | ||
exit 1 | ||
fi | ||
TEST_TMP_FILE=$(mktemp) | ||
NUM=0 | ||
FAIL=0 | ||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
NC='\033[0m' # No Color | ||
BIN=$(readlink -f "${THIS_SCRIPT_DIR}/../target/release/${THIS_SCRIPT_NAME}") | ||
DEB_BIN=$(readlink -f "${THIS_SCRIPT_DIR}/../target/debug/${THIS_SCRIPT_NAME}") | ||
|
||
|
||
echo -e " *** ${GREEN}Testing $THIS_SCRIPT_NAME${NC} (test: $TEST_TMP_FILE)*** " | ||
|
||
|
||
|
||
function test { | ||
NUM=$((NUM+1)) | ||
local msg="$1" | ||
local condition=$2 | ||
if [ "$condition" ]; then | ||
echo -e "${GREEN}OK${NC}\t$NUM: $msg" | ||
else | ||
FAIL=$((FAIL+1)) | ||
echo -e "${RED}FAIL${NC}\t$NUM: $msg" | ||
fi | ||
} | ||
|
||
function equal { | ||
local got="$1" | ||
local expected="$2" | ||
local msg="$3" | ||
NUM=$((NUM+1)) | ||
if [ "$got" == "$expected" ]; then | ||
echo -e "${GREEN}OK${NC}\t$NUM: $msg [$got]" | ||
else | ||
FAIL=$((FAIL+1)) | ||
echo -e "${RED}FAIL${NC}\t$NUM: $msg" | ||
echo -e "\tGot: $got" | ||
echo -e "\tExpected: $expected" | ||
fi | ||
} | ||
|
||
function different { | ||
local got="$1" | ||
local expected="$2" | ||
local msg="$3" | ||
NUM=$((NUM+1)) | ||
if [ "$got" != "$expected" ]; then | ||
echo -e "${GREEN}OK${NC}\t$NUM: $msg [$got != $expected]" | ||
else | ||
FAIL=$((FAIL+1)) | ||
echo -e "${RED}FAIL${NC}\t$NUM: $msg" | ||
echo -e "\tGot: $got" | ||
echo -e "\tequals to: $expected" | ||
fi | ||
} | ||
|
||
function getmd5 { | ||
# use md5sum on Linux, md5 on OSX | ||
if [ "$(uname)" == "Darwin" ]; then | ||
md5 -q "$1" | ||
else | ||
md5sum "$1" | cut -f 1 -d " " | ||
fi | ||
} | ||
function done_testing { | ||
if [ -e "$TEST_TMP_FILE" ]; then | ||
rm "$TEST_TMP_FILE" | ||
fi | ||
if [ "$FAIL" -eq 0 ]; then | ||
echo -e "${GREEN}OK!${NC}\tAll $NUM tests passed${NC}" | ||
exit 0 | ||
else | ||
echo -e "${RED}$FAIL/$NUM errors${NC}\ttests failed${NC}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
test "Release binary $BIN" "-e $BIN" | ||
test "Release debug $DEB_BIN" "-e $DEB_BIN" | ||
test "Release binary --help" "$DEB_BIN --help" | ||
test "Debug binary --help" "$DEB_BIN --help" | ||
|
||
test "Release binary --version" "$DEB_BIN --version" | ||
test "Debug binary --version" "$DEB_BIN --version" |