diff --git a/README.md b/README.md index 98e512d..d23d1e6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Git demo -This project contains 5 bash scripts, and 3 branches we can use for testing. +This project contains 5 bash scripts, and 3 branches we can use for testing. The testing script validates that the **scripts/** directory contains executable .sh files. + diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 0000000..0d072ae --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +# validate that the scripts folder only has .sh files +if [[ $(find scripts -type f -not -name "*.sh") ]]; then + echo "Error: scripts folder contains non-bash files" + exit 1 +fi + +# validate all scripts are executable +for file in scripts/*.sh; do + if [[ ! -x "$file" ]]; then + echo "Error: $file is not executable" + exit 1 + fi +done