diff --git a/orcli b/orcli index 2bdc2bd..bdc89f9 100755 --- a/orcli +++ b/orcli @@ -1050,7 +1050,7 @@ orcli_info_command() { # :command.function orcli_test_command() { # src/test_command.sh - # shellcheck shell=bash + # shellcheck shell=bash disable=SC2154 # catch args, convert the space delimited string to an array files=() @@ -1099,11 +1099,16 @@ orcli_test_command() { results=() for i in "${!files[@]}"; do set +e - bash <( + bash -e <( + # support ./orcli if ! command -v orcli &>/dev/null; then echo "shopt -s expand_aliases" echo "alias orcli=${scriptpath}/orcli" fi + # separate subdirectory for each test + echo "mkdir -p ${OPENREFINE_TMPDIR}/${files[$i]}" + echo "cd ${OPENREFINE_TMPDIR}/${files[$i]} || exit 1" + # echo test file awk 1 "${files[$i]}" ) &>"$OPENREFINE_TMPDIR/test.log" results+=(${?}) diff --git a/src/test_command.sh b/src/test_command.sh index 813d9d3..20894b9 100644 --- a/src/test_command.sh +++ b/src/test_command.sh @@ -1,4 +1,4 @@ -# shellcheck shell=bash +# shellcheck shell=bash disable=SC2154 # catch args, convert the space delimited string to an array files=() @@ -47,11 +47,16 @@ export OPENREFINE_TMPDIR OPENREFINE_URL OPENREFINE_PID results=() for i in "${!files[@]}"; do set +e - bash <( + bash -e <( + # support ./orcli if ! command -v orcli &>/dev/null; then echo "shopt -s expand_aliases" echo "alias orcli=${scriptpath}/orcli" fi + # separate subdirectory for each test + echo "mkdir -p ${OPENREFINE_TMPDIR}/${files[$i]}" + echo "cd ${OPENREFINE_TMPDIR}/${files[$i]} || exit 1" + # echo test file awk 1 "${files[$i]}" ) &>"$OPENREFINE_TMPDIR/test.log" results+=(${?}) diff --git a/tests/fail.sh b/tests/fail.sh deleted file mode 100644 index 50acc94..0000000 --- a/tests/fail.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# environment -t=import-csv -mkdir "${OPENREFINE_TMPDIR}/${t}" -cd "${OPENREFINE_TMPDIR}/${t}" || exit 1 - -# data -cat << "DATA" > "test.csv" -a,b,c -1,2,3 -0,0,0 -$,\,' -DATA - -# assertion -cat << "DATA" > "test.assert" -a b c -1 2 3 -0 1 0 -$ \ ' -DATA - -# action -orcli import csv "test.csv" -orcli export tsv "test csv" --output "test.output" - -# test -diff -u "test.assert" "test.output" \ No newline at end of file diff --git a/tests/import-csv.sh b/tests/import-csv.sh index 878a9e5..f9406d5 100644 --- a/tests/import-csv.sh +++ b/tests/import-csv.sh @@ -1,12 +1,10 @@ #!/bin/bash # environment -t=import-csv -mkdir "${OPENREFINE_TMPDIR}/${t}" -cd "${OPENREFINE_TMPDIR}/${t}" || exit 1 +t="$(basename "$(pwd)" .sh)" # data -cat << "DATA" > "test.csv" +cat << "DATA" > "${t}.csv" a,b,c 1,2,3 0,0,0 @@ -14,7 +12,7 @@ $,\,' DATA # assertion -cat << "DATA" > "test.assert" +cat << "DATA" > "${t}.assert" a b c 1 2 3 0 0 0 @@ -22,8 +20,8 @@ $ \ ' DATA # action -orcli import csv "test.csv" -orcli export tsv "test csv" --output "test.output" +orcli import csv "${t}.csv" +orcli export tsv "${t} csv" --output "${t}.output" # test -diff -u "test.assert" "test.output" \ No newline at end of file +diff -u "${t}.assert" "${t}.output" \ No newline at end of file