53 lines
1.5 KiB
Bash
Executable File
53 lines
1.5 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
|
|
: ${TRACE:="NO"} # or YES to send traces to jaeger
|
|
: ${BACKTRACE:="NO"} # or YES to print a rust backtrace when panicking
|
|
: ${NO_COLOR:=""} # Set to anything to disable color output
|
|
|
|
|
|
cd "$DIR/../"
|
|
REALPATH=$(command -v uu-realpath || command -v realpath)
|
|
MAKE=$(command -v gmake || command -v make)
|
|
|
|
function main {
|
|
build_container
|
|
launch_container
|
|
}
|
|
|
|
function build_container {
|
|
$MAKE -C "$DIR/../docker/organic_test"
|
|
}
|
|
|
|
function launch_container {
|
|
local additional_flags=()
|
|
local additional_args=()
|
|
|
|
if [ "$NO_COLOR" != "" ]; then
|
|
additional_flags+=(--env "NO_COLOR=$NO_COLOR")
|
|
fi
|
|
|
|
if [ "$SHELL" != "YES" ]; then
|
|
additional_args+=(cargo run)
|
|
else
|
|
additional_flags+=(-t)
|
|
fi
|
|
|
|
if [ "$TRACE" = "YES" ]; then
|
|
# We use the host network so it can talk to jaeger hosted at 127.0.0.1
|
|
additional_flags+=(--network=host --env RUST_LOG=debug)
|
|
fi
|
|
|
|
if [ "$BACKTRACE" = "YES" ]; then
|
|
additional_flags+=(--env RUST_BACKTRACE=full)
|
|
fi
|
|
|
|
docker run "${additional_flags[@]}" --init --rm -i -v "$($REALPATH ./):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test "${additional_args[@]}"
|
|
}
|
|
|
|
main "${@}"
|