From e8c743afc1897ea477168bc1e2f3489e9a69385a Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Tue, 5 Sep 2023 07:23:30 -0400 Subject: [PATCH] Bash: fix errecho for multiple services (#5345) fixes for errecho general test fix --- .../awsdocs_general.sh | 2 +- aws-cli/bash-linux/iam/awsdocs_general.sh | 2 +- .../{test_general.sh => include_tests.sh} | 2 +- .../bash-linux/iam/tests/test_iam_examples.sh | 2 +- .../medical-imaging/awsdocs_general.sh | 2 +- .../{test_general.sh => include_tests.sh} | 2 +- .../tests/test_medical_imaging_examples.sh | 2 +- aws-cli/bash-linux/run_tests.sh | 20 +++++++++++++++++++ .../awsdocs_general.sh | 4 ++-- 9 files changed, 29 insertions(+), 9 deletions(-) rename aws-cli/bash-linux/iam/tests/{test_general.sh => include_tests.sh} (98%) rename aws-cli/bash-linux/medical-imaging/tests/{test_general.sh => include_tests.sh} (98%) create mode 100755 aws-cli/bash-linux/run_tests.sh diff --git a/aws-cli/bash-linux/ec2/change-ec2-instance-type/awsdocs_general.sh b/aws-cli/bash-linux/ec2/change-ec2-instance-type/awsdocs_general.sh index 6464fcdb1e7..12330db1bd4 100644 --- a/aws-cli/bash-linux/ec2/change-ec2-instance-type/awsdocs_general.sh +++ b/aws-cli/bash-linux/ec2/change-ec2-instance-type/awsdocs_general.sh @@ -90,7 +90,7 @@ function test_failed { # This function outputs everything sent to it to STDERR (standard error output). ############################################################################### function errecho { - printf "%b\n" "$*" 2>&1 + printf "%b\n" "$*" 1>&2 } ############################################################################### diff --git a/aws-cli/bash-linux/iam/awsdocs_general.sh b/aws-cli/bash-linux/iam/awsdocs_general.sh index 446dcb839e6..fa6d4cf6655 100644 --- a/aws-cli/bash-linux/iam/awsdocs_general.sh +++ b/aws-cli/bash-linux/iam/awsdocs_general.sh @@ -35,7 +35,7 @@ VERBOSE=false # This function outputs everything sent to it to STDERR (standard error output). ############################################################################### function errecho() { - printf "%s\n" "$*" 2>&1 + printf "%s\n" "$*" 1>&2 } # snippet-end:[aws-cli.bash-linux.iam.errecho] diff --git a/aws-cli/bash-linux/iam/tests/test_general.sh b/aws-cli/bash-linux/iam/tests/include_tests.sh similarity index 98% rename from aws-cli/bash-linux/iam/tests/test_general.sh rename to aws-cli/bash-linux/iam/tests/include_tests.sh index d4b96e01e35..6bc1aec82c4 100644 --- a/aws-cli/bash-linux/iam/tests/test_general.sh +++ b/aws-cli/bash-linux/iam/tests/include_tests.sh @@ -48,7 +48,7 @@ function run_test() { # Check to see if we got the expected error code. if [[ "$expected_err_code" -ne "$err" ]]; then - test_failed "The test \"$description\" returned an unexpected error code: $err" + test_failed "The test \"$description\" returned an unexpected error code: $err. $test_command_response" fi # Check the error message, if we provided other than "". diff --git a/aws-cli/bash-linux/iam/tests/test_iam_examples.sh b/aws-cli/bash-linux/iam/tests/test_iam_examples.sh index 486321b4d90..65a57422a16 100755 --- a/aws-cli/bash-linux/iam/tests/test_iam_examples.sh +++ b/aws-cli/bash-linux/iam/tests/test_iam_examples.sh @@ -30,7 +30,7 @@ function main() { # bashsupport disable=BP2001 export VERBOSE=false - source ./test_general.sh + source ./include_tests.sh { local current_directory current_directory=$(pwd) diff --git a/aws-cli/bash-linux/medical-imaging/awsdocs_general.sh b/aws-cli/bash-linux/medical-imaging/awsdocs_general.sh index 68faf524a08..38fc949a9f3 100644 --- a/aws-cli/bash-linux/medical-imaging/awsdocs_general.sh +++ b/aws-cli/bash-linux/medical-imaging/awsdocs_general.sh @@ -35,7 +35,7 @@ VERBOSE=false # This function outputs everything sent to it to STDERR (standard error output). ############################################################################### function errecho() { - printf "%s\n" "$*" 2>&1 + printf "%s\n" "$*" 1>&2 } # snippet-end:[aws-cli.bash-linux.medical-imaging.errecho] diff --git a/aws-cli/bash-linux/medical-imaging/tests/test_general.sh b/aws-cli/bash-linux/medical-imaging/tests/include_tests.sh similarity index 98% rename from aws-cli/bash-linux/medical-imaging/tests/test_general.sh rename to aws-cli/bash-linux/medical-imaging/tests/include_tests.sh index d4b96e01e35..6bc1aec82c4 100644 --- a/aws-cli/bash-linux/medical-imaging/tests/test_general.sh +++ b/aws-cli/bash-linux/medical-imaging/tests/include_tests.sh @@ -48,7 +48,7 @@ function run_test() { # Check to see if we got the expected error code. if [[ "$expected_err_code" -ne "$err" ]]; then - test_failed "The test \"$description\" returned an unexpected error code: $err" + test_failed "The test \"$description\" returned an unexpected error code: $err. $test_command_response" fi # Check the error message, if we provided other than "". diff --git a/aws-cli/bash-linux/medical-imaging/tests/test_medical_imaging_examples.sh b/aws-cli/bash-linux/medical-imaging/tests/test_medical_imaging_examples.sh index 5ae1ed3863e..7974143d4cd 100755 --- a/aws-cli/bash-linux/medical-imaging/tests/test_medical_imaging_examples.sh +++ b/aws-cli/bash-linux/medical-imaging/tests/test_medical_imaging_examples.sh @@ -29,7 +29,7 @@ export INTERACTIVE=false # bashsupport disable=BP2001 export VERBOSE=false - source ./test_general.sh + source ./include_tests.sh { local current_directory current_directory=$(pwd) diff --git a/aws-cli/bash-linux/run_tests.sh b/aws-cli/bash-linux/run_tests.sh new file mode 100755 index 00000000000..315ca9cbf72 --- /dev/null +++ b/aws-cli/bash-linux/run_tests.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +base_dir=$(pwd) + +echo "Running tests for S3 Bucket Lifecycle Operations" +cd s3/bucket-lifecycle-operations/ +./test_bucket_operations.sh +cd $base_dir + +echo "Running IAM tests" +cd iam/tests +./test_iam_examples.sh +cd $base_dir + +echo "Running medical-imaging tests" +cd medical-imaging/tests +./test_medical_imaging_examples.sh +cd $base_dir + +echo "Done" \ No newline at end of file diff --git a/aws-cli/bash-linux/s3/bucket-lifecycle-operations/awsdocs_general.sh b/aws-cli/bash-linux/s3/bucket-lifecycle-operations/awsdocs_general.sh index d888ce953d2..be212a49edd 100644 --- a/aws-cli/bash-linux/s3/bucket-lifecycle-operations/awsdocs_general.sh +++ b/aws-cli/bash-linux/s3/bucket-lifecycle-operations/awsdocs_general.sh @@ -53,7 +53,7 @@ function run_test() { # Check to see if we got the expected error code. if [[ "$expected_err_code" -ne "$err" ]]; then - test_failed "The test \"$description\" returned an unexpected error code: $err" + test_failed "The test \"$description\" returned an unexpected error code: $err. $test_command_response" fi # Check the error message, if we provided other than "". @@ -101,7 +101,7 @@ function test_failed() { # This function outputs everything sent to it to STDERR (standard error output). ############################################################################### function errecho() { - printf "%s\n" "$*" 2>&1 + printf "%s\n" "$*" 1>&2 } # snippet-end:[aws-cli.bash-linux.s3.errecho]