Fixed todo example. Testing script now bootstraps when needed.

This commit is contained in:
Sergio Benitez 2016-08-06 19:57:44 -07:00
parent b767c1bdec
commit d16d9bd0d7
4 changed files with 30 additions and 5 deletions

3
.gitignore vendored
View File

@ -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

View File

@ -7,7 +7,7 @@ authors = ["Sergio Benitez <sb@sergio.bz>"]
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"

12
examples/todo/bootstrap.sh Executable file
View File

@ -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

View File

@ -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