Skip to content

Commit

Permalink
create temporary directory and clean up on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Leila011 committed Aug 19, 2024
1 parent b062bda commit 1ea646a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/agat/agat_sp_prokka_infer_name_from_attributes/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,27 @@ set -eo pipefail
## VIASH END

test_dir="${meta_resources_dir}/test_data"
out_dir="${meta_resources_dir}/out_data"

# create temporary directory and clean up on exit
TMPDIR=$(mktemp -d "$meta_temp_dir/$meta_functionality_name-XXXXXX")
function clean_up {
[[ -d "$TMPDIR" ]] && rm -rf "$TMPDIR"
}
trap clean_up EXIT

echo "> Run $meta_name with test data"
"$meta_executable" \
--gff "$test_dir/input_prokka.gff" \
--output "$out_dir/output.gff" \
--output "$TMPDIR/output.gff" \

echo ">> Checking output"
[ ! -f "$out_dir/output.gff" ] && echo "Output file output.gff does not exist" && exit 1
[ ! -f "$TMPDIR/output.gff" ] && echo "Output file output.gff does not exist" && exit 1

echo ">> Check if output is empty"
[ ! -s "$out_dir/output.gff" ] && echo "Output file output.gff is empty" && exit 1
[ ! -s "$TMPDIR/output.gff" ] && echo "Output file output.gff is empty" && exit 1

echo ">> Check if output matches expected output"
diff "$out_dir/output.gff" "$test_dir/output_prokka.gff"
diff "$TMPDIR/output.gff" "$test_dir/output_prokka.gff"
if [ $? -ne 0 ]; then
echo "Output file output.gff does not match expected output"
exit 1
Expand Down

0 comments on commit 1ea646a

Please sign in to comment.