From 422804d8467ea1b5816162cb69493297b2994e50 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 14 Aug 2023 12:18:55 -0400 Subject: [PATCH] Add script for running specific tests inside docker. --- Makefile | 4 +-- scripts/run_docker_integration_test.bash | 31 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100755 scripts/run_docker_integration_test.bash diff --git a/Makefile b/Makefile index cc8d53f..2eb2466 100644 --- a/Makefile +++ b/Makefile @@ -35,12 +35,12 @@ clean: .PHONY: test test: -> cargo test --lib --test test_loader -- --test-threads $(TESTJOBS) +> cargo test --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS) .PHONY: dockertest dockertest: > $(MAKE) -C docker/organic_test -> docker run --rm -i -t -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 --lib --test test_loader" +> docker run --rm -i -t -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" .PHONY: integrationtest integrationtest: diff --git a/scripts/run_docker_integration_test.bash b/scripts/run_docker_integration_test.bash new file mode 100755 index 0000000..0d587dc --- /dev/null +++ b/scripts/run_docker_integration_test.bash @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +REALPATH=$(command -v uu-realpath || command -v realpath) + +samples_dir=$(readlink -f "$DIR/../org_mode_samples") + +function get_test_names { + for test_file in "$@" + do + if [ -e "$test_file" ]; then + test_file_full_path=$(readlink -f "$test_file") + relative_to_samples=$($REALPATH --relative-to "$samples_dir" "$test_file_full_path") + without_extension="${relative_to_samples%.org}" + echo "${without_extension/\//_}" | tr '[:upper:]' '[:lower:]' + else + echo "$test_file" | tr '[:upper:]' '[:lower:]' + fi + done +} + +get_test_names "$@" | while read test; do + ( + cd "$DIR/../" + make -C docker/organic_test + 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" + ) +done