-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Modified test-runner script to take certain flags - Test runner now validates input - Fixed an issue with the `gitleaks.toml`
- Loading branch information
1 parent
610a3ad
commit 9517144
Showing
3 changed files
with
69 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,68 @@ | ||
#!/bin/bash -ex | ||
#!/bin/bash -x | ||
|
||
cd "${PWD}/tests/${1}" | ||
# Test runner for Ansible Conjur Collection | ||
|
||
# Directories containing a `test.sh` file | ||
test_directories=("conjur" "conjur-host-identity") | ||
|
||
# Target directory that can be manually set by passing a value to the `-d` flag | ||
target="" | ||
|
||
# Print usage instructions | ||
function help { | ||
echo "Test runner for Ansible Conjur Collection" | ||
|
||
echo "-a Run all test files in default test directories" | ||
echo "-d <arg> Run test file in given directory. Valid options are: ${test_directories[*]} all" | ||
echo "-h View help and available commands" | ||
exit 1 | ||
} | ||
|
||
# Run a `test.sh` file in a given subdirectory of the top-level `tests` directory | ||
function run_test { | ||
pushd "${PWD}/tests/${1}" | ||
echo "Running tests for ${1}..." | ||
./test.sh | ||
popd | ||
} | ||
|
||
# Handles input to dictate wether all tests should be ran, or just one set | ||
function handle_input { | ||
if [[ ! -z ${target} ]]; then | ||
for test_dir in "${test_directories[@]}"; do | ||
if [[ ${target} == "${test_dir}" ]]; then | ||
run_test ${target} | ||
exit 0 | ||
fi | ||
done | ||
echo "Error: unrecognized test directory given: ${target}" | ||
echo "" | ||
help | ||
else | ||
echo "Running all tests..." | ||
for test_dir in "${test_directories[@]}"; do | ||
run_test "${test_dir}" | ||
done | ||
exit 0 | ||
fi | ||
} | ||
|
||
# Exit if no input given | ||
if [[ $# -eq 0 ]] ; then | ||
echo "Error: No test directory or flag given" | ||
echo "" | ||
help | ||
fi | ||
|
||
while getopts ahd: option; do | ||
case "$option" in | ||
a) handle_input | ||
;; | ||
d) target=${OPTARG} | ||
handle_input | ||
;; | ||
h) help | ||
;; | ||
esac | ||
done | ||
|
||
./test.sh |