From 7a882fd967cb2f6384e853da73734a518b3eb43e Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Wed, 28 Dec 2016 22:33:56 -0600 Subject: [PATCH] Disallow tabs in testing script. --- scripts/config.sh | 1 + scripts/mk-docs.sh | 2 +- scripts/publish.sh | 2 +- scripts/test.sh | 18 +++++++++++++++--- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/config.sh b/scripts/config.sh index c49f2802..31435da4 100755 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -23,6 +23,7 @@ function relative() { fi } +ROOT_DIR=$(relative "") || exit $? EXAMPLES_DIR=$(relative "examples") || exit $? LIB_DIR=$(relative "lib") || exit $? CODEGEN_DIR=$(relative "codegen") || exit $? diff --git a/scripts/mk-docs.sh b/scripts/mk-docs.sh index 8bc15b26..4d5771ea 100755 --- a/scripts/mk-docs.sh +++ b/scripts/mk-docs.sh @@ -5,7 +5,7 @@ set -e # Builds the rustdocs for all of the libraries. # -# Brings in: EXAMPLES_DIR, LIB_DIR, CODEGEN_DIR, and CONTRIB_DIR, DOC_DIR +# Brings in: ROOT_DIR, EXAMPLES_DIR, LIB_DIR, CODEGEN_DIR, CONTRIB_DIR, DOC_DIR SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $SCRIPT_DIR/config.sh diff --git a/scripts/publish.sh b/scripts/publish.sh index 98868c31..dc042698 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -5,7 +5,7 @@ set -e # Publishes the current versions of core, contrib, and codegen to crates.io. # -# Brings in: EXAMPLES_DIR, LIB_DIR, CODEGEN_DIR, CONTRIB_DIR, DOC_DIR +# Brings in: ROOT_DIR, EXAMPLES_DIR, LIB_DIR, CODEGEN_DIR, CONTRIB_DIR, DOC_DIR SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $SCRIPT_DIR/config.sh diff --git a/scripts/test.sh b/scripts/test.sh index 2836e876..5cb11de4 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -# Brings in: EXAMPLES_DIR, LIB_DIR, CODEGEN_DIR, and CONTRIB_DIR, DOC_DIR +# Brings in: ROOT_DIR, EXAMPLES_DIR, LIB_DIR, CODEGEN_DIR, CONTRIB_DIR, DOC_DIR SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $SCRIPT_DIR/config.sh @@ -27,8 +27,6 @@ function build_and_test() { # Checks that the versions for Cargo projects $@ all match function check_versions_match() { - echo ":: Ensuring all crate versions match..." - local last_version="" for dir in $@; do local cargo_toml="${dir}/Cargo.toml" @@ -47,8 +45,22 @@ function check_versions_match() { done } +# Ensures there are not tabs in any file in the directories $@. +function ensure_tab_free() { + local matches=$(egrep -I -R '\t' $ROOT_DIR | egrep -v '/target|/.git|LICENSE') + if ! [ -z "${matches}" ]; then + echo "Tab characters were found in the following:" + echo "${matches}" + exit 1 + fi +} + +echo ":: Ensuring all crate versions match..." check_versions_match "${LIB_DIR}" "${CODEGEN_DIR}" "${CONTRIB_DIR}" +echo ":: Checking for tabs..." +ensure_tab_free + # Update dependencies before running tests. echo ":: Updating dependencies..." cargo update