2016-06-16 19:34:25 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-05-05 12:59:28 +00:00
|
|
|
# `SECRETS_PROJECT_ROOT` must be set before running the script.
|
2016-06-16 19:34:25 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2019-05-21 16:06:51 +00:00
|
|
|
TEST_DIR=/tmp/git-secret-test
|
2018-07-14 19:23:39 +00:00
|
|
|
|
2021-05-03 12:43:04 +00:00
|
|
|
rm -rf "${TEST_DIR}"
|
2019-03-27 05:10:07 +00:00
|
|
|
mkdir "${TEST_DIR}"
|
2019-08-16 20:53:57 +00:00
|
|
|
echo "# created dir: ${TEST_DIR}"
|
2019-05-21 16:06:51 +00:00
|
|
|
|
2019-03-27 05:10:07 +00:00
|
|
|
chmod 0700 "${TEST_DIR}"
|
|
|
|
(
|
2021-05-03 12:43:04 +00:00
|
|
|
cd "$TEST_DIR"
|
2018-08-25 14:05:17 +00:00
|
|
|
|
2021-05-03 12:43:04 +00:00
|
|
|
# test with non-standard SECRETS_DIR (normally .gitsecret)
|
|
|
|
# and SECRETS_EXTENSION (normally .secret)
|
|
|
|
export SECRETS_DIR='.gitsec'
|
|
|
|
export SECRETS_EXTENSION='.sec'
|
2019-02-11 21:33:59 +00:00
|
|
|
|
2021-05-03 12:43:04 +00:00
|
|
|
export TMPDIR="$TEST_DIR"
|
|
|
|
echo "# TMPDIR is $TMPDIR"
|
2019-03-27 05:10:07 +00:00
|
|
|
|
2021-05-03 12:43:04 +00:00
|
|
|
# bats expects diagnostic lines to be sent to fd 3, matching regex '^# '
|
2019-05-21 16:06:51 +00:00
|
|
|
# (IE, like: `echo '# message here' >&3`).
|
|
|
|
# bats ... 3>&1 shows diagnostic output
|
2021-05-05 12:59:28 +00:00
|
|
|
bats "${SECRETS_PROJECT_ROOT}/tests" 3>&1
|
2019-03-27 05:10:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
rm -rf "${TEST_DIR}"
|