From d16d9bd0d77a58924cd83983995ae1ea0a92ff92 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Sat, 6 Aug 2016 19:57:44 -0700 Subject: [PATCH] Fixed todo example. Testing script now bootstraps when needed. --- .gitignore | 3 +++ examples/todo/Cargo.toml | 2 +- examples/todo/bootstrap.sh | 12 ++++++++++++ scripts/test.sh | 18 ++++++++++++++---- 4 files changed, 30 insertions(+), 5 deletions(-) create mode 100755 examples/todo/bootstrap.sh diff --git a/.gitignore b/.gitignore index fe9df4b5..63d1ee48 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,9 @@ # Generated by Cargo target +# Generated databases +db.sql + # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock Cargo.lock diff --git a/examples/todo/Cargo.toml b/examples/todo/Cargo.toml index b6ccb129..efd9e59f 100644 --- a/examples/todo/Cargo.toml +++ b/examples/todo/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Sergio Benitez "] rocket = { path = "../../lib" } rocket_macros = { path = "../../macros" } lazy_static = "*" -tera = "*" +tera = { git = "https://github.com/Keats/tera" } serde = "0.8" serde_json = "0.8" serde_macros = "0.8" diff --git a/examples/todo/bootstrap.sh b/examples/todo/bootstrap.sh new file mode 100755 index 00000000..c41ac48a --- /dev/null +++ b/examples/todo/bootstrap.sh @@ -0,0 +1,12 @@ +#! /usr/bin/env bash + +SCRIPTPATH=$(cd "$(dirname "$0")" ; pwd -P) +DATABASE_URL=${SCRIPTPATH}/db/db.sql + +pushd $SCRIPTPATH + # install the diesel CLI tools + cargo install diesel_cli + + # create db/db.sql + diesel migration --database-url=$DATABASE_URL run +popd $SCRIPTPATH diff --git a/scripts/test.sh b/scripts/test.sh index 4d017396..a4857a05 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,9 +1,9 @@ #!/bin/bash set -e -EXAMPLES_DIR="examples/" -LIB_DIR="lib/" -MACROS_DIR="macros/" +EXAMPLES_DIR="examples" +LIB_DIR="lib" +MACROS_DIR="macros" function build_and_test() { local dir=$1 @@ -26,8 +26,18 @@ build_and_test $LIB_DIR build_and_test $MACROS_DIR for file in ${EXAMPLES_DIR}/*; do - echo "${file}" if [ -d "${file}" ]; then + bootstrap_script="${file}/bootstrap.sh" + if [ -x "${bootstrap_script}" ]; then + echo ":: Bootstrapping ${file}..." + + if ! ./${bootstrap_script}; then + echo ":: Running bootstrap script (${bootstrap_script}) failed!" + echo ":: Skipping ${file}." + continue + fi + fi + build_and_test "${file}" fi done