move setup from test file to test command
This commit is contained in:
parent
6051f707ca
commit
aea762f22f
9
orcli
9
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+=(${?})
|
||||
|
|
|
@ -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+=(${?})
|
||||
|
|
|
@ -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"
|
|
@ -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"
|
||||
diff -u "${t}.assert" "${t}.output"
|
Loading…
Reference in New Issue