experimental SECRETS_TEST_VERBOSE shows debug info during tests (#446)

* add a travis target using SECRETS_TEST_VERBOSE=1
* Document SECRETS_TEST_VERBOSE as experimental
* note experimental feature may change or be removed
pull/448/head
Josh Rabinowitz 5 years ago committed by GitHub
parent fc85d05fc0
commit cb1636a6dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,6 +7,13 @@ matrix:
# env: GITSECRET_DIST="windows"
# sudo: required
# language: sh
- os: osx
name: osx-with-debug-output
env: GITSECRET_DIST="brew" SECRETS_TEST_VERBOSE=1
sudo: required
language: shell
#language: ruby
#rvm: 2.6
- os: osx
env: GITSECRET_DIST="brew"
sudo: required

@ -39,8 +39,10 @@
- Document SECRETS_VERBOSE and improve env var docs (#396)
- Update CHANGELOG.md to mention fix for #281 in v0.2.5 (#311)
- Add text explaining git-secret Style Guide and Development Philosophy
- Experimental SECRETS_TEST_VERBOSE env var shows debug info during tests (may be removed)
- Upgrade bats-core to v1.1.0, import bats-core into vendor/bats-core (#377)
- Improve git-secret user messaging.
- Setting SECRETS_TEST_VERBOSE env var shows debug info during tests (EXPERIMENTAL)
## Version 0.2.5

@ -47,7 +47,9 @@ These are only required if dealing with manuals, `gh-pages` or releases:
2. Fork and clone your repository: `git clone https://github.com/${YOUR_NAME}/git-secret.git`
3. Make sure that everything works on the current platform by running `make test`
3. Make sure that everything works on the current platform by running `make test`.
You can also try the experimental `SECRETS_TEST_VERBOSE=1 make test`.
Note that 'experimental' features may change or be removed in a future version of `git-secret`.
4. [Run local CI tests](#running-local-ci-tests) to verify functionality on supported platforms `bundle exec kitchen verify --test-base-path="$PWD/.ci/integration"`.

@ -355,9 +355,10 @@ function _is_tracked_in_git {
}
# This can give unexpected .git dir when used in a _subdirectory_ of another git repo; See #431 and #433.
function _get_git_root_path {
# We need this function to get the location of the `.git` folder,
# since `.gitsecret` (or value set by SECRETS_DIR env var) must be on the same level.
# since `.gitsecret` (or value set by SECRETS_DIR env var) must be in the same dir.
local result
result=$(_clean_windows_path "$(git rev-parse --show-toplevel)")

@ -13,6 +13,8 @@ FIXTURES_DIR="$BATS_TEST_DIRNAME/fixtures"
TEST_GPG_HOMEDIR="$BATS_TMPDIR"
TEST_GPG_OUTPUT_FILE=$(TMPDIR="$BATS_TMP_DIR" mktemp -t '_git_secret_test_output_XXX')
# shellcheck disable=SC2016
AWK_GPG_GET_FP='
BEGIN { OFS=":"; FS=":"; }
@ -67,12 +69,10 @@ function stop_gpg_agent {
username=$(id -u -n)
if [[ "$GITSECRET_DIST" == "windows" ]]; then
ps -l -u "$username" | gawk \
'/gpg-agent/ { if ( $0 !~ "awk" ) { system("kill "$1) } }' \
> /dev/null 2>&1
'/gpg-agent/ { if ( $0 !~ "awk" ) { system("kill "$1) } }' >> "$TEST_GPG_OUTPUT_FILE" 2>&1
else
ps -wx -U "$username" | gawk \
'/gpg-agent --homedir/ { if ( $0 !~ "awk" ) { system("kill "$1) } }' \
> /dev/null 2>&1
'/gpg-agent --homedir/ { if ( $0 !~ "awk" ) { system("kill "$1) } }' >> "$TEST_GPG_OUTPUT_FILE" 2>&1
fi
}
@ -102,7 +102,7 @@ function install_fixture_key {
local public_key="$BATS_TMPDIR/public-${1}.key"
cp "$FIXTURES_DIR/gpg/${1}/public.key" "$public_key"
$GPGTEST --import "$public_key" > /dev/null 2>&1
$GPGTEST --import "$public_key" >> "$TEST_GPG_OUTPUT_FILE" 2>&1
rm -f "$public_key"
}
@ -120,7 +120,7 @@ function install_fixture_full_key {
cp "$FIXTURES_DIR/gpg/${1}/private.key" "$private_key"
bash -c "$gpgtest_import --allow-secret-key-import \
--import \"$private_key\"" > /dev/null 2>&1
--import \"$private_key\"" >> "${TEST_GPG_OUTPUT_FILE}" 2>&1
# since 0.1.2 fingerprint is returned:
fingerprint=$(get_gpg_fingerprint_by_email "$email")
@ -137,7 +137,7 @@ function uninstall_fixture_key {
local email
email="$1"
$GPGTEST --yes --delete-key "$email" > /dev/null 2>&1
$GPGTEST --yes --delete-key "$email" >> "$TEST_GPG_OUTPUT_FILE" 2>&1
}
@ -151,8 +151,7 @@ function uninstall_fixture_full_key {
fingerprint=$(get_gpg_fingerprint_by_email "$email")
fi
$GPGTEST --yes \
--delete-secret-keys "$fingerprint" > /dev/null 2>&1
$GPGTEST --yes --delete-secret-keys "$fingerprint" >> "$TEST_GPG_OUTPUT_FILE" 2>&1
uninstall_fixture_key "$1"
}
@ -200,12 +199,12 @@ function set_state_initial {
function set_state_git {
git init > /dev/null 2>&1
git init >> "$TEST_GPG_OUTPUT_FILE" 2>&1
}
function set_state_secret_init {
git secret init > /dev/null 2>&1
git secret init >> "$TEST_GPG_OUTPUT_FILE" 2>&1
}
@ -213,7 +212,7 @@ function set_state_secret_tell {
local email
email="$1"
git secret tell -d "$TEST_GPG_HOMEDIR" "$email" > /dev/null 2>&1
git secret tell -d "$TEST_GPG_HOMEDIR" "$email" >> "$TEST_GPG_OUTPUT_FILE" 2>&1
}
@ -223,7 +222,7 @@ function set_state_secret_add {
echo "$content" > "$filename" # we add a newline
echo "$filename" >> ".gitignore"
git secret add "$filename" > /dev/null 2>&1
git secret add "$filename" >> "$TEST_GPG_OUTPUT_FILE" 2>&1
}
function set_state_secret_add_without_newline {
@ -232,12 +231,12 @@ function set_state_secret_add_without_newline {
echo -n "$content" > "$filename" # we do not add a newline
echo "$filename" >> ".gitignore"
git secret add "$filename" > /dev/null 2>&1
git secret add "$filename" >> "$TEST_GPG_OUTPUT_FILE" 2>&1
}
function set_state_secret_hide {
git secret hide > /dev/null 2>&1
git secret hide >> "$TEST_GPG_OUTPUT_FILE" 2>&1
}
@ -247,7 +246,7 @@ function unset_current_state {
# unsets `secret_hide`
# removes .secret files:
git secret clean > /dev/null 2>&1
git secret clean >> "$TEST_GPG_OUTPUT_FILE" 2>&1
# unsets `secret_add`, `secret_tell` and `secret_init` by removing $_SECRETS_DIR
local secrets_dir
@ -262,6 +261,18 @@ function unset_current_state {
# stop gpg-agent
stop_gpg_agent
# SECRETS_TEST_VERBOSE is experimental
if [[ -n "$SECRETS_TEST_VERBOSE" ]]; then
# display the captured output as bats diagnostic (fd3, preceded by '# ')
sed "s/^/# $BATS_TEST_DESCRIPTION: /" < "$TEST_GPG_OUTPUT_FILE" >&3
# display the last $output
# shellcheck disable=SC2001,SC2154
echo "$output" | sed "s/^/# '$BATS_TEST_DESCRIPTION' final output: /" >&3
fi
rm "$TEST_GPG_OUTPUT_FILE"
# removes gpg homedir:
find "$TEST_GPG_HOMEDIR" \
-regex ".*\/random_seed\|.*\.gpg\|.*\.kbx.?\|.*private-keys.*\|.*test_sub_dir\|.*S.gpg-agent\|.*file_to_hide.*" \

Loading…
Cancel
Save