Skip to content

Commit

Permalink
ensure test_trtools.sh can be run with a dev install but explain the …
Browse files Browse the repository at this point in the history
…caveats
  • Loading branch information
aryarm authored Feb 20, 2024
1 parent c759bb8 commit 37c75bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 8 additions & 6 deletions test/cmdline_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ if [ $# -eq 0 ]; then
# use default example location
EXDATADIR="example-files"
BEAGLEDIR="trtools/testsupport/sample_vcfs/beagle"
elif (( $# != 2 )) ; then
echo "usage: cmdline_tests.sh {example_dir} {beagle_dir}" 2>&1
echo "Expected 2 arguments but recieved $#" 2>&1
BEAGLESCRIPT="scripts/trtools_prep_beagle_vcf.sh"
elif (( $# != 3 )) ; then
echo "usage: cmdline_tests.sh {example_dir} {beagle_dir} {beagle_script}" 2>&1
echo "Expected 3 arguments but recieved $#" 2>&1
exit 1
else
EXDATADIR=$1
BEAGLEDIR=$2
BEAGLESCRIPT=$3
fi

TMPDIR=$(mktemp -d -t tmp-XXXXXXXXXX)
Expand Down Expand Up @@ -220,10 +222,10 @@ prep_beagle_out="$TMPDIR"/test_prep_beagle_vcf.vcf.gz
ref_panel="$BEAGLEDIR"/1kg_snpstr_21_first_100k_first_50_annotated.vcf.gz
imputed_vcf="$BEAGLEDIR"/1kg_snpstr_21_first_100k_second_50_STRs_imputed.vcf.gz

runcmd_fail "trtools_prep_beagle_vcf.sh hipstr nonexistent.vcf.gz $imputed_vcf $prep_beagle_out"
runcmd_fail "trtools_prep_beagle_vcf.sh hipstr $ref_panel nonexistent.vcf.gz $prep_beagle_out"
runcmd_fail "$BEAGLESCRIPT hipstr nonexistent.vcf.gz $imputed_vcf $prep_beagle_out"
runcmd_fail "$BEAGLESCRIPT hipstr $ref_panel nonexistent.vcf.gz $prep_beagle_out"

trtools_prep_beagle_vcf.sh hipstr "$ref_panel" "$imputed_vcf" "$prep_beagle_out"
$BEAGLESCRIPT hipstr "$ref_panel" "$imputed_vcf" "$prep_beagle_out"

if ! [[ -f "$prep_beagle_out" ]] ; then
echo "prep_beagle_vcf test didn't produce output file" >&2
Expand Down
8 changes: 7 additions & 1 deletion trtools/testsupport/test_trtools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
# Run the tests for an installed copy of trtools
# If not already present, megabytes of test data will be downloaded before test running

# If TRTools was installed normally, this script can be executed by simply running
# 'test_trtools.sh' on the command line.
# Otherwise, if TRTools was installed via poetry, you should run the command
# 'poetry run trtools/testsupport/test_trtools.sh'. However, please note that this
# script should not be used to test TRTools against any recent/unpublished changes.

echo "Running test_trtools.sh"

command -v git >/dev/null 2>&1 || { echo >&2 "git is not available, but is required for downloading the test data. Aborting."; exit 1; }
Expand Down Expand Up @@ -41,4 +47,4 @@ cd "$loc" || exit 1
# run unit tests
python -m pytest . -p trtools.testsupport.dataloader --datadir "$TMP"/trtools/testsupport
# run command line tests
$TMP/test/cmdline_tests.sh $TMP/example-files $TMP/trtools/testsupport/sample_vcfs/beagle
$TMP/test/cmdline_tests.sh $TMP/example-files $TMP/trtools/testsupport/sample_vcfs/beagle $TMP/scripts/trtools_prep_beagle_vcf.sh

0 comments on commit 37c75bb

Please sign in to comment.