Support cargo '+' flags in testing script.

This commit is contained in:
Sergio Benitez 2020-07-21 10:24:18 -07:00
parent 67efe143c5
commit 4a1a4c0e45
2 changed files with 39 additions and 24 deletions

View File

@ -76,23 +76,27 @@ ALL_PROJECT_DIRS=(
"${CONTRIB_LIB_ROOT}" "${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 if [ "${1}" = "-p" ]; then
echo "ROCKET_VERSION: ${ROCKET_VERSION}" print_environment
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)"
fi fi

View File

@ -7,6 +7,8 @@ source "${SCRIPT_DIR}/config.sh"
# Add Cargo to PATH. # Add Cargo to PATH.
export PATH=${HOME}/.cargo/bin:${PATH} export PATH=${HOME}/.cargo/bin:${PATH}
export CARGO_INCREMENTAL=0
CARGO="cargo"
# Checks that the versions for Cargo projects $@ all match # Checks that the versions for Cargo projects $@ all match
function check_versions_match() { function check_versions_match() {
@ -49,6 +51,15 @@ function ensure_trailing_whitespace_free() {
fi fi
} }
if [[ $1 == +* ]]; then
CARGO="$CARGO $1"
shift
fi
echo ":: Preparing. Environment is..."
print_environment
echo " CARGO: $CARGO"
echo ":: Ensuring all crate versions match..." echo ":: Ensuring all crate versions match..."
check_versions_match "${ALL_PROJECT_DIRS[@]}" check_versions_match "${ALL_PROJECT_DIRS[@]}"
@ -59,7 +70,7 @@ echo ":: Checking for trailing whitespace..."
ensure_trailing_whitespace_free ensure_trailing_whitespace_free
echo ":: Updating dependencies..." echo ":: Updating dependencies..."
cargo update $CARGO update
if [ "$1" = "--contrib" ]; then if [ "$1" = "--contrib" ]; then
FEATURES=( FEATURES=(
@ -83,11 +94,11 @@ if [ "$1" = "--contrib" ]; then
pushd "${CONTRIB_LIB_ROOT}" > /dev/null 2>&1 pushd "${CONTRIB_LIB_ROOT}" > /dev/null 2>&1
echo ":: Building and testing contrib [default]..." echo ":: Building and testing contrib [default]..."
CARGO_INCREMENTAL=0 cargo test $CARGO test
for feature in "${FEATURES[@]}"; do for feature in "${FEATURES[@]}"; do
echo ":: Building and testing contrib [${feature}]..." echo ":: Building and testing contrib [${feature}]..."
CARGO_INCREMENTAL=0 cargo test --no-default-features --features "${feature}" $CARGO test --no-default-features --features "${feature}"
done done
popd > /dev/null 2>&1 popd > /dev/null 2>&1
@ -100,16 +111,16 @@ elif [ "$1" = "--core" ]; then
pushd "${CORE_LIB_ROOT}" > /dev/null 2>&1 pushd "${CORE_LIB_ROOT}" > /dev/null 2>&1
echo ":: Building and testing core [no features]..." 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 for feature in "${FEATURES[@]}"; do
echo ":: Building and testing core [${feature}]..." echo ":: Building and testing core [${feature}]..."
CARGO_INCREMENTAL=0 cargo test --no-default-features --features "${feature}" $CARGO test --no-default-features --features "${feature}"
done done
popd > /dev/null 2>&1 popd > /dev/null 2>&1
else else
echo ":: Building and testing libraries..." echo ":: Building and testing libraries..."
CARGO_INCREMENTAL=0 cargo test --all-features --all $@ $CARGO test --all-features --all $@
fi fi