2017-04-06 22:59:41 +00:00
|
|
|
#!/usr/bin/env bash
|
2016-03-18 03:18:16 +00:00
|
|
|
set -e
|
|
|
|
|
2018-06-07 13:34:47 +00:00
|
|
|
# Brings in _ROOT, _DIR, _DIRS globals.
|
2016-10-02 08:18:37 +00:00
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2017-07-29 04:34:59 +00:00
|
|
|
source "${SCRIPT_DIR}/config.sh"
|
2016-03-18 03:18:16 +00:00
|
|
|
|
2016-08-07 03:59:51 +00:00
|
|
|
# Add Cargo to PATH.
|
|
|
|
export PATH=${HOME}/.cargo/bin:${PATH}
|
2020-07-21 17:24:18 +00:00
|
|
|
export CARGO_INCREMENTAL=0
|
2022-04-19 04:15:03 +00:00
|
|
|
export RUSTC_BOOTSTRAP=1
|
2020-07-21 17:24:18 +00:00
|
|
|
CARGO="cargo"
|
2016-08-07 03:59:51 +00:00
|
|
|
|
2016-09-30 03:50:06 +00:00
|
|
|
# Checks that the versions for Cargo projects $@ all match
|
|
|
|
function check_versions_match() {
|
|
|
|
local last_version=""
|
2017-07-29 04:34:59 +00:00
|
|
|
for dir in "${@}"; do
|
2016-09-30 03:50:06 +00:00
|
|
|
local cargo_toml="${dir}/Cargo.toml"
|
|
|
|
if ! [ -f "${cargo_toml}" ]; then
|
|
|
|
echo "Cargo configuration file '${cargo_toml}' does not exist."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-07-29 04:34:59 +00:00
|
|
|
local version=$(grep version "${cargo_toml}" | head -n 1 | cut -d' ' -f3)
|
2016-09-30 03:50:06 +00:00
|
|
|
if [ -z "${last_version}" ]; then
|
|
|
|
last_version="${version}"
|
|
|
|
elif ! [ "${version}" = "${last_version}" ]; then
|
|
|
|
echo "Versions differ in '${cargo_toml}'. ${version} != ${last_version}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2021-04-28 02:54:10 +00:00
|
|
|
function check_style() {
|
|
|
|
# Ensure there are no tabs in any file.
|
2016-12-29 04:47:15 +00:00
|
|
|
local tab=$(printf '\t')
|
2023-01-30 22:41:03 +00:00
|
|
|
local matches=$(git grep -PIn "${tab}" "${PROJECT_ROOT}" | grep -v 'LICENSE')
|
2016-12-29 04:33:56 +00:00
|
|
|
if ! [ -z "${matches}" ]; then
|
|
|
|
echo "Tab characters were found in the following:"
|
|
|
|
echo "${matches}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-04-28 02:54:10 +00:00
|
|
|
# Ensure non-comment lines are under 100 characters.
|
|
|
|
local n=100
|
2023-01-30 22:41:03 +00:00
|
|
|
local matches=$(git grep -PIn "(?=^..{$n,}$)(?!^\s*\/\/[\/!].*$).*" '*.rs')
|
2021-04-28 02:54:10 +00:00
|
|
|
if ! [ -z "${matches}" ]; then
|
|
|
|
echo "Lines longer than $n characters were found in the following:"
|
|
|
|
echo "${matches}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ensure there's no trailing whitespace.
|
2023-01-30 22:41:03 +00:00
|
|
|
local matches=$(git grep -PIn "\s+$" "${PROJECT_ROOT}" | grep -v -F '.stderr:')
|
2017-03-16 02:26:15 +00:00
|
|
|
if ! [ -z "${matches}" ]; then
|
|
|
|
echo "Trailing whitespace was found in the following:"
|
|
|
|
echo "${matches}"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-06-08 01:27:31 +00:00
|
|
|
|
|
|
|
local pattern='tail -n 1 % | grep -q "^$" && echo %'
|
|
|
|
local matches=$(git grep -z -Il '' | xargs -0 -P 16 -I % sh -c "${pattern}")
|
|
|
|
if ! [ -z "${matches}" ]; then
|
|
|
|
echo "Trailing new line(s) found in the following:"
|
|
|
|
echo "${matches}"
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-03-16 02:26:15 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 00:53:57 +00:00
|
|
|
function indir() {
|
|
|
|
local dir="${1}"
|
|
|
|
shift
|
|
|
|
pushd "${dir}" > /dev/null 2>&1 ; $@ ; popd > /dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
function test_contrib() {
|
2021-05-31 16:15:00 +00:00
|
|
|
DB_POOLS_FEATURES=(
|
2021-07-09 23:34:54 +00:00
|
|
|
deadpool_postgres
|
|
|
|
deadpool_redis
|
2021-05-31 16:15:00 +00:00
|
|
|
sqlx_mysql
|
|
|
|
sqlx_postgres
|
|
|
|
sqlx_sqlite
|
2021-07-09 23:34:54 +00:00
|
|
|
mongodb
|
2023-06-09 23:46:24 +00:00
|
|
|
diesel_mysql
|
|
|
|
diesel_postgres
|
2021-05-31 16:15:00 +00:00
|
|
|
)
|
|
|
|
|
2021-05-25 01:58:05 +00:00
|
|
|
SYNC_DB_POOLS_FEATURES=(
|
2018-08-18 23:52:45 +00:00
|
|
|
diesel_postgres_pool
|
|
|
|
diesel_sqlite_pool
|
|
|
|
diesel_mysql_pool
|
|
|
|
postgres_pool
|
|
|
|
sqlite_pool
|
2019-01-04 16:19:09 +00:00
|
|
|
memcache_pool
|
2018-08-18 23:52:45 +00:00
|
|
|
)
|
2017-01-15 10:33:45 +00:00
|
|
|
|
2021-05-25 01:58:05 +00:00
|
|
|
DYN_TEMPLATES_FEATURES=(
|
|
|
|
tera
|
|
|
|
handlebars
|
2024-03-26 02:06:50 +00:00
|
|
|
minijinja
|
2021-05-25 01:58:05 +00:00
|
|
|
)
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
|
2023-04-01 22:02:24 +00:00
|
|
|
WS_FEATURES=(
|
|
|
|
tungstenite
|
|
|
|
)
|
|
|
|
|
2021-05-31 16:15:00 +00:00
|
|
|
for feature in "${DB_POOLS_FEATURES[@]}"; do
|
|
|
|
echo ":: Building and testing db_pools [$feature]..."
|
|
|
|
$CARGO test -p rocket_db_pools --no-default-features --features $feature $@
|
|
|
|
done
|
|
|
|
|
2021-05-25 01:58:05 +00:00
|
|
|
for feature in "${SYNC_DB_POOLS_FEATURES[@]}"; do
|
|
|
|
echo ":: Building and testing sync_db_pools [$feature]..."
|
|
|
|
$CARGO test -p rocket_sync_db_pools --no-default-features --features $feature $@
|
|
|
|
done
|
2018-08-18 23:52:45 +00:00
|
|
|
|
2021-05-25 01:58:05 +00:00
|
|
|
for feature in "${DYN_TEMPLATES_FEATURES[@]}"; do
|
|
|
|
echo ":: Building and testing dyn_templates [$feature]..."
|
|
|
|
$CARGO test -p rocket_dyn_templates --no-default-features --features $feature $@
|
|
|
|
done
|
2023-04-01 22:02:24 +00:00
|
|
|
|
|
|
|
for feature in "${WS_FEATURES[@]}"; do
|
|
|
|
echo ":: Building and testing ws [$feature]..."
|
|
|
|
$CARGO test -p rocket_ws --no-default-features --features $feature $@
|
|
|
|
done
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_core() {
|
2018-11-05 20:29:03 +00:00
|
|
|
FEATURES=(
|
Update to hyper 1. Enable custom + unix listeners.
This commit completely rewrites Rocket's HTTP serving. In addition to
significant internal cleanup, this commit introduces the following major
features:
* Support for custom, external listeners in the `listener` module.
The new `listener` module contains new `Bindable`, `Listener`, and
`Connection` traits which enable composable, external
implementations of connection listeners. Rocket can launch on any
`Listener`, or anything that can be used to create a listener
(`Bindable`), via a new `launch_on()` method.
* Support for Unix domain socket listeners out of the box.
The default listener backwards compatibly supports listening on Unix
domain sockets. To do so, configure an `address` of
`unix:path/to/socket` and optional set `reuse` to `true` (the
default) or `false` which controls whether Rocket will handle
creating and deleting the unix domain socket.
In addition to these new features, this commit makes the following major
improvements:
* Rocket now depends on hyper 1.
* Rocket no longer depends on hyper to handle connections. This allows
us to handle more connection failure conditions which results in an
overall more robust server with fewer dependencies.
* Logic to work around hyper's inability to reference incoming request
data in the response results in a 15% performance improvement.
* `Client`s can be marked secure with `Client::{un}tracked_secure()`,
allowing Rocket to treat local connections as running under TLS.
* The `macros` feature of `tokio` is no longer used by Rocket itself.
Dependencies can take advantage of this reduction in compile-time
cost by disabling the new default feature `tokio-macros`.
* A new `TlsConfig::validate()` method allows checking a TLS config.
* New `TlsConfig::{certs,key}_reader()`,
`MtlsConfig::ca_certs_reader()` methods return `BufReader`s, which
allow reading the configured certs and key directly.
* A new `NamedFile::open_with()` constructor allows specifying
`OpenOptions`.
These improvements resulted in the following breaking changes:
* The MSRV is now 1.74.
* `hyper` is no longer exported from `rocket::http`.
* `IoHandler::io` takes `Box<Self>` instead of `Pin<Box<Self>>`.
- Use `Box::into_pin(self)` to recover the previous type.
* `Response::upgrade()` now returns an `&mut dyn IoHandler`, not
`Pin<& mut _>`.
* `Config::{address,port,tls,mtls}` methods have been removed.
- Use methods on `Rocket::endpoint()` instead.
* `TlsConfig` was moved to `tls::TlsConfig`.
* `MutualTls` was renamed and moved to `mtls::MtlsConfig`.
* `ErrorKind::TlsBind` was removed.
* The second field of `ErrorKind::Shutdown` was removed.
* `{Local}Request::{set_}remote()` methods take/return an `Endpoint`.
* `Client::new()` was removed; it was previously deprecated.
Internally, the following major changes were made:
* A new `async_bound` attribute macro was introduced to allow setting
bounds on futures returned by `async fn`s in traits while
maintaining good docs.
* All utility functionality was moved to a new `util` module.
Resolves #2671.
Resolves #1070.
2023-12-19 22:32:11 +00:00
|
|
|
tokio-macros
|
|
|
|
http2
|
2024-03-19 03:19:00 +00:00
|
|
|
http3-preview
|
2020-07-22 19:21:19 +00:00
|
|
|
secrets
|
2018-11-05 20:29:03 +00:00
|
|
|
tls
|
2021-07-09 06:59:47 +00:00
|
|
|
mtls
|
2021-04-29 12:19:24 +00:00
|
|
|
json
|
|
|
|
msgpack
|
2021-05-21 21:29:43 +00:00
|
|
|
uuid
|
2024-05-03 02:12:25 +00:00
|
|
|
trace
|
2018-11-05 20:29:03 +00:00
|
|
|
)
|
|
|
|
|
2021-07-01 03:44:58 +00:00
|
|
|
echo ":: Building and checking core [no features]..."
|
|
|
|
RUSTDOCFLAGS="-Zunstable-options --no-run" \
|
|
|
|
indir "${CORE_LIB_ROOT}" $CARGO test --no-default-features $@
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
|
2021-06-08 00:53:57 +00:00
|
|
|
for feature in "${FEATURES[@]}"; do
|
2021-07-01 03:44:58 +00:00
|
|
|
echo ":: Building and checking core [${feature}]..."
|
|
|
|
RUSTDOCFLAGS="-Zunstable-options --no-run" \
|
|
|
|
indir "${CORE_LIB_ROOT}" $CARGO test --no-default-features --features "${feature}" $@
|
2021-06-08 00:53:57 +00:00
|
|
|
done
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_examples() {
|
2021-06-08 00:53:57 +00:00
|
|
|
# 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.
|
2021-03-09 23:32:04 +00:00
|
|
|
echo ":: Building and testing examples..."
|
2021-06-09 10:52:44 +00:00
|
|
|
indir "${EXAMPLES_DIR}" $CARGO update
|
2021-06-08 00:53:57 +00:00
|
|
|
ROCKET_SECRET_KEY="itlYmFR2vYKrOmFhupMIn/hyB6lYCCTXz4yaQX89XVg=" \
|
|
|
|
indir "${EXAMPLES_DIR}" $CARGO test --all $@
|
2023-01-30 22:15:24 +00:00
|
|
|
}
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
|
|
|
|
function test_default() {
|
2021-03-09 23:32:04 +00:00
|
|
|
echo ":: Building and testing core libraries..."
|
2021-06-08 00:53:57 +00:00
|
|
|
indir "${PROJECT_ROOT}" $CARGO test --all --all-features $@
|
|
|
|
|
|
|
|
echo ":: Checking benchmarks..."
|
2021-06-09 10:52:44 +00:00
|
|
|
indir "${BENCHMARKS_ROOT}" $CARGO update
|
2021-06-08 00:53:57 +00:00
|
|
|
indir "${BENCHMARKS_ROOT}" $CARGO check --benches --all-features $@
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
|
2021-06-08 00:53:57 +00:00
|
|
|
echo ":: Checking fuzzers..."
|
2021-06-09 10:52:44 +00:00
|
|
|
indir "${FUZZ_ROOT}" $CARGO update
|
2021-06-08 00:53:57 +00:00
|
|
|
indir "${FUZZ_ROOT}" $CARGO check --all --all-features $@
|
2024-04-16 09:39:52 +00:00
|
|
|
|
|
|
|
case "$OSTYPE" in
|
|
|
|
darwin* | linux*)
|
|
|
|
echo ":: Checking testbench..."
|
|
|
|
indir "${TESTBENCH_ROOT}" $CARGO update
|
|
|
|
indir "${TESTBENCH_ROOT}" $CARGO check $@
|
|
|
|
;;
|
|
|
|
*) echo ":: Skipping testbench [$OSTYPE]" ;;
|
|
|
|
esac
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
}
|
|
|
|
|
2023-01-30 22:15:24 +00:00
|
|
|
function test_ui() {
|
|
|
|
echo ":: Testing compile-time UI output..."
|
2024-05-02 22:11:00 +00:00
|
|
|
indir "${PROJECT_ROOT}" $CARGO test --test ui-fail --all --all-features -- --ignored $@
|
2023-01-30 22:15:24 +00:00
|
|
|
}
|
|
|
|
|
2021-03-27 03:12:19 +00:00
|
|
|
function run_benchmarks() {
|
|
|
|
echo ":: Running benchmarks..."
|
2021-06-09 10:52:44 +00:00
|
|
|
indir "${BENCHMARKS_ROOT}" $CARGO update
|
2021-06-08 00:53:57 +00:00
|
|
|
indir "${BENCHMARKS_ROOT}" $CARGO bench $@
|
2021-03-27 03:12:19 +00:00
|
|
|
}
|
|
|
|
|
2024-04-12 10:11:10 +00:00
|
|
|
function run_testbench() {
|
|
|
|
echo ":: Running testbench..."
|
|
|
|
indir "${TESTBENCH_ROOT}" $CARGO update
|
|
|
|
indir "${TESTBENCH_ROOT}" $CARGO run $@
|
|
|
|
}
|
|
|
|
|
2024-08-10 01:48:11 +00:00
|
|
|
# The kind of test we'll be running.
|
|
|
|
TEST_KIND="default"
|
|
|
|
KINDS=("default" "all" "core" "contrib" "examples" "benchmarks" "testbench" "ui")
|
|
|
|
|
|
|
|
function print_help() {
|
|
|
|
echo "USAGE:"
|
|
|
|
echo " $0 [+<TOOLCHAIN>] [--help|-h] [--<TEST>]"
|
|
|
|
echo ""
|
|
|
|
echo "OPTIONS:"
|
|
|
|
echo " +<TOOLCHAIN> Forwarded to Cargo to select toolchain."
|
|
|
|
echo " --help, -h Print this help message and exit."
|
|
|
|
echo " --<TEST> Run the specified test suite."
|
|
|
|
echo " (Run without --<TEST> to run default tests.)"
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "AVAILABLE <TEST> OPTIONS:"
|
|
|
|
for kind in "${KINDS[@]}"; do
|
|
|
|
echo " ${kind}"
|
|
|
|
done
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "EXAMPLES:"
|
|
|
|
echo " $0 # Run default tests on current toolchain."
|
|
|
|
echo " $0 +stable --all # Run all tests on stable toolchain."
|
|
|
|
echo " $0 --ui # Run UI tests on current toolchain."
|
|
|
|
}
|
|
|
|
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
if [[ $1 == +* ]]; then
|
2021-06-08 00:53:57 +00:00
|
|
|
CARGO="$CARGO $1"
|
|
|
|
shift
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
fi
|
|
|
|
|
2024-08-10 01:48:11 +00:00
|
|
|
if [[ $1 == "--help" ]] || [[ $1 == "-h" ]]; then
|
|
|
|
print_help
|
|
|
|
exit 0
|
|
|
|
fi
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
|
|
|
|
if [[ " ${KINDS[@]} " =~ " ${1#"--"} " ]]; then
|
2021-06-08 00:53:57 +00:00
|
|
|
TEST_KIND=${1#"--"}
|
|
|
|
shift
|
2018-08-18 23:52:45 +00:00
|
|
|
fi
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
|
|
|
|
echo ":: Preparing. Environment is..."
|
|
|
|
print_environment
|
|
|
|
echo " CARGO: $CARGO"
|
|
|
|
echo " EXTRA FLAGS: $@"
|
|
|
|
|
2021-06-09 10:49:26 +00:00
|
|
|
echo ":: Ensuring core crate versions match..."
|
|
|
|
check_versions_match "${CORE_CRATE_ROOTS[@]}"
|
|
|
|
|
|
|
|
echo ":: Ensuring contrib sync_db_pools versions match..."
|
|
|
|
check_versions_match "${CONTRIB_SYNC_DB_POOLS_CRATE_ROOTS[@]}"
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
|
2021-07-18 20:14:13 +00:00
|
|
|
echo ":: Ensuring contrib db_pools versions match..."
|
2024-02-28 21:23:19 +00:00
|
|
|
check_versions_match "${CONTRIB_DB_POOLS_CRATE_ROOTS[@]}"
|
2021-07-18 20:14:13 +00:00
|
|
|
|
2021-04-28 02:54:10 +00:00
|
|
|
echo ":: Ensuring minimum style requirements are met..."
|
|
|
|
check_style
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
|
|
|
|
echo ":: Updating dependencies..."
|
|
|
|
if ! $CARGO update ; then
|
|
|
|
echo " WARNING: Update failed! Proceeding with possibly outdated deps..."
|
|
|
|
fi
|
|
|
|
|
|
|
|
case $TEST_KIND in
|
|
|
|
core) test_core $@ ;;
|
2021-03-09 23:32:04 +00:00
|
|
|
contrib) test_contrib $@ ;;
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
examples) test_examples $@ ;;
|
2021-03-09 23:32:04 +00:00
|
|
|
default) test_default $@ ;;
|
2021-03-27 03:12:19 +00:00
|
|
|
benchmarks) run_benchmarks $@ ;;
|
2024-04-12 10:11:10 +00:00
|
|
|
testbench) run_testbench $@ ;;
|
2023-01-30 22:15:24 +00:00
|
|
|
ui) test_ui $@ ;;
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
all)
|
2021-03-11 06:52:37 +00:00
|
|
|
test_default $@ & default=$!
|
|
|
|
test_examples $@ & examples=$!
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
test_core $@ & core=$!
|
|
|
|
test_contrib $@ & contrib=$!
|
2024-04-12 10:11:10 +00:00
|
|
|
run_testbench $@ & testbench=$!
|
2023-01-30 22:15:24 +00:00
|
|
|
test_ui $@ & ui=$!
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
|
2021-03-11 06:52:37 +00:00
|
|
|
failures=()
|
2021-05-25 01:58:05 +00:00
|
|
|
if ! wait $default ; then failures+=("DEFAULT"); fi
|
2021-03-11 06:52:37 +00:00
|
|
|
if ! wait $examples ; then failures+=("EXAMPLES"); fi
|
|
|
|
if ! wait $core ; then failures+=("CORE"); fi
|
|
|
|
if ! wait $contrib ; then failures+=("CONTRIB"); fi
|
2024-04-12 10:11:10 +00:00
|
|
|
if ! wait $testbench ; then failures+=("TESTBENCH"); fi
|
2023-01-30 22:15:24 +00:00
|
|
|
if ! wait $ui ; then failures+=("UI"); fi
|
2021-03-11 06:52:37 +00:00
|
|
|
|
|
|
|
if [ ${#failures[@]} -ne 0 ]; then
|
|
|
|
tput setaf 1;
|
|
|
|
echo -e "\n!!! ${#failures[@]} TEST SUITE FAILURE(S) !!!"
|
|
|
|
for failure in "${failures[@]}"; do
|
|
|
|
echo " :: ${failure}"
|
|
|
|
done
|
|
|
|
|
|
|
|
tput sgr0
|
|
|
|
exit ${#failures[@]}
|
|
|
|
fi
|
|
|
|
|
Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.
This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.
The summary of changes in this commit are:
* Config 'secret_key' success and failure are now tested.
* 'secret_key' validation was moved to pre-launch from 'Config:from()'.
* 'Config::from()' only extracts the config.
* Added 'Config::try_from()' for non-panicking extraction.
* 'Config' now knows the profile it was extracted from.
* The 'Config' provider sets a profile of 'Config.profile'.
* 'Rocket', 'Client', 'Fairings', implement 'Debug'.
* 'fairing::Info' implements 'Copy', 'Clone'.
* 'Fairings' keeps track of, logs attach fairings.
* 'Rocket::reconfigure()' was added to allow modifying a config.
Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.
Resolves #1543.
Fixes #1564.
2021-03-09 08:07:43 +00:00
|
|
|
;;
|
|
|
|
esac
|