organic/scripts/run_integration_test.bash

36 lines
982 B
Bash
Raw Normal View History

#!/usr/bin/env bash
#
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2023-08-14 19:53:17 +00:00
cd "$DIR/../"
REALPATH=$(command -v uu-realpath || command -v realpath)
2023-08-14 19:53:17 +00:00
function main {
local test_names=$(get_test_names "${@}")
local test
while read test; do
cargo test --no-fail-fast --test test_loader "$test" -- --show-output
done<<<"$test_names"
}
function get_test_names {
2023-08-14 19:53:17 +00:00
local test_file
local samples_dir=$($REALPATH "$DIR/../org_mode_samples")
for test_file in "$@"
do
if [ -e "$test_file" ]; then
2023-08-14 19:53:17 +00:00
local test_file_full_path=$($REALPATH "$test_file")
local relative_to_samples=$($REALPATH --relative-to "$samples_dir" "$test_file_full_path")
local without_extension="${relative_to_samples%.org}"
echo "${without_extension/\//_}" | tr '[:upper:]' '[:lower:]'
else
echo "$test_file" | tr '[:upper:]' '[:lower:]'
fi
done
}
2023-08-14 19:53:17 +00:00
main "${@}"