From 4a1a4c0e4599f675cc2a2df7db63003a3d5ec8d3 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Tue, 21 Jul 2020 10:24:18 -0700 Subject: [PATCH] Support cargo '+' flags in testing script. --- scripts/config.sh | 40 ++++++++++++++++++++++------------------ scripts/test.sh | 23 +++++++++++++++++------ 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/scripts/config.sh b/scripts/config.sh index 2e03d30e..be7d48a5 100755 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -76,23 +76,27 @@ ALL_PROJECT_DIRS=( "${CONTRIB_LIB_ROOT}" ) +function print_environment() { + echo " ROCKET_VERSION: ${ROCKET_VERSION}" + echo " CURRENT_RELEASE: ${CURRENT_RELEASE}" + echo " PRE_RELEASE: ${PRE_RELEASE}" + echo " VERSION_CODENAME: ${VERSION_CODENAME}" + echo " SCRIPT_DIR: ${SCRIPT_DIR}" + echo " PROJECT_ROOT: ${PROJECT_ROOT}" + echo " CORE_ROOT: ${CORE_ROOT}" + echo " CONTRIB_ROOT: ${CONTRIB_ROOT}" + echo " SITE_ROOT: ${SITE_ROOT}" + echo " CORE_LIB_ROOT: ${CORE_LIB_ROOT}" + echo " CORE_CODEGEN_ROOT: ${CORE_CODEGEN_ROOT}" + echo " CORE_HTTP_ROOT: ${CORE_HTTP_ROOT}" + echo " CONTRIB_LIB_ROOT: ${CONTRIB_LIB_ROOT}" + echo " CONTRIB_CODEGEN_ROOT: ${CONTRIB_CODEGEN_ROOT}" + echo " EXAMPLES_DIR: ${EXAMPLES_DIR}" + echo " DOC_DIR: ${DOC_DIR}" + echo " ALL_PROJECT_DIRS: ${ALL_PROJECT_DIRS[*]}" + echo " date(): $(future_date)" +} + if [ "${1}" = "-p" ]; then - echo "ROCKET_VERSION: ${ROCKET_VERSION}" - echo "CURRENT_RELEASE: ${CURRENT_RELEASE}" - echo "PRE_RELEASE: ${PRE_RELEASE}" - echo "VERSION_CODENAME: ${VERSION_CODENAME}" - echo "SCRIPT_DIR: ${SCRIPT_DIR}" - echo "PROJECT_ROOT: ${PROJECT_ROOT}" - echo "CORE_ROOT: ${CORE_ROOT}" - echo "CONTRIB_ROOT: ${CONTRIB_ROOT}" - echo "SITE_ROOT: ${SITE_ROOT}" - echo "CORE_LIB_ROOT: ${CORE_LIB_ROOT}" - echo "CORE_CODEGEN_ROOT: ${CORE_CODEGEN_ROOT}" - echo "CORE_HTTP_ROOT: ${CORE_HTTP_ROOT}" - echo "CONTRIB_LIB_ROOT: ${CONTRIB_LIB_ROOT}" - echo "CONTRIB_CODEGEN_ROOT: ${CONTRIB_CODEGEN_ROOT}" - echo "EXAMPLES_DIR: ${EXAMPLES_DIR}" - echo "DOC_DIR: ${DOC_DIR}" - echo "ALL_PROJECT_DIRS: ${ALL_PROJECT_DIRS[*]}" - echo "date(): $(future_date)" + print_environment fi diff --git a/scripts/test.sh b/scripts/test.sh index 3110477b..e9459b06 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -7,6 +7,8 @@ source "${SCRIPT_DIR}/config.sh" # Add Cargo to PATH. export PATH=${HOME}/.cargo/bin:${PATH} +export CARGO_INCREMENTAL=0 +CARGO="cargo" # Checks that the versions for Cargo projects $@ all match function check_versions_match() { @@ -49,6 +51,15 @@ function ensure_trailing_whitespace_free() { fi } +if [[ $1 == +* ]]; then + CARGO="$CARGO $1" + shift +fi + +echo ":: Preparing. Environment is..." +print_environment +echo " CARGO: $CARGO" + echo ":: Ensuring all crate versions match..." check_versions_match "${ALL_PROJECT_DIRS[@]}" @@ -59,7 +70,7 @@ echo ":: Checking for trailing whitespace..." ensure_trailing_whitespace_free echo ":: Updating dependencies..." -cargo update +$CARGO update if [ "$1" = "--contrib" ]; then FEATURES=( @@ -83,11 +94,11 @@ if [ "$1" = "--contrib" ]; then pushd "${CONTRIB_LIB_ROOT}" > /dev/null 2>&1 echo ":: Building and testing contrib [default]..." - CARGO_INCREMENTAL=0 cargo test + $CARGO test for feature in "${FEATURES[@]}"; do echo ":: Building and testing contrib [${feature}]..." - CARGO_INCREMENTAL=0 cargo test --no-default-features --features "${feature}" + $CARGO test --no-default-features --features "${feature}" done popd > /dev/null 2>&1 @@ -100,16 +111,16 @@ elif [ "$1" = "--core" ]; then pushd "${CORE_LIB_ROOT}" > /dev/null 2>&1 echo ":: Building and testing core [no features]..." - CARGO_INCREMENTAL=0 cargo test --no-default-features + $CARGO test --no-default-features for feature in "${FEATURES[@]}"; do echo ":: Building and testing core [${feature}]..." - CARGO_INCREMENTAL=0 cargo test --no-default-features --features "${feature}" + $CARGO test --no-default-features --features "${feature}" done popd > /dev/null 2>&1 else echo ":: Building and testing libraries..." - CARGO_INCREMENTAL=0 cargo test --all-features --all $@ + $CARGO test --all-features --all $@ fi