Skip to content

Commit

Permalink
DRY up use of helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
iokiwi committed Jan 15, 2023
1 parent 020fd16 commit a0d04b9
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 71 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,6 @@ jobs:
- name: 'Run all tests'
run: './test/run.sh'
shell: 'bash'
# - uses: 'docker/setup-buildx-action@v2'
# if: contains(matrix.os, 'ubuntu')
# with:
# install: true
# - uses: 'docker/build-push-action@v3'
# if: contains(matrix.os, 'ubuntu')
# with:
# context: .
# load: true
# tags: "tgenv-terraform:${{ github.head_ref }}"
# - name: 'Check Dockerfile'
# if: contains(matrix.os, 'ubuntu')
# run: |
# expect=1.2.3;
# got="$(docker run -e "TGENV_TERRAFORM_VERSION=${expect}" "tgenv-terraform:${{ github.head_ref }}" version)";
# echo "${got}" | tee /dev/stderr | grep -e 'Terraform v1.2.3'

# When we push to main, test everything in order to guarantee releases
test-main-pushes:
Expand All @@ -69,19 +53,3 @@ jobs:
- name: 'Run all tests'
run: './test/run.sh'
shell: 'bash'
# - uses: 'docker/setup-buildx-action@v2'
# if: contains(matrix.os, 'ubuntu')
# with:
# install: true
# - uses: 'docker/build-push-action@v3'
# if: contains(matrix.os, 'ubuntu')
# with:
# context: .
# load: true
# tags: 'tgenv-terraform:latest'
# - name: 'Check Dockerfile'
# if: contains(matrix.os, 'ubuntu')
# run: |
# expect=1.2.3;
# got="$(docker run -e "TGENV_TERRAFORM_VERSION=${expect}" tgenv-terraform:latest version)";
# echo "${got}" | tee /dev/stderr | grep -e 'Terraform v1.2.3'
5 changes: 5 additions & 0 deletions libexec/helpers
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/usr/bin/env bash

function error_and_proceed() {
errors+=("${1}")
echo -e "tgenv: ${0}: Test Failed: ${1}" >&2
}

function error_and_die() {
echo -e "tgenv: $(basename ${0}): \033[0;31m[ERROR] ${1}\033[0;39m" >&2
exit 1
Expand Down
3 changes: 2 additions & 1 deletion test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ if [ -n "${TGENV_DEBUG}" ]; then
export PS4='+ [${BASH_SOURCE##*/}:${LINENO}] '
set -x
fi
TGENV_ROOT=$(cd $(dirname ${0})/.. && pwd)

export TGENV_ROOT=$(cd $(dirname ${0})/.. && pwd)
export PATH="${TGENV_ROOT}/bin:${PATH}"

errors=()
Expand Down
10 changes: 1 addition & 9 deletions test/test_install_and_use.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@

declare -a errors

function error_and_proceed() {
errors+=("${1}")
echo -e "tgenv: ${0}: Test Failed: ${1}" >&2
}

function error_and_die() {
echo -e "tgenv: ${0}: ${1}" >&2
exit 1
}
source "${TGENV_ROOT}/libexec/helpers"

[ -n "$TGENV_DEBUG" ] && set -x
source $(dirname $0)/helpers.sh \
Expand Down
13 changes: 2 additions & 11 deletions test/test_list.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
#!/usr/bin/env bash

# set -uo pipefail;

set -uo pipefail;
declare -a errors

function error_and_proceed() {
errors+=("${1}")
echo -e "tgenv: ${0}: Test Failed: ${1}" >&2
}

function error_and_die() {
echo -e "tgenv: ${0}: ${1}" >&2
exit 1
}
source "${TGENV_ROOT}/libexec/helpers"

[ "${TGENV_DEBUG:-0}" -gt 0 ] && set -x
source $(dirname $0)/helpers.sh \
Expand Down
10 changes: 1 addition & 9 deletions test/test_symlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@

declare -a errors

function error_and_proceed() {
errors+=("${1}")
echo -e "tgenv: Test Failed: ${1}" >&2
}

function error_and_die() {
echo -e "tgenv: ${1}" >&2
exit 1
}
source "${TGENV_ROOT}/libexec/helpers"

[ -n "${TGENV_DEBUG}" ] && set -x
source $(dirname $0)/helpers.sh \
Expand Down
10 changes: 1 addition & 9 deletions test/test_uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@

declare -a errors

function error_and_proceed() {
errors+=("${1}")
echo -e "tgenv: ${0}: Test Failed: ${1}" >&2
}

function error_and_die() {
echo -e "tgenv: ${0}: ${1}" >&2
exit 1
}
source "${TGENV_ROOT}/libexec/helpers"

[ -n "${TGENV_DEBUG}" ] && set -x
source $(dirname $0)/helpers.sh \
Expand Down

0 comments on commit a0d04b9

Please sign in to comment.