mirror of https://github.com/rwf2/Rocket.git
Parallelize testing. Fix compiletest dependencies.
This commit is contained in:
parent
4d2f695db0
commit
d4eda278a2
|
@ -9,10 +9,8 @@ fn run_mode(mode: &'static str) {
|
|||
config.mode = cfg_mode;
|
||||
config.src_base = PathBuf::from(format!("tests/{}", mode));
|
||||
let flags = [
|
||||
"-L ../target/debug/",
|
||||
"-L ../target/debug/deps/",
|
||||
"-L target/debug/",
|
||||
"-L target/debug/deps/"
|
||||
"-L crate=../target/debug/",
|
||||
"-L dependency=../target/debug/deps/",
|
||||
].join(" ");
|
||||
|
||||
config.target_rustcflags = Some(flags);
|
||||
|
|
|
@ -21,3 +21,6 @@ cargo install diesel_cli # install diesel CLI tools
|
|||
DATABASE_URL=db/db.sql diesel migration run # create db/db.sql
|
||||
```
|
||||
|
||||
## Running
|
||||
|
||||
Run this example using: `DATABASE_URL=db/db.sql cargo run`
|
||||
|
|
|
@ -12,3 +12,5 @@ pushd $SCRIPT_PATH > /dev/null
|
|||
# create db/db.sql
|
||||
diesel migration --database-url=$DATABASE_URL run
|
||||
popd $SCRIPT_PATH > /dev/null
|
||||
|
||||
echo "export DATABASE_URL=$DATABASE_URL"
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
mod schema {
|
||||
infer_schema!("db/db.sql");
|
||||
}
|
||||
|
||||
use diesel;
|
||||
use diesel::prelude::*;
|
||||
use diesel::sqlite::SqliteConnection;
|
||||
use self::schema::tasks;
|
||||
use self::schema::tasks::dsl::{tasks as all_tasks, completed as task_completed};
|
||||
|
||||
const DATABASE_FILE: &'static str = env!("DATABASE_URL");
|
||||
|
||||
mod schema {
|
||||
infer_schema!("env:DATABASE_URL");
|
||||
}
|
||||
|
||||
fn db() -> SqliteConnection {
|
||||
SqliteConnection::establish("db/db.sql").expect("Failed to connect to db.")
|
||||
SqliteConnection::establish(DATABASE_FILE).expect("Failed to connect to db.")
|
||||
}
|
||||
|
||||
#[table_name = "tasks"]
|
||||
|
|
|
@ -8,23 +8,6 @@ source $SCRIPT_DIR/config.sh
|
|||
# Add Cargo to PATH.
|
||||
export PATH=${HOME}/.cargo/bin:${PATH}
|
||||
|
||||
# Builds and tests the Cargo project at $1
|
||||
function build_and_test() {
|
||||
local dir=$1
|
||||
if [ -z "${dir}" ] || ! [ -d "${dir}" ]; then
|
||||
echo "Tried to build and test inside '${dir}', but it is an invalid path."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd ${dir}
|
||||
echo ":: Building '${PWD}'..."
|
||||
RUST_BACKTRACE=1 cargo build --all-features
|
||||
|
||||
echo ":: Running unit tests in '${PWD}'..."
|
||||
RUST_BACKTRACE=1 cargo test --all-features
|
||||
popd
|
||||
}
|
||||
|
||||
# Checks that the versions for Cargo projects $@ all match
|
||||
function check_versions_match() {
|
||||
local last_version=""
|
||||
|
@ -56,6 +39,26 @@ function ensure_tab_free() {
|
|||
fi
|
||||
}
|
||||
|
||||
function bootstrap_examples() {
|
||||
for file in ${EXAMPLES_DIR}/*; do
|
||||
if [ -d "${file}" ]; then
|
||||
bootstrap_script="${file}/bootstrap.sh"
|
||||
if [ -x "${bootstrap_script}" ]; then
|
||||
echo " Bootstrapping ${file}..."
|
||||
|
||||
env_vars=$(${bootstrap_script})
|
||||
bootstrap_result=$?
|
||||
if [ $bootstrap_result -ne 0 ]; then
|
||||
echo " Running bootstrap script (${bootstrap_script}) failed!"
|
||||
exit 1
|
||||
else
|
||||
eval $env_vars
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
echo ":: Ensuring all crate versions match..."
|
||||
check_versions_match "${LIB_DIR}" "${CODEGEN_DIR}" "${CONTRIB_DIR}"
|
||||
|
||||
|
@ -65,35 +68,8 @@ ensure_tab_free
|
|||
echo ":: Updating dependencies..."
|
||||
cargo update
|
||||
|
||||
echo ":: Cleaning cached crates..."
|
||||
cargo clean -p rocket
|
||||
cargo clean -p rocket_codegen
|
||||
cargo clean -p rocket_contrib
|
||||
echo ":: Boostrapping examples..."
|
||||
bootstrap_examples
|
||||
|
||||
echo ":: Building and testing libraries..."
|
||||
build_and_test "${LIB_DIR}"
|
||||
build_and_test "${CODEGEN_DIR}"
|
||||
build_and_test "${CONTRIB_DIR}"
|
||||
|
||||
for file in ${EXAMPLES_DIR}/*; do
|
||||
if [ -d "${file}" ]; then
|
||||
bootstrap_script="${file}/bootstrap.sh"
|
||||
if [ -x "${bootstrap_script}" ]; then
|
||||
echo ":: Bootstrapping ${file}..."
|
||||
|
||||
# We're just going to leave this commented out for next time...
|
||||
# if [ "$(basename $file)" = "todo" ]; then
|
||||
# echo ":: Skipping todo example due to broken Diesel..."
|
||||
# continue
|
||||
# fi
|
||||
|
||||
if ! ${bootstrap_script}; then
|
||||
echo ":: Running bootstrap script (${bootstrap_script}) failed!"
|
||||
echo ":: Skipping ${file}."
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
build_and_test "${file}"
|
||||
fi
|
||||
done
|
||||
cargo test --all-features --all
|
||||
|
|
Loading…
Reference in New Issue