2016-10-02 08:18:37 +00:00
|
|
|
# Simply sets up a few useful variables.
|
|
|
|
|
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
|
|
|
function relative() {
|
|
|
|
local full_path="${SCRIPT_DIR}/../${1}"
|
2016-10-02 08:23:28 +00:00
|
|
|
|
2016-10-04 00:25:55 +00:00
|
|
|
if [ -d "${full_path}" ]; then
|
2016-12-26 04:23:54 +00:00
|
|
|
# Try to use readlink as a fallback to readpath for cross-platform compat.
|
|
|
|
if command -v realpath >/dev/null 2>&1; then
|
2018-01-24 02:53:02 +00:00
|
|
|
realpath "${full_path}"
|
2016-12-26 04:23:54 +00:00
|
|
|
elif ! (readlink -f 2>&1 | grep illegal > /dev/null); then
|
2018-01-24 02:53:02 +00:00
|
|
|
readlink -f "${full_path}"
|
2016-10-04 00:25:55 +00:00
|
|
|
else
|
2016-12-26 04:23:54 +00:00
|
|
|
echo "Rocket's scripts require 'realpath' or 'readlink -f' support." >&2
|
|
|
|
echo "Install realpath or GNU readlink via your package manager." >&2
|
|
|
|
echo "Aborting." >&2
|
|
|
|
exit 1
|
2016-10-04 00:25:55 +00:00
|
|
|
fi
|
2016-10-02 08:23:28 +00:00
|
|
|
else
|
2016-10-04 00:25:55 +00:00
|
|
|
# when the directory doesn't exist, fallback to this.
|
|
|
|
echo "${full_path}"
|
2016-10-02 08:23:28 +00:00
|
|
|
fi
|
2016-10-02 08:18:37 +00:00
|
|
|
}
|
|
|
|
|
2020-02-26 00:56:59 +00:00
|
|
|
function future_date() {
|
|
|
|
local days_in_future=`[[ -z "$1" ]] && echo "0" || echo "$1"`
|
|
|
|
if date -v+1d +%Y-%m-%d > /dev/null 2>&1; then
|
|
|
|
echo $(date -v+${days_in_future}d +%Y-%m-%d)
|
|
|
|
elif date -d "+1 day" > /dev/null 2>&1; then
|
|
|
|
echo $(date '+%Y-%m-%d' -d "+${days_in_future} days")
|
|
|
|
else
|
|
|
|
echo "Error: need a 'date' cmd that accepts -v (BSD) or -d (GNU)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-06-07 13:34:47 +00:00
|
|
|
# Root of workspace-like directories.
|
|
|
|
PROJECT_ROOT=$(relative "") || exit $?
|
|
|
|
CORE_ROOT=$(relative "core") || exit $?
|
|
|
|
CONTRIB_ROOT=$(relative "contrib") || exit $?
|
2018-10-07 04:16:02 +00:00
|
|
|
SITE_ROOT=$(relative "site") || exit $?
|
2021-03-27 03:12:19 +00:00
|
|
|
BENCHMARKS_ROOT=$(relative "benchmarks") || exit $?
|
2021-06-08 00:53:57 +00:00
|
|
|
FUZZ_ROOT=$(relative "core/lib/fuzz") || exit $?
|
2018-06-07 13:34:47 +00:00
|
|
|
|
|
|
|
# Root of project-like directories.
|
|
|
|
CORE_LIB_ROOT=$(relative "core/lib") || exit $?
|
2018-10-22 06:53:09 +00:00
|
|
|
CORE_CODEGEN_ROOT=$(relative "core/codegen") || exit $?
|
2018-06-07 13:34:47 +00:00
|
|
|
CORE_HTTP_ROOT=$(relative "core/http") || exit $?
|
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
|
|
|
GUIDE_TESTS_ROOT=$(relative "site/tests") || exit $?
|
2018-06-07 13:34:47 +00:00
|
|
|
|
|
|
|
# Root of infrastructure directories.
|
2016-12-26 04:23:54 +00:00
|
|
|
EXAMPLES_DIR=$(relative "examples") || exit $?
|
|
|
|
DOC_DIR=$(relative "target/doc") || exit $?
|
2016-10-02 08:18:37 +00:00
|
|
|
|
2020-10-21 11:54:24 +00:00
|
|
|
# Versioning information. These are changed as versions change.
|
|
|
|
VERSION=$(git grep -h "^version" "${CORE_LIB_ROOT}" | head -n 1 | cut -d '"' -f2)
|
|
|
|
MAJOR_VERSION=$(echo "${VERSION}" | cut -d'.' -f1-2)
|
|
|
|
VIRTUAL_CODENAME="$(git branch --show-current)"
|
|
|
|
PHYSICAL_CODENAME="v${MAJOR_VERSION}"
|
|
|
|
CURRENT_RELEASE=false
|
|
|
|
PRE_RELEASE=true
|
|
|
|
|
|
|
|
# A generated codename for this version. Use the git branch for pre-releases.
|
|
|
|
case $PRE_RELEASE in
|
|
|
|
true)
|
|
|
|
CODENAME="${VIRTUAL_CODENAME}"
|
2021-06-09 10:24:07 +00:00
|
|
|
DOC_VERSION="${VERSION}-$(future_date)"
|
2020-10-21 11:54:24 +00:00
|
|
|
;;
|
|
|
|
false)
|
|
|
|
CODENAME="${PHYSICAL_CODENAME}"
|
|
|
|
DOC_VERSION="${VERSION}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2021-06-09 10:49:26 +00:00
|
|
|
CORE_CRATE_ROOTS=(
|
2018-06-07 13:34:47 +00:00
|
|
|
"${CORE_HTTP_ROOT}"
|
2018-10-29 11:52:31 +00:00
|
|
|
"${CORE_CODEGEN_ROOT}"
|
|
|
|
"${CORE_LIB_ROOT}"
|
2021-05-25 01:58:05 +00:00
|
|
|
)
|
|
|
|
|
2021-06-09 10:49:26 +00:00
|
|
|
CONTRIB_SYNC_DB_POOLS_CRATE_ROOTS=(
|
|
|
|
"${CONTRIB_ROOT}/sync_db_pools/lib"
|
|
|
|
"${CONTRIB_ROOT}/sync_db_pools/codegen"
|
|
|
|
)
|
|
|
|
|
|
|
|
ALL_CRATE_ROOTS=(
|
|
|
|
"${CORE_HTTP_ROOT}"
|
|
|
|
"${CORE_CODEGEN_ROOT}"
|
|
|
|
"${CORE_LIB_ROOT}"
|
|
|
|
"${CONTRIB_ROOT}/sync_db_pools/lib"
|
|
|
|
"${CONTRIB_ROOT}/sync_db_pools/codegen"
|
2021-05-25 01:58:05 +00:00
|
|
|
"${CONTRIB_ROOT}/dyn_templates"
|
2018-06-07 13:34:47 +00:00
|
|
|
)
|
|
|
|
|
2020-07-21 17:24:18 +00:00
|
|
|
function print_environment() {
|
2020-10-21 11:54:24 +00:00
|
|
|
echo " VERSION: ${VERSION}"
|
|
|
|
echo " MAJOR_VERSION: ${MAJOR_VERSION}"
|
|
|
|
echo " CODENAME: ${CODENAME}"
|
|
|
|
echo " DOC_VERSION: ${DOC_VERSION}"
|
2020-07-21 17:24:18 +00:00
|
|
|
echo " CURRENT_RELEASE: ${CURRENT_RELEASE}"
|
|
|
|
echo " PRE_RELEASE: ${PRE_RELEASE}"
|
|
|
|
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}"
|
2021-03-27 03:12:19 +00:00
|
|
|
echo " BENCHMARKS_ROOT: ${BENCHMARKS_ROOT}"
|
2020-07-21 17:24:18 +00:00
|
|
|
echo " CORE_LIB_ROOT: ${CORE_LIB_ROOT}"
|
|
|
|
echo " CORE_CODEGEN_ROOT: ${CORE_CODEGEN_ROOT}"
|
|
|
|
echo " CORE_HTTP_ROOT: ${CORE_HTTP_ROOT}"
|
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 " GUIDE_TESTS_ROOT: ${GUIDE_TESTS_ROOT}"
|
2020-07-21 17:24:18 +00:00
|
|
|
echo " EXAMPLES_DIR: ${EXAMPLES_DIR}"
|
|
|
|
echo " DOC_DIR: ${DOC_DIR}"
|
2021-06-09 10:49:26 +00:00
|
|
|
echo " ALL_CRATE_ROOTS: ${ALL_CRATE_ROOTS[*]}"
|
2020-07-21 17:24:18 +00:00
|
|
|
echo " date(): $(future_date)"
|
|
|
|
}
|
|
|
|
|
2016-10-02 08:18:37 +00:00
|
|
|
if [ "${1}" = "-p" ]; then
|
2020-07-21 17:24:18 +00:00
|
|
|
print_environment
|
2016-10-02 08:18:37 +00:00
|
|
|
fi
|