36bdc54703
This also switches to using stdin rather than writing the file slices to the filesystem.
82 lines
3.0 KiB
Bash
Executable File
82 lines
3.0 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
|
|
|
|
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=()
|
|
local features=(compare)
|
|
|
|
if [ "$NO_COLOR" != "" ]; then
|
|
additional_flags+=(--env "NO_COLOR=$NO_COLOR")
|
|
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)
|
|
features+=(tracing)
|
|
fi
|
|
|
|
if [ "$SHELL" != "YES" ]; then
|
|
local features_joined
|
|
features_joined=$(IFS=","; echo "${features[*]}")
|
|
additional_args+=(cargo build --bin compare --no-default-features --features "$features_joined")
|
|
additional_flags+=(--read-only)
|
|
else
|
|
additional_args+=(/bin/sh)
|
|
additional_flags+=(-t)
|
|
fi
|
|
|
|
if [ "$BACKTRACE" = "YES" ]; then
|
|
additional_flags+=(--env RUST_BACKTRACE=full)
|
|
fi
|
|
|
|
if [ $# -gt 0 ]; then
|
|
# If we passed in args, we need to forward them along
|
|
for path in "${@}"; do
|
|
local full_path
|
|
full_path=$($REALPATH "$path")
|
|
docker run "${additional_flags[@]}" --init --rm -i --mount type=tmpfs,destination=/tmp -v "/:/input:ro" -v "$($REALPATH "$DIR/../"):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source --entrypoint "" organic-test "${additional_args[@]}" -- "/input${full_path}"
|
|
done
|
|
else
|
|
if [ "$SHELL" != "YES" ]; then
|
|
local current_directory init_script
|
|
current_directory=$(pwd)
|
|
init_script=$(cat <<EOF
|
|
set -euo pipefail
|
|
IFS=\$'\n\t'
|
|
|
|
${@}
|
|
cd /input${current_directory}
|
|
exec /target/debug/compare
|
|
EOF
|
|
)
|
|
|
|
docker run "${additional_flags[@]}" --init --rm -i --mount type=tmpfs,destination=/tmp -v "/:/input:ro" -v "$($REALPATH "$DIR/../"):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source --entrypoint "" organic-test sh -c "$init_script" "${additional_args[@]}"
|
|
else
|
|
docker run "${additional_flags[@]}" --init --rm -i --mount type=tmpfs,destination=/tmp -v "/:/input:ro" -v "$($REALPATH "$DIR/../"):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source --entrypoint "" organic-test "${additional_args[@]}"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
main "${@}"
|