Check fuzzers and benchmarks in testing script.

This commit is contained in:
Sergio Benitez 2021-06-07 17:53:57 -07:00
parent 0aa9a11ca4
commit 2d974ece78
2 changed files with 31 additions and 28 deletions

View File

@ -41,6 +41,7 @@ CORE_ROOT=$(relative "core") || exit $?
CONTRIB_ROOT=$(relative "contrib") || exit $? CONTRIB_ROOT=$(relative "contrib") || exit $?
SITE_ROOT=$(relative "site") || exit $? SITE_ROOT=$(relative "site") || exit $?
BENCHMARKS_ROOT=$(relative "benchmarks") || exit $? BENCHMARKS_ROOT=$(relative "benchmarks") || exit $?
FUZZ_ROOT=$(relative "core/lib/fuzz") || exit $?
# Root of project-like directories. # Root of project-like directories.
CORE_LIB_ROOT=$(relative "core/lib") || exit $? CORE_LIB_ROOT=$(relative "core/lib") || exit $?

View File

@ -58,6 +58,12 @@ function check_style() {
fi fi
} }
function indir() {
local dir="${1}"
shift
pushd "${dir}" > /dev/null 2>&1 ; $@ ; popd > /dev/null 2>&1
}
function test_contrib() { function test_contrib() {
SYNC_DB_POOLS_FEATURES=( SYNC_DB_POOLS_FEATURES=(
diesel_postgres_pool diesel_postgres_pool
@ -93,43 +99,39 @@ function test_core() {
uuid uuid
) )
pushd "${CORE_LIB_ROOT}" > /dev/null 2>&1
echo ":: Building and testing core [no features]..." echo ":: Building and testing core [no features]..."
$CARGO test --no-default-features $@ indir "${CORE_LIB_ROOT}" $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 test --no-default-features --features "${feature}" $@ indir "${CORE_LIB_ROOT}" $CARGO test --no-default-features --features "${feature}" $@
done done
popd > /dev/null 2>&1
} }
function test_examples() { function test_examples() {
# Cargo compiles Rocket once with the `secrets` feature enabled, so when run
# in production, we need a secret key or tests will fail needlessly. We test
# in core that secret key failing/not failing works as expected, but here we
# provide a valid secret_key so tests don't fail.
echo ":: Building and testing examples..." echo ":: Building and testing examples..."
pushd "${EXAMPLES_DIR}" > /dev/null 2>&1
# Rust compiles Rocket once with the `secrets` feature enabled, so when run
# in production, we need a secret key or tests will fail needlessly. We
# test in core that secret key failing/not failing works as expected.
ROCKET_SECRET_KEY="itlYmFR2vYKrOmFhupMIn/hyB6lYCCTXz4yaQX89XVg=" \ ROCKET_SECRET_KEY="itlYmFR2vYKrOmFhupMIn/hyB6lYCCTXz4yaQX89XVg=" \
$CARGO test --all $@ indir "${EXAMPLES_DIR}" $CARGO test --all $@
popd > /dev/null 2>&1 }
}
function test_default() { function test_default() {
echo ":: Building and testing core libraries..." echo ":: Building and testing core libraries..."
indir "${PROJECT_ROOT}" $CARGO test --all --all-features $@
pushd "${PROJECT_ROOT}" > /dev/null 2>&1 echo ":: Checking benchmarks..."
$CARGO test --all --all-features $@ indir "${BENCHMARKS_ROOT}" $CARGO check --benches --all-features $@
popd > /dev/null 2>&1
echo ":: Checking fuzzers..."
indir "${FUZZ_ROOT}" $CARGO check --all --all-features $@
} }
function run_benchmarks() { function run_benchmarks() {
echo ":: Running benchmarks..." echo ":: Running benchmarks..."
indir "${BENCHMARKS_ROOT}" $CARGO bench $@
pushd "${BENCHMARKS_ROOT}" > /dev/null 2>&1
$CARGO bench $@
popd > /dev/null 2>&1
} }
if [[ $1 == +* ]]; then if [[ $1 == +* ]]; then