From efbf911f820a4c310ee1f9be9f118398f9fbbd11 Mon Sep 17 00:00:00 2001 From: Ethan P Date: Thu, 26 Sep 2019 15:49:36 -0700 Subject: [PATCH] Add verification to build script --- README.md | 6 ++++++ build.sh | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dd993e1..e0e3e84 100644 --- a/README.md +++ b/README.md @@ -60,3 +60,9 @@ If you only want to install a single script, you can run the build process and c Depending on the distribution, bat may have been renamed to avoid package conflicts. If you wish to use these scripts on a distribution where this is the case, there is an `--alternate-executable=NAME` option which will build the scripts to use an alternate executable name. + + +**Verification:** + +The build script will attempt to verify the correctness of the "bin" scripts by comparing their output with their source counterparts. It is recommended to let it do this, but you can disable verification with the `--no-verify` option. + diff --git a/build.sh b/build.sh index 9e44e43..75a1856 100755 --- a/build.sh +++ b/build.sh @@ -180,6 +180,7 @@ pp_minify() { # ----------------------------------------------------------------------------- # Options. OPT_INSTALL=false +OPT_VERIFY=true OPT_MINIFY="lib" OPT_PREFIX="/usr/local" OPT_BAT="bat" @@ -193,6 +194,7 @@ while shiftopt; do --prefix) shiftval; OPT_PREFIX="$OPT_VAL";; --alternate-executable) shiftval; OPT_BAT="$OPT_VAL";; --minify) shiftval; OPT_MINIFY="$OPT_VAL";; + --no-verify) shiftval; OPT_VERIFY=false;; --docs:url) shiftval; DOCS_URL="$OPT_VAL";; --docs:maintainer) shiftval; DOCS_MAINTAINER="$OPT_VAL";; @@ -240,7 +242,6 @@ done # ----------------------------------------------------------------------------- # Build files. - printc "%{YELLOW}Building scripts...%{CLEAR}\n" 1>&2 file_i=0 file_n="${#SOURCES[@]}" @@ -258,4 +259,12 @@ for file in "${SOURCES[@]}"; do cat >/dev/null done +# ----------------------------------------------------------------------------- +# Verify files by running the tests. + +if "$OPT_VERIFY"; then + printc "\n%{YELLOW}Verifying scripts...%{CLEAR}\n" 1>&2 + "$HERE/test/run.sh" consistency-test + exit $? +fi