Skip to content

Commit

Permalink
Adjust 02a tests to new error output format
Browse files Browse the repository at this point in the history
  • Loading branch information
LegenJCdary committed Feb 16, 2023
1 parent d51045e commit 3e5e7da
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
7 changes: 3 additions & 4 deletions tests/02a-checkrun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ echo -e " ___ ____ _ _\n / _ \___ \ __ _
check_run_ok "ansible-deployer show --debug" "\[DEBUG\]: load_configuration called"

# Check different output options
check_message_in_output "ansible-deployer run --task task_with_ansible_fail --stage testing --infrastructure testInfra" "\[ERROR\]: TASK \[Run ll\]"
check_message_in_output "ansible-deployer run --task task_with_ansible_fail --stage testing --infrastructure testInfra --debug" "\[DEBUG\]: TASK \[Run ll\]"
check_message_not_in_output "ansible-deployer run --task task_with_ansible_fail --stage testing --infrastructure testInfra --raw-runner-output" "\[ERROR\]: TASK \[Run ll\]"
check_message_in_output "ansible-deployer run --task task_with_ansible_fail --stage testing --infrastructure testInfra --raw-runner-output --debug" "\[DEBUG\]: TASK \[Run ll\]"
check_message_with_newline_in_output "ansible-deployer run --task task_with_ansible_fail --stage testing --infrastructure testInfra" "\[ERROR\]:.*\n.*TASK \[Run ll\]"
check_message_with_newline_in_output "ansible-deployer run --task task_with_ansible_fail --stage testing --infrastructure testInfra --raw-runner-output" "\[ERROR\]:.*\n.*TASK \[Run ll\]"
check_message_with_newline_in_output "ansible-deployer run --task task_with_ansible_fail --stage testing --infrastructure testInfra --raw-runner-output" ".*\n.*TASK \[Run ll\]"

echo -e " ___ ____ _ _\n / _ \___ \ __ _ ___| |__ ___ ___| | ___ __ _ _ _ __\n | | | |__) / _\` | _____ / __| '_ \ / _ \/ __| |/ / '__| | | | '_ \ \n | |_| / __/ (_| | |_____| | (__| | | | __/ (__| <| | | |_| | | | |\n \___/_____\__,_| \___|_| |_|\___|\___|_|\_\_| \__,_|_| |_|\n \n _ _ _ _ _ _\n | (_)_ __ ___ (_) |_ ___ _ __ | |_(_) ___ _ __\n | | | '_ \` _ \| | __| / _ \| '_ \| __| |/ _ \| '_ \ \n | | | | | | | | | |_ | (_) | |_) | |_| | (_) | | | |\n |_|_|_| |_| |_|_|\__| \___/| .__/ \__|_|\___/|_| |_|\n |_|\n"
# Check --limit option
Expand Down
7 changes: 3 additions & 4 deletions tests/02a-checkrun_short.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ echo -e " ___ ____ _ _
check_run_ok "ansible-deployer show -d" "\[DEBUG\]: load_configuration called"

# Check different output options
check_message_in_output "ansible-deployer run -t task_with_ansible_fail -s testing -i testInfra" "\[ERROR\]: TASK \[Run ll\]"
check_message_in_output "ansible-deployer run -t task_with_ansible_fail -s testing -i testInfra -d" "\[DEBUG\]: TASK \[Run ll\]"
check_message_not_in_output "ansible-deployer run -t task_with_ansible_fail -s testing -i testInfra --raw-runner-output" "\[ERROR\]: TASK \[Run ll\]"
check_message_in_output "ansible-deployer run -t task_with_ansible_fail -s testing -i testInfra --raw-runner-output -d" "\[DEBUG\]: TASK \[Run ll\]"
check_message_with_newline_in_output "ansible-deployer run -t task_with_ansible_fail -s testing -i testInfra" "\[ERROR\]:.*\n.*TASK \[Run ll\]"
check_message_with_newline_in_output "ansible-deployer run -t task_with_ansible_fail -s testing -i testInfra --raw-runner-output" "\[ERROR\]:.*\n.*TASK \[Run ll\]"
check_message_with_newline_in_output "ansible-deployer run -t task_with_ansible_fail -s testing -i testInfra --raw-runner-output" ".*\n.*TASK \[Run ll\]"

echo -e " ___ ____ _ _ _ _\n / _ \___ \ __ _ ___| |__ ___ ___| | ___ __ _ _ _ __ ___| |__ ___ _ __| |_\n | | | |__) / _\` | _____ / __| '_ \ / _ \/ __| |/ / '__| | | | '_ \ / __| '_ \ / _ \| '__| __|\n | |_| / __/ (_| | |_____| | (__| | | | __/ (__| <| | | |_| | | | | \__ \ | | | (_) | | | |_\n \___/_____\__,_| \___|_| |_|\___|\___|_|\_\_| \__,_|_| |_| |___/_| |_|\___/|_| \__|\n \n _ _ _ _ _ _\n | (_)_ __ ___ (_) |_ ___ _ __ | |_(_) ___ _ __\n | | | '_ \` _ \| | __| / _ \| '_ \| __| |/ _ \| '_ \ \n | | | | | | | | | |_ | (_) | |_) | |_| | (_) | | | |\n |_|_|_| |_| |_|_|\__| \___/| .__/ \__|_|\___/|_| |_|\n |_|\n"
# Check --limit option
Expand Down
32 changes: 32 additions & 0 deletions tests/testing_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,35 @@ check_file_startingwith_in_dir() {
exit 1
fi
}

check_message_with_newline_in_output() {
CMD=$1
EXPTEXT=$2
echo "Check: $CMD"
eval "$CMD |& grep -zP '$EXPTEXT'"
if [ $? -eq 0 ]
then
echo "OK: '${CMD}' returned '${EXPTEXT}'"
else
echo "FAILED: '${CMD}' didn't return '${EXPTEXT}'"
echo $CMD
eval $CMD
exit 1
fi
}

check_message_with_newline_not_in_output() {
CMD=$1
EXPTEXT=$2
echo "Check: $CMD"
eval "$CMD |& grep -zP '$EXPTEXT'"
if [ $? -eq 0 ]
then
echo "FAILED: '${CMD}' returned '${EXPTEXT}'"
echo $CMD
eval $CMD
exit 1
else
echo "OK: '${CMD}' didn't return '${EXPTEXT}'"
fi
}

0 comments on commit 3e5e7da

Please sign in to comment.