mirror of https://github.com/rwf2/Rocket.git
Move examples to their own workspace.
This allows us to test all of the "core" crates (and the guide) by testing the root workspace, and all of the examples by testing in the examples workspace.
This commit is contained in:
parent
4e06ee64aa
commit
17dd8dafd0
|
@ -19,6 +19,7 @@ jobs:
|
||||||
test:
|
test:
|
||||||
- { name: Debug, flag: }
|
- { name: Debug, flag: }
|
||||||
- { name: Contrib, flag: "--contrib" }
|
- { name: Contrib, flag: "--contrib" }
|
||||||
|
- { name: Examples, flag: "--examples" }
|
||||||
toolchain: [stable]
|
toolchain: [stable]
|
||||||
allow-failures: [false]
|
allow-failures: [false]
|
||||||
include:
|
include:
|
||||||
|
@ -32,11 +33,7 @@ jobs:
|
||||||
allow-failures: false
|
allow-failures: false
|
||||||
- toolchain: nightly
|
- toolchain: nightly
|
||||||
os: { name: Linux, distro: ubuntu-latest }
|
os: { name: Linux, distro: ubuntu-latest }
|
||||||
test: { name: Debug, flag: }
|
test: { name: Debug, flag: "--all" }
|
||||||
allow-failures: true
|
|
||||||
- toolchain: nightly
|
|
||||||
os: { name: Linux, distro: ubuntu-latest }
|
|
||||||
test: { name: Contrib, flag: "--contrib" }
|
|
||||||
allow-failures: true
|
allow-failures: true
|
||||||
|
|
||||||
continue-on-error: ${{ matrix.allow-failures }}
|
continue-on-error: ${{ matrix.allow-failures }}
|
||||||
|
|
32
Cargo.toml
32
Cargo.toml
|
@ -6,36 +6,4 @@ members = [
|
||||||
"contrib/lib",
|
"contrib/lib",
|
||||||
"contrib/codegen",
|
"contrib/codegen",
|
||||||
"site/tests",
|
"site/tests",
|
||||||
"examples/cookies",
|
|
||||||
"examples/errors",
|
|
||||||
"examples/forms",
|
|
||||||
"examples/hello_person",
|
|
||||||
"examples/query_params",
|
|
||||||
"examples/hello_world",
|
|
||||||
"examples/manual_routes",
|
|
||||||
"examples/optional_redirect",
|
|
||||||
"examples/redirect",
|
|
||||||
"examples/static_files",
|
|
||||||
"examples/todo",
|
|
||||||
"examples/content_types",
|
|
||||||
"examples/ranking",
|
|
||||||
"examples/testing",
|
|
||||||
"examples/request_local_state",
|
|
||||||
"examples/request_guard",
|
|
||||||
"examples/stream",
|
|
||||||
"examples/json",
|
|
||||||
"examples/msgpack",
|
|
||||||
"examples/handlebars_templates",
|
|
||||||
"examples/tera_templates",
|
|
||||||
"examples/config",
|
|
||||||
"examples/raw_upload",
|
|
||||||
"examples/pastebin",
|
|
||||||
"examples/state",
|
|
||||||
"examples/managed_queue",
|
|
||||||
"examples/uuid",
|
|
||||||
"examples/session",
|
|
||||||
"examples/raw_sqlite",
|
|
||||||
"examples/tls",
|
|
||||||
"examples/fairings",
|
|
||||||
"examples/hello_2018",
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
[workspace]
|
||||||
|
members = [
|
||||||
|
"cookies",
|
||||||
|
"errors",
|
||||||
|
"forms",
|
||||||
|
"hello_person",
|
||||||
|
"query_params",
|
||||||
|
"hello_world",
|
||||||
|
"manual_routes",
|
||||||
|
"optional_redirect",
|
||||||
|
"redirect",
|
||||||
|
"static_files",
|
||||||
|
"todo",
|
||||||
|
"content_types",
|
||||||
|
"ranking",
|
||||||
|
"testing",
|
||||||
|
"request_local_state",
|
||||||
|
"request_guard",
|
||||||
|
"stream",
|
||||||
|
"json",
|
||||||
|
"msgpack",
|
||||||
|
"handlebars_templates",
|
||||||
|
"tera_templates",
|
||||||
|
"config",
|
||||||
|
"raw_upload",
|
||||||
|
"pastebin",
|
||||||
|
"state",
|
||||||
|
"managed_queue",
|
||||||
|
"uuid",
|
||||||
|
"session",
|
||||||
|
"raw_sqlite",
|
||||||
|
"tls",
|
||||||
|
"fairings",
|
||||||
|
"hello_2018",
|
||||||
|
]
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "config"
|
name = "config"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "content_types"
|
name = "content_types"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "cookies"
|
name = "cookies"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "errors"
|
name = "errors"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "fairings"
|
name = "fairings"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "forms"
|
name = "forms"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "handlebars_templates"
|
name = "handlebars_templates"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "hello_2018"
|
name = "hello_2018"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "hello_person"
|
name = "hello_person"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "hello_world"
|
name = "hello_world"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "json"
|
name = "json"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "managed_queue"
|
name = "managed_queue"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../.."
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "manual_routes"
|
name = "manual_routes"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "msgpack"
|
name = "msgpack"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "optional_redirect"
|
name = "optional_redirect"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "pastebin"
|
name = "pastebin"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "query_params"
|
name = "query_params"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "ranking"
|
name = "ranking"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "raw_sqlite"
|
name = "raw_sqlite"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "raw_upload"
|
name = "raw_upload"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "redirect"
|
name = "redirect"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "request_guard"
|
name = "request_guard"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "request_local_state"
|
name = "request_local_state"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "session"
|
name = "session"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "state"
|
name = "state"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "static_files"
|
name = "static_files"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "stream"
|
name = "stream"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "tera_templates"
|
name = "tera_templates"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "testing"
|
name = "testing"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "tls"
|
name = "tls"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "todo"
|
name = "todo"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
workspace = "../../"
|
workspace = "../"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|
|
@ -73,14 +73,12 @@ function test_contrib() {
|
||||||
echo ":: Building and testing contrib [default]..."
|
echo ":: Building and testing contrib [default]..."
|
||||||
|
|
||||||
pushd "${CONTRIB_LIB_ROOT}" > /dev/null 2>&1
|
pushd "${CONTRIB_LIB_ROOT}" > /dev/null 2>&1
|
||||||
|
|
||||||
$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 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +89,6 @@ function test_core() {
|
||||||
)
|
)
|
||||||
|
|
||||||
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 test --no-default-features $@
|
$CARGO test --no-default-features $@
|
||||||
|
|
||||||
|
@ -99,36 +96,27 @@ function test_core() {
|
||||||
echo ":: Building and testing core [${feature}]..."
|
echo ":: Building and testing core [${feature}]..."
|
||||||
$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
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_examples() {
|
function test_examples() {
|
||||||
for dir in $(find "${EXAMPLES_DIR}" -maxdepth 1 -mindepth 1 -type d); do
|
echo ":: Building and testing examples..."
|
||||||
echo ":: Building and testing example [${dir#"${EXAMPLES_DIR}/"}]..."
|
|
||||||
|
|
||||||
pushd "${dir}" > /dev/null 2>&1
|
pushd "${EXAMPLES_DIR}" > /dev/null 2>&1
|
||||||
$CARGO test $@
|
# Rust compiles Rocket once with the `secrets` feature enabled, so when run
|
||||||
popd > /dev/null 2>&1
|
# in production, we need a secret key or tests will fail needlessly. We
|
||||||
done
|
# ensure in core that secret key failing/not failing works as expected.
|
||||||
}
|
ROCKET_SECRET_KEY="itlYmFR2vYKrOmFhupMIn/hyB6lYCCTXz4yaQX89XVg=" \
|
||||||
|
$CARGO test --all $@
|
||||||
function test_guide() {
|
|
||||||
echo ":: Building and testing guide..."
|
|
||||||
|
|
||||||
pushd "${GUIDE_TESTS_ROOT}" > /dev/null 2>&1
|
|
||||||
$CARGO test $@
|
|
||||||
popd > /dev/null 2>&1
|
popd > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_default() {
|
function test_default() {
|
||||||
for project in "${ALL_PROJECT_DIRS[@]}"; do
|
echo ":: Building and testing core libraries..."
|
||||||
echo ":: Building and testing ${project#"${PROJECT_ROOT}/"}..."
|
|
||||||
|
|
||||||
pushd "${project}" > /dev/null 2>&1
|
pushd "${PROJET_ROOT}" > /dev/null 2>&1
|
||||||
$CARGO test --all-features $@
|
$CARGO test --all --all-features $@
|
||||||
popd > /dev/null 2>&1
|
popd > /dev/null 2>&1
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $1 == +* ]]; then
|
if [[ $1 == +* ]]; then
|
||||||
|
@ -138,7 +126,7 @@ fi
|
||||||
|
|
||||||
# The kind of test we'll be running.
|
# The kind of test we'll be running.
|
||||||
TEST_KIND="default"
|
TEST_KIND="default"
|
||||||
KINDS=("contrib" "core" "examples" "guide" "all")
|
KINDS=("contrib" "core" "examples" "default" "all")
|
||||||
|
|
||||||
if [[ " ${KINDS[@]} " =~ " ${1#"--"} " ]]; then
|
if [[ " ${KINDS[@]} " =~ " ${1#"--"} " ]]; then
|
||||||
TEST_KIND=${1#"--"}
|
TEST_KIND=${1#"--"}
|
||||||
|
@ -165,24 +153,16 @@ if ! $CARGO update ; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $TEST_KIND in
|
case $TEST_KIND in
|
||||||
contrib) test_contrib $@ ;;
|
|
||||||
core) test_core $@ ;;
|
core) test_core $@ ;;
|
||||||
|
contrib) test_contrib $@ ;;
|
||||||
examples) test_examples $@ ;;
|
examples) test_examples $@ ;;
|
||||||
guide) test_guide $@ ;;
|
default) test_default $@ ;;
|
||||||
default)
|
|
||||||
test_examples $@ & examples=$!
|
|
||||||
test_default $@ & default=$!
|
|
||||||
test_guide $@ & guide=$!
|
|
||||||
|
|
||||||
wait $examples && wait $default && wait $guide
|
|
||||||
;;
|
|
||||||
all)
|
all)
|
||||||
test_core $@ & core=$!
|
test_core $@ & core=$!
|
||||||
test_contrib $@ & contrib=$!
|
test_contrib $@ & contrib=$!
|
||||||
test_examples $@ & examples=$!
|
test_examples $@ & examples=$!
|
||||||
test_default $@ & default=$!
|
test_default $@ & default=$!
|
||||||
test_guide $@ & guide=$!
|
|
||||||
|
|
||||||
wait $core && wait $contrib && wait $examples && wait $default && wait $guide
|
wait $core && wait $contrib && wait $examples && wait $default
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in New Issue