From 3afefda0d4e57b0ce9d96cb7df15aada379f1a96 Mon Sep 17 00:00:00 2001 From: chatton Date: Mon, 11 Sep 2023 16:14:54 +0100 Subject: [PATCH 1/2] chore: verify dependencies --- e2e/scripts/run-e2e.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/e2e/scripts/run-e2e.sh b/e2e/scripts/run-e2e.sh index 1328b1d8f88..30ea0426a1b 100755 --- a/e2e/scripts/run-e2e.sh +++ b/e2e/scripts/run-e2e.sh @@ -5,23 +5,30 @@ set -eo pipefail TEST="${1}" ENTRY_POINT="${2:-}" +function _verify_dependencies() { + if ! command -v fzf > /dev/null || ! command -v jq > /dev/null ; then + echo "fzf and jq are required to interactively select a test." + exit 1 + fi +} + # _get_test returns the test that should be used in the e2e test. If an argument is provided, that argument # is returned. Otherwise, fzf is used to interactively choose from all available tests. function _get_test(){ + # if an argument is provided, it is used directly. This enables the drop down selection with fzf. if [ -n "$1" ]; then echo "$1" return # if fzf and jq are installed, we can use them to provide an interactive mechanism to select from all available tests. - elif command -v fzf > /dev/null && command -v jq > /dev/null; then + else cd .. go run -mod=readonly cmd/build_test_matrix/main.go | jq -r '.include[] | .test' | fzf cd - > /dev/null - else - echo "TEST was not provided and both fzf and jq are not present. Unable to determine which test should be used." - exit 1 fi } +_verify_dependencies + # if test is set, that is used directly, otherwise the test can be interactively provided if fzf is installed. TEST="$(_get_test ${TEST})" From ecbee94853303561849cfe93283aee9280b00dd3 Mon Sep 17 00:00:00 2001 From: chatton Date: Tue, 12 Sep 2023 10:10:33 +0100 Subject: [PATCH 2/2] chore: corrected logic for fzf and jq verification --- e2e/scripts/run-e2e.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/e2e/scripts/run-e2e.sh b/e2e/scripts/run-e2e.sh index 30ea0426a1b..577778cb35c 100755 --- a/e2e/scripts/run-e2e.sh +++ b/e2e/scripts/run-e2e.sh @@ -5,13 +5,29 @@ set -eo pipefail TEST="${1}" ENTRY_POINT="${2:-}" -function _verify_dependencies() { - if ! command -v fzf > /dev/null || ! command -v jq > /dev/null ; then - echo "fzf and jq are required to interactively select a test." +function _verify_jq() { + if ! command -v jq > /dev/null ; then + echo "jq is required to extract test entrypoint." + exit 1 + fi +} + +function _verify_fzf() { + if ! command -v fzf > /dev/null ; then + echo "fzf is required to interactively select a test." exit 1 fi } +function _verify_dependencies() { + if [ -z "${TEST}" ]; then + # fzf is only required if we are not explicitly specifying a test. + _verify_fzf + fi + # jq is always required to determine the entrypoint of the test. + _verify_jq +} + # _get_test returns the test that should be used in the e2e test. If an argument is provided, that argument # is returned. Otherwise, fzf is used to interactively choose from all available tests. function _get_test(){