From 413fd1104369b7f2349f484636b42f5dd79bf601 Mon Sep 17 00:00:00 2001 From: David Acacio Date: Wed, 1 Apr 2015 16:27:30 +0200 Subject: [PATCH 1/2] Added color code to the result (green, red & yellow) --- src/shunit2 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/shunit2 b/src/shunit2 index 7077149..a79cb51 100755 --- a/src/shunit2 +++ b/src/shunit2 @@ -829,18 +829,18 @@ _shunit_generateReport() && _shunit_skipped_="skipped=${__shunit_assertsSkipped}" if [ ${_shunit_ok_} -eq ${SHUNIT_TRUE} ]; then - _shunit_msg_='OK' + _shunit_msg_='\e[32mOK' [ -n "${_shunit_skipped_}" ] \ && _shunit_msg_="${_shunit_msg_} (${_shunit_skipped_})" else - _shunit_msg_="FAILED (${_shunit_failures_}" + _shunit_msg_="\e[31mFAILED (${_shunit_failures_}" [ -n "${_shunit_skipped_}" ] \ && _shunit_msg_="${_shunit_msg_},${_shunit_skipped_}" _shunit_msg_="${_shunit_msg_})" fi echo - echo ${_shunit_msg_} + echo -e ${_shunit_msg_}"\e[0m" __shunit_reportGenerated=${SHUNIT_TRUE} unset _shunit_failures_ _shunit_msg_ _shunit_ok_ _shunit_skipped_ @@ -879,7 +879,7 @@ _shunit_assertFail() __shunit_testSuccess=${SHUNIT_FALSE} __shunit_assertsFailed=`expr ${__shunit_assertsFailed} + 1` __shunit_assertsTotal=`expr ${__shunit_assertsTotal} + 1` - echo "${__SHUNIT_ASSERT_MSG_PREFIX}${_shunit_msg_}" + echo -e "\e[93m${__SHUNIT_ASSERT_MSG_PREFIX}${_shunit_msg_}\e[0m" unset _shunit_msg_ } From 6bc5841f1765c12e4af558fcc5f9f354963ade77 Mon Sep 17 00:00:00 2001 From: David Acacio Date: Thu, 6 Jul 2017 15:51:37 +0200 Subject: [PATCH 2/2] Fix code to pass tests in bash and sh. --- src/shunit2 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/shunit2 b/src/shunit2 index a79cb51..c08291b 100755 --- a/src/shunit2 +++ b/src/shunit2 @@ -829,18 +829,24 @@ _shunit_generateReport() && _shunit_skipped_="skipped=${__shunit_assertsSkipped}" if [ ${_shunit_ok_} -eq ${SHUNIT_TRUE} ]; then - _shunit_msg_='\e[32mOK' + _shunit_msg_='OK' [ -n "${_shunit_skipped_}" ] \ && _shunit_msg_="${_shunit_msg_} (${_shunit_skipped_})" else - _shunit_msg_="\e[31mFAILED (${_shunit_failures_}" + _shunit_msg_="FAILED (${_shunit_failures_}" [ -n "${_shunit_skipped_}" ] \ && _shunit_msg_="${_shunit_msg_},${_shunit_skipped_}" _shunit_msg_="${_shunit_msg_})" fi echo - echo -e ${_shunit_msg_}"\e[0m" + if [ "${_shunit_msg_}" = 'OK' ]; then + echo -e "$(tput setaf 2)" + else + echo -e "$(tput setaf 2)" + fi + echo ${_shunit_msg_} + echo -e "$(tput sgr0)" __shunit_reportGenerated=${SHUNIT_TRUE} unset _shunit_failures_ _shunit_msg_ _shunit_ok_ _shunit_skipped_ @@ -879,7 +885,7 @@ _shunit_assertFail() __shunit_testSuccess=${SHUNIT_FALSE} __shunit_assertsFailed=`expr ${__shunit_assertsFailed} + 1` __shunit_assertsTotal=`expr ${__shunit_assertsTotal} + 1` - echo -e "\e[93m${__SHUNIT_ASSERT_MSG_PREFIX}${_shunit_msg_}\e[0m" + echo "${__SHUNIT_ASSERT_MSG_PREFIX}${_shunit_msg_}" unset _shunit_msg_ }