47 lines
1.1 KiB
Bash
Executable File
47 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
set -euo pipefail
|
|
IFS=$'\n\t'
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
: ${SHELL:="NO"} # or YES to launch a shell instead of running the test
|
|
|
|
cd "$DIR/../"
|
|
REALPATH=$(command -v uu-realpath || command -v realpath)
|
|
MAKE=$(command -v gmake || command -v make)
|
|
|
|
function main {
|
|
local org_file="$($REALPATH "$1")"
|
|
build_container
|
|
launch_container "$org_file"
|
|
}
|
|
|
|
function build_container {
|
|
$MAKE -C "$DIR/../docker/organic_test"
|
|
}
|
|
|
|
function launch_container {
|
|
local org_file="$1"
|
|
local additional_flags=()
|
|
local additional_args=()
|
|
|
|
local init_script=$(cat <<EOF
|
|
set -euo pipefail
|
|
IFS=\$'\n\t'
|
|
|
|
cd /source
|
|
export CARGO_TARGET_DIR=/target
|
|
cargo run -- /input.org
|
|
EOF
|
|
)
|
|
|
|
if [ "$SHELL" != "YES" ]; then
|
|
additional_args+=(sh -c "$init_script")
|
|
else
|
|
additional_flags+=(-i -t)
|
|
fi
|
|
docker run "${additional_flags[@]}" --rm -v "${org_file}:/input.org:ro" -v "$($REALPATH ./):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target -w / organic-test "${additional_args[@]}"
|
|
}
|
|
|
|
main "${@}"
|