Clean up run_docker_integration_test.bash
This commit is contained in:
parent
5768c8acda
commit
306878c95d
@ -29,7 +29,6 @@ function launch_container {
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
IFS=\$'\n\t'
|
IFS=\$'\n\t'
|
||||||
|
|
||||||
cd /source
|
|
||||||
export CARGO_TARGET_DIR=/target
|
export CARGO_TARGET_DIR=/target
|
||||||
cargo run -- /input.org
|
cargo run -- /input.org
|
||||||
EOF
|
EOF
|
||||||
@ -40,7 +39,10 @@ EOF
|
|||||||
else
|
else
|
||||||
additional_flags+=(-i -t)
|
additional_flags+=(-i -t)
|
||||||
fi
|
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[@]}"
|
|
||||||
|
# TODO: add support for reporting to jaeger with RUST_BACKTRACE=1 RUST_LOG=debug
|
||||||
|
|
||||||
|
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 /source organic-test "${additional_args[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
main "${@}"
|
main "${@}"
|
||||||
|
@ -4,17 +4,33 @@ set -euo pipefail
|
|||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
cd "$DIR/../"
|
||||||
REALPATH=$(command -v uu-realpath || command -v realpath)
|
REALPATH=$(command -v uu-realpath || command -v realpath)
|
||||||
|
MAKE=$(command -v gmake || command -v make)
|
||||||
|
|
||||||
samples_dir=$(readlink -f "$DIR/../org_mode_samples")
|
function main {
|
||||||
|
local test_names=$(get_test_names "${@}")
|
||||||
|
build_container
|
||||||
|
|
||||||
|
local test
|
||||||
|
while read test; do
|
||||||
|
launch_container "$test"
|
||||||
|
done<<<"$test_names"
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_container {
|
||||||
|
$MAKE -C "$DIR/../docker/organic_test"
|
||||||
|
}
|
||||||
|
|
||||||
function get_test_names {
|
function get_test_names {
|
||||||
|
local test_file
|
||||||
|
local samples_dir=$($REALPATH "$DIR/../org_mode_samples")
|
||||||
for test_file in "$@"
|
for test_file in "$@"
|
||||||
do
|
do
|
||||||
if [ -e "$test_file" ]; then
|
if [ -e "$test_file" ]; then
|
||||||
test_file_full_path=$(readlink -f "$test_file")
|
local test_file_full_path=$($REALPATH "$test_file")
|
||||||
relative_to_samples=$($REALPATH --relative-to "$samples_dir" "$test_file_full_path")
|
local relative_to_samples=$($REALPATH --relative-to "$samples_dir" "$test_file_full_path")
|
||||||
without_extension="${relative_to_samples%.org}"
|
local without_extension="${relative_to_samples%.org}"
|
||||||
echo "${without_extension/\//_}" | tr '[:upper:]' '[:lower:]'
|
echo "${without_extension/\//_}" | tr '[:upper:]' '[:lower:]'
|
||||||
else
|
else
|
||||||
echo "$test_file" | tr '[:upper:]' '[:lower:]'
|
echo "$test_file" | tr '[:upper:]' '[:lower:]'
|
||||||
@ -22,11 +38,21 @@ function get_test_names {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
make -C "$DIR/../docker/organic_test"
|
function launch_container {
|
||||||
|
local test="$1"
|
||||||
|
local additional_args=()
|
||||||
|
|
||||||
get_test_names "$@" | while read test; do
|
local init_script=$(cat <<EOF
|
||||||
(
|
set -euo pipefail
|
||||||
cd "$DIR/../"
|
IFS=\$'\n\t'
|
||||||
docker run --rm -v "$(readlink -f ./):/.source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry -w / organic-test sh -c "cp -r /.source /source && cd /source && cargo test --no-fail-fast --lib --test test_loader \"$test\" -- --show-output"
|
|
||||||
)
|
export CARGO_TARGET_DIR=/target
|
||||||
done
|
cargo test --no-fail-fast --lib --test test_loader "$test" -- --show-output
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
docker run --rm -v "$($REALPATH ./):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target -w /source organic-test sh -c "$init_script"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
main "${@}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user