From 4a0984891a522d4478e9f919adf219e51286118d Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Sun, 2 Oct 2016 01:18:37 -0700 Subject: [PATCH] Make running scripts more robust. --- scripts/config.sh | 23 +++++++++++++++++++++++ scripts/test.sh | 9 ++++----- 2 files changed, 27 insertions(+), 5 deletions(-) create mode 100755 scripts/config.sh diff --git a/scripts/config.sh b/scripts/config.sh new file mode 100755 index 00000000..40b444e4 --- /dev/null +++ b/scripts/config.sh @@ -0,0 +1,23 @@ +# Simply sets up a few useful variables. + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +function relative() { + local full_path="${SCRIPT_DIR}/../${1}" + echo $(realpath "${full_path}") +} + +EXAMPLES_DIR=$(relative "examples") +LIB_DIR=$(relative "lib") +CODEGEN_DIR=$(relative "codegen") +CONTRIB_DIR=$(relative "contrib") +DOC_DIR=$(relative "target/doc") + +if [ "${1}" = "-p" ]; then + echo $SCRIPT_DIR + echo $EXAMPLES_DIR + echo $LIB_DIR + echo $CODEGEN_DIR + echo $CONTRIB_DIR + echo $DOC_DIR +fi diff --git a/scripts/test.sh b/scripts/test.sh index eb00e6c4..e949a9dc 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,10 +1,9 @@ #!/bin/bash set -e -EXAMPLES_DIR="examples" -LIB_DIR="lib" -CODEGEN_DIR="codegen" -CONTRIB_DIR="contrib" +# Brings in: EXAMPLES_DIR, LIB_DIR, CODEGEN_DIR, and CONTRIB_DIR, DOC_DIR +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $SCRIPT_DIR/config.sh # Add Cargo to PATH. export PATH=${HOME}/.cargo/bin:${PATH} @@ -61,7 +60,7 @@ for file in ${EXAMPLES_DIR}/*; do if [ -x "${bootstrap_script}" ]; then echo ":: Bootstrapping ${file}..." - if ! ./${bootstrap_script}; then + if ! ${bootstrap_script}; then echo ":: Running bootstrap script (${bootstrap_script}) failed!" echo ":: Skipping ${file}." continue