make test scripts standalone
This commit is contained in:
parent
aea762f22f
commit
8b2e35ced2
162
orcli
162
orcli
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# This script was generated by bashly 0.8.10 (https://bashly.dannyb.co)
|
# This script was generated by bashly 0.9.0 (https://bashly.dannyb.co)
|
||||||
# Modifying it manually is not recommended
|
# Modifying it manually is not recommended
|
||||||
|
|
||||||
# :wrapper.bash3_bouncer
|
# :wrapper.bash3_bouncer
|
||||||
|
@ -377,7 +377,7 @@ orcli_test_usage() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "Usage:\n"
|
printf "Usage:\n"
|
||||||
printf " orcli test [FILE...]\n"
|
printf " orcli test\n"
|
||||||
printf " orcli test --help | -h\n"
|
printf " orcli test --help | -h\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
@ -390,15 +390,6 @@ orcli_test_usage() {
|
||||||
printf " Show this help\n"
|
printf " Show this help\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# :command.usage_args
|
|
||||||
printf "Arguments:\n"
|
|
||||||
|
|
||||||
# :argument.usage
|
|
||||||
echo " FILE..."
|
|
||||||
printf " Path to one or more files\n"
|
|
||||||
printf " Default: tests/*.sh\n"
|
|
||||||
echo
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1052,16 +1043,12 @@ orcli_test_command() {
|
||||||
# src/test_command.sh
|
# src/test_command.sh
|
||||||
# shellcheck shell=bash disable=SC2154
|
# shellcheck shell=bash disable=SC2154
|
||||||
|
|
||||||
# catch args, convert the space delimited string to an array
|
|
||||||
files=()
|
|
||||||
eval "files=(${args[file]})"
|
|
||||||
|
|
||||||
# check existence of files
|
# check existence of files
|
||||||
for i in "${!files[@]}"; do
|
if ! [[ -f "tests/help.sh" ]]; then
|
||||||
if ! [[ -f "${files[$i]}" ]]; then
|
error "Cannot open test files!"
|
||||||
error "cannot open ${files[$i]} (no such file)!"
|
|
||||||
fi
|
fi
|
||||||
done
|
cd "tests"
|
||||||
|
files=(*.sh)
|
||||||
|
|
||||||
# locate orcli and OpenRefine
|
# locate orcli and OpenRefine
|
||||||
scriptpath=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
|
scriptpath=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
|
||||||
|
@ -1100,15 +1087,10 @@ orcli_test_command() {
|
||||||
for i in "${!files[@]}"; do
|
for i in "${!files[@]}"; do
|
||||||
set +e
|
set +e
|
||||||
bash -e <(
|
bash -e <(
|
||||||
# support ./orcli
|
|
||||||
if ! command -v orcli &>/dev/null; then
|
if ! command -v orcli &>/dev/null; then
|
||||||
echo "shopt -s expand_aliases"
|
echo "shopt -s expand_aliases"
|
||||||
echo "alias orcli=${scriptpath}/orcli"
|
echo "alias orcli=${scriptpath}/orcli"
|
||||||
fi
|
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]}"
|
awk 1 "${files[$i]}"
|
||||||
) &>"$OPENREFINE_TMPDIR/test.log"
|
) &>"$OPENREFINE_TMPDIR/test.log"
|
||||||
results+=(${?})
|
results+=(${?})
|
||||||
|
@ -1379,6 +1361,7 @@ orcli_run_command() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
parse_requirements() {
|
parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--version | -v)
|
--version | -v)
|
||||||
version_command
|
version_command
|
||||||
|
@ -1391,18 +1374,24 @@ parse_requirements() {
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.environment_variables_filter
|
# :command.environment_variables_filter
|
||||||
# :command.environment_variables_default
|
# :command.environment_variables_default
|
||||||
export OPENREFINE_URL="${OPENREFINE_URL:-http://localhost:3333}"
|
export OPENREFINE_URL="${OPENREFINE_URL:-http://localhost:3333}"
|
||||||
|
|
||||||
# :command.dependencies_filter
|
# :command.dependencies_filter
|
||||||
if ! [[ -x "$(command -v curl)" ]]; then
|
if ! command -v curl >/dev/null 2>&1; then
|
||||||
printf "missing dependency: curl\n" >&2
|
printf "missing dependency: curl\n" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if ! [[ -x "$(command -v jq)" ]]; then
|
|
||||||
|
if ! command -v jq >/dev/null 2>&1; then
|
||||||
printf "missing dependency: jq\n" >&2
|
printf "missing dependency: jq\n" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -1509,6 +1498,7 @@ parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_completions_parse_requirements() {
|
orcli_completions_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h)
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
|
@ -1516,7 +1506,12 @@ orcli_completions_parse_requirements() {
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="completions"
|
action="completions"
|
||||||
|
@ -1547,6 +1542,7 @@ orcli_completions_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_import_parse_requirements() {
|
orcli_import_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h)
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
|
@ -1554,7 +1550,12 @@ orcli_import_parse_requirements() {
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action=${1:-}
|
action=${1:-}
|
||||||
|
@ -1616,6 +1617,7 @@ orcli_import_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_import_csv_parse_requirements() {
|
orcli_import_csv_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h)
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
|
@ -1623,7 +1625,12 @@ orcli_import_csv_parse_requirements() {
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="import csv"
|
action="import csv"
|
||||||
|
@ -1724,6 +1731,7 @@ orcli_import_csv_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_import_tsv_parse_requirements() {
|
orcli_import_tsv_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h)
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
|
@ -1731,7 +1739,12 @@ orcli_import_tsv_parse_requirements() {
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="import tsv"
|
action="import tsv"
|
||||||
|
@ -1816,6 +1829,7 @@ orcli_import_tsv_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_list_parse_requirements() {
|
orcli_list_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h)
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
|
@ -1823,7 +1837,12 @@ orcli_list_parse_requirements() {
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="list"
|
action="list"
|
||||||
|
@ -1854,6 +1873,7 @@ orcli_list_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_info_parse_requirements() {
|
orcli_info_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h)
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
|
@ -1861,7 +1881,12 @@ orcli_info_parse_requirements() {
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="info"
|
action="info"
|
||||||
|
@ -1904,6 +1929,7 @@ orcli_info_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_test_parse_requirements() {
|
orcli_test_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h)
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
|
@ -1911,7 +1937,12 @@ orcli_test_parse_requirements() {
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="test"
|
action="test"
|
||||||
|
@ -1928,29 +1959,21 @@ orcli_test_parse_requirements() {
|
||||||
|
|
||||||
*)
|
*)
|
||||||
# :command.parse_requirements_case
|
# :command.parse_requirements_case
|
||||||
# :command.parse_requirements_case_repeatable
|
# :command.parse_requirements_case_simple
|
||||||
if [[ -z ${args[file]+x} ]]; then
|
printf "invalid argument: %s\n" "$key" >&2
|
||||||
|
exit 1
|
||||||
args[file]="\"$1\""
|
|
||||||
shift
|
|
||||||
else
|
|
||||||
args[file]="${args[file]} \"$1\""
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# :command.default_assignments
|
|
||||||
[[ -n ${args[file]:-} ]] || args[file]="tests/*.sh"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_transform_parse_requirements() {
|
orcli_transform_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h)
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
|
@ -1958,7 +1981,12 @@ orcli_transform_parse_requirements() {
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="transform"
|
action="transform"
|
||||||
|
@ -2015,6 +2043,7 @@ orcli_transform_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_export_parse_requirements() {
|
orcli_export_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h)
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
|
@ -2022,7 +2051,12 @@ orcli_export_parse_requirements() {
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action=${1:-}
|
action=${1:-}
|
||||||
|
@ -2077,6 +2111,7 @@ orcli_export_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_export_tsv_parse_requirements() {
|
orcli_export_tsv_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h)
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
|
@ -2084,7 +2119,12 @@ orcli_export_tsv_parse_requirements() {
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="export tsv"
|
action="export tsv"
|
||||||
|
@ -2167,6 +2207,7 @@ orcli_export_tsv_parse_requirements() {
|
||||||
# :command.parse_requirements
|
# :command.parse_requirements
|
||||||
orcli_run_parse_requirements() {
|
orcli_run_parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
# :command.fixed_flags_filter
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--help | -h)
|
--help | -h)
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
|
@ -2174,7 +2215,12 @@ orcli_run_parse_requirements() {
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# :command.command_filter
|
# :command.command_filter
|
||||||
action="run"
|
action="run"
|
||||||
|
@ -2279,97 +2325,111 @@ run() {
|
||||||
normalize_input "$@"
|
normalize_input "$@"
|
||||||
parse_requirements "${input[@]}"
|
parse_requirements "${input[@]}"
|
||||||
|
|
||||||
if [[ $action == "completions" ]]; then
|
case "$action" in
|
||||||
|
"completions")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_completions_usage
|
orcli_completions_usage
|
||||||
else
|
else
|
||||||
orcli_completions_command
|
orcli_completions_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "import" ]]; then
|
"import")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_import_usage
|
orcli_import_usage
|
||||||
else
|
else
|
||||||
orcli_import_command
|
orcli_import_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "import csv" ]]; then
|
"import csv")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_import_csv_usage
|
orcli_import_csv_usage
|
||||||
else
|
else
|
||||||
orcli_import_csv_command
|
orcli_import_csv_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "import tsv" ]]; then
|
"import tsv")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_import_tsv_usage
|
orcli_import_tsv_usage
|
||||||
else
|
else
|
||||||
orcli_import_tsv_command
|
orcli_import_tsv_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "list" ]]; then
|
"list")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_list_usage
|
orcli_list_usage
|
||||||
else
|
else
|
||||||
orcli_list_command
|
orcli_list_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "info" ]]; then
|
"info")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_info_usage
|
orcli_info_usage
|
||||||
else
|
else
|
||||||
orcli_info_command
|
orcli_info_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "test" ]]; then
|
"test")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_test_usage
|
orcli_test_usage
|
||||||
else
|
else
|
||||||
orcli_test_command
|
orcli_test_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "transform" ]]; then
|
"transform")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_transform_usage
|
orcli_transform_usage
|
||||||
else
|
else
|
||||||
orcli_transform_command
|
orcli_transform_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "export" ]]; then
|
"export")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_export_usage
|
orcli_export_usage
|
||||||
else
|
else
|
||||||
orcli_export_command
|
orcli_export_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "export tsv" ]]; then
|
"export tsv")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_export_tsv_usage
|
orcli_export_tsv_usage
|
||||||
else
|
else
|
||||||
orcli_export_tsv_command
|
orcli_export_tsv_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "run" ]]; then
|
"run")
|
||||||
if [[ ${args[--help]:-} ]]; then
|
if [[ ${args[--help]:-} ]]; then
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
orcli_run_usage
|
orcli_run_usage
|
||||||
else
|
else
|
||||||
orcli_run_command
|
orcli_run_command
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
elif [[ $action == "root" ]]; then
|
"root")
|
||||||
root_command
|
root_command
|
||||||
fi
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize
|
initialize
|
||||||
|
|
|
@ -118,11 +118,6 @@ commands:
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
help: run functional tests on tmp OpenRefine workspace
|
help: run functional tests on tmp OpenRefine workspace
|
||||||
args:
|
|
||||||
- name: file
|
|
||||||
help: Path to one or more files
|
|
||||||
default: "tests/*.sh"
|
|
||||||
repeatable: true
|
|
||||||
|
|
||||||
- name: transform
|
- name: transform
|
||||||
help: apply undo/redo JSON file(s) to an OpenRefine project
|
help: apply undo/redo JSON file(s) to an OpenRefine project
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
# shellcheck shell=bash disable=SC2154
|
# shellcheck shell=bash disable=SC2154
|
||||||
|
|
||||||
# catch args, convert the space delimited string to an array
|
|
||||||
files=()
|
|
||||||
eval "files=(${args[file]})"
|
|
||||||
|
|
||||||
# check existence of files
|
# check existence of files
|
||||||
for i in "${!files[@]}"; do
|
if ! [[ -f "tests/help.sh" ]]; then
|
||||||
if ! [[ -f "${files[$i]}" ]]; then
|
error "Cannot open test files!"
|
||||||
error "cannot open ${files[$i]} (no such file)!"
|
|
||||||
fi
|
fi
|
||||||
done
|
cd "tests"
|
||||||
|
files=(*.sh)
|
||||||
|
|
||||||
# locate orcli and OpenRefine
|
# locate orcli and OpenRefine
|
||||||
scriptpath=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
|
scriptpath=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
|
||||||
|
@ -48,15 +44,10 @@ results=()
|
||||||
for i in "${!files[@]}"; do
|
for i in "${!files[@]}"; do
|
||||||
set +e
|
set +e
|
||||||
bash -e <(
|
bash -e <(
|
||||||
# support ./orcli
|
|
||||||
if ! command -v orcli &>/dev/null; then
|
if ! command -v orcli &>/dev/null; then
|
||||||
echo "shopt -s expand_aliases"
|
echo "shopt -s expand_aliases"
|
||||||
echo "alias orcli=${scriptpath}/orcli"
|
echo "alias orcli=${scriptpath}/orcli"
|
||||||
fi
|
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]}"
|
awk 1 "${files[$i]}"
|
||||||
) &>"$OPENREFINE_TMPDIR/test.log"
|
) &>"$OPENREFINE_TMPDIR/test.log"
|
||||||
results+=(${?})
|
results+=(${?})
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
a,b,c
|
||||||
|
1,2,3
|
||||||
|
0,0,0
|
||||||
|
$,\,'
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
a b c
|
||||||
|
1 2 3
|
||||||
|
0 0 0
|
||||||
|
$ \ '
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
t="help"
|
||||||
|
|
||||||
|
# environment
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
trap '{ rm -rf "${tmpdir}"; }' 0 2 3 15
|
||||||
|
cd "${tmpdir}" || exit 1
|
||||||
|
|
||||||
|
# assertion
|
||||||
|
cat << "DATA" > "${t}.assert"
|
||||||
|
orcli - OpenRefine command-line interface written in Bash
|
||||||
|
DATA
|
||||||
|
|
||||||
|
# action
|
||||||
|
orcli --help | head -n1 > "${t}.output"
|
||||||
|
|
||||||
|
# test
|
||||||
|
diff -u "${t}.assert" "${t}.output"
|
|
@ -1,23 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
t="import-csv"
|
||||||
|
|
||||||
# environment
|
# environment
|
||||||
t="$(basename "$(pwd)" .sh)"
|
tmpdir="$(mktemp -d)"
|
||||||
|
trap '{ rm -rf "${tmpdir}"; }' 0 2 3 15
|
||||||
# data
|
cp data/example.csv "${tmpdir}"/${t}.csv
|
||||||
cat << "DATA" > "${t}.csv"
|
cp data/example.tsv "${tmpdir}"/${t}.assert
|
||||||
a,b,c
|
cd "${tmpdir}" || exit 1
|
||||||
1,2,3
|
|
||||||
0,0,0
|
|
||||||
$,\,'
|
|
||||||
DATA
|
|
||||||
|
|
||||||
# assertion
|
|
||||||
cat << "DATA" > "${t}.assert"
|
|
||||||
a b c
|
|
||||||
1 2 3
|
|
||||||
0 0 0
|
|
||||||
$ \ '
|
|
||||||
DATA
|
|
||||||
|
|
||||||
# action
|
# action
|
||||||
orcli import csv "${t}.csv"
|
orcli import csv "${t}.csv"
|
||||||
|
|
Loading…
Reference in New Issue