From 8cd5969248d41931a6075517453e1f7dadb68f7e Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Sun, 9 Apr 2023 12:40:05 +0800 Subject: [PATCH] chore: use strict mode for tests/*/*.sh REF: #15514 Signed-off-by: Wei Fu --- tests/fixtures/gencerts.sh | 12 +++++++++--- tests/integration/fixtures-expired/gencerts.sh | 11 ++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/tests/fixtures/gencerts.sh b/tests/fixtures/gencerts.sh index e4226fca012..b2364cb7957 100755 --- a/tests/fixtures/gencerts.sh +++ b/tests/fixtures/gencerts.sh @@ -1,15 +1,21 @@ #!/bin/bash -set -e +set -euo pipefail if ! [[ "$0" =~ "./gencerts.sh" ]]; then echo "must be run from 'fixtures'" exit 255 fi -if ! which cfssl; then +if ! command -v cfssl; then echo "cfssl is not installed" - echo "use: go install -mod mod github.com/cloudflare/cfssl/cmd/cfssl github.com/cloudflare/cfssl/cmd/cfssljson" + echo "use: go install -mod mod github.com/cloudflare/cfssl/cmd/cfssl" + exit 255 +fi + +if ! command -v cfssljson; then + echo "cfssljson is not installed" + echo "use: go install -mod mod github.com/cloudflare/cfssl/cmd/cfssljson" exit 255 fi diff --git a/tests/integration/fixtures-expired/gencerts.sh b/tests/integration/fixtures-expired/gencerts.sh index aecdd423bba..b15ae25c609 100755 --- a/tests/integration/fixtures-expired/gencerts.sh +++ b/tests/integration/fixtures-expired/gencerts.sh @@ -1,12 +1,21 @@ #!/bin/bash +set -euo pipefail + if ! [[ "$0" =~ "./gencerts.sh" ]]; then echo "must be run from 'fixtures'" exit 255 fi -if ! which cfssl; then +if ! command -v cfssl; then echo "cfssl is not installed" + echo "use: go install -mod mod github.com/cloudflare/cfssl/cmd/cfssl" + exit 255 +fi + +if ! command -v cfssljson; then + echo "cfssljson is not installed" + echo "use: go install -mod mod github.com/cloudflare/cfssl/cmd/cfssljson" exit 255 fi