Skip to content

Commit

Permalink
close #18 close #19 hooks/bin/git-TEST-cases.sh done with testing rea…
Browse files Browse the repository at this point in the history
…dy for production
  • Loading branch information
BradleyA committed Sep 17, 2019
1 parent b4aac4c commit a6838a7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
14 changes: 12 additions & 2 deletions hooks/EXAMPLES/SA-shellcheck-001
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# hooks/EXAMPLES/SA-shellcheck-001 2.94.553 2019-09-17T12:16:59.237567-05:00 (CDT) https://github.com/BradleyA/git-TEST-commit-automation.git uadmin five-rpi3b.cptx86.com 2.93
# close #18 close #19 hooks/bin/git-TEST-cases.sh done with testing ready for production
# hooks/EXAMPLES/SA-shellcheck-001 2.65.489 2019-09-13T09:46:25.137946-05:00 (CDT) https://github.com/BradleyA/git-TEST-commit-automation.git uadmin five-rpi3b.cptx86.com 2.64-18-ga5bfb20
# hooks/EXAMPLES/SA-shellcheck-001 added comment about SA-shellcheck-001.expected file is REQUIRED in the test directory.
# hooks/EXAMPLES/SA-shellcheck-001 2.59.423 2019-09-08T22:15:43.170194-05:00 (CDT) https://github.com/BradleyA/git-TEST-commit-automation.git uadmin five-rpi3b.cptx86.com 2.58
Expand Down Expand Up @@ -47,15 +49,23 @@ if [[ "${DEBUG}" == "1" ]] ; then new_message "${SCRIPT_NAME}" "${LINENO}" "DEBU

# NOTE: SA-shellcheck-001.expected file is REQUIRED in the test directory. Either an empty file if no error are expected or a file with expected errors

shellcheck "${1}" > "${0}".test-case-output # analyse code for potential errors

if [[ ! -e "${0}.expected" ]] ; then
echo "${BOLD}Test case --->${NORMAL} ${0} ${1} ${RETURN_CODE} - ${0}.expected was not found. Unable to compare shellcheck output - ${BOLD}ERROR - ERROR${NORMAL}"
exit 2
fi

#>>> add code here to remove all lines before the line including #86#
#>>> mktemp file ???
#>>> cp ${1} into temp-file
#>>> sed -i '/#86#/,$!d' ./temp-file
#>>> shellcheck "${./temp-file}" > "${0}".test-case-output # analyse code for potential errors
#>>> diff "${0}".expected "${0}".test-case-output >/dev/null 2>&1

shellcheck "${1}" > "${0}".test-case-output # analyse code for potential errors

diff "${0}".expected "${0}".test-case-output >/dev/null 2>&1
RETURN_CODE=${?}

if [[ "${RETURN_CODE}" -eq 0 ]] ; then
echo "${BOLD}Test case --->${NORMAL} ${0} ${1} ${RETURN_CODE} - No difference with expected output - ${BOLD}PASS - PASS${NORMAL}"
cat "${0}".test-case-output
Expand Down
14 changes: 7 additions & 7 deletions hooks/bin/git-TEST-cases.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# hooks/bin/git-TEST-cases.sh 2.93.552 2019-09-17T11:20:41.129205-05:00 (CDT) https://github.com/BradleyA/git-TEST-commit-automation.git uadmin five-rpi3b.cptx86.com 2.92-1-g916f760
# #19 hooks/bin/git-TEST-cases.sh updated new_message 'Only one of these option -a, --all, -c, --clean, -n, or -none can be selected.'
# hooks/bin/git-TEST-cases.sh 2.94.553 2019-09-17T12:16:59.374340-05:00 (CDT) https://github.com/BradleyA/git-TEST-commit-automation.git uadmin five-rpi3b.cptx86.com 2.93
# close #18 close #19 hooks/bin/git-TEST-cases.sh done with testing ready for production
# hooks/bin/git-TEST-cases.sh 2.92.550 2019-09-17T10:54:54.644826-05:00 (CDT) https://github.com/BradleyA/git-TEST-commit-automation.git uadmin five-rpi3b.cptx86.com 2.91
# close #3 hooks/bin/git-TEST-cases.sh
#86# hooks/bin/git-TEST-cases.sh - search from top of repository to list TEST directory test cases
Expand Down Expand Up @@ -133,7 +133,7 @@ if [[ "${ALL_TEST_CASES}" == "" ]] ; then ALL_TEST_CASES=${DEFAULT_ALL_TEST_CASE

###

### Production standard 9.3.513 Parse CLI options and arguments
### Production standard 9.3.513 Parse CLI options and arguments #19
# hooks/bin/git-TEST-cases.sh - add option to not show TEST cases for hooks/
# -a --all 1) Print all files with test cases exclude hooks/ (create links)
# -c --clean 2) Remove linked TEST cases and run FVT-cleanup.sh & SA-cleanup.sh
Expand All @@ -160,7 +160,7 @@ while [[ "${#}" -gt 0 ]] ; do
display_usage ; new_message "${SCRIPT_NAME}" "${LINENO}" "ERROR" " Argument for ${1} is not found on command line" 1>&2 ; exit 1
fi ; FILE_NAME=${2} ; shift 2 ;;
--hooks|-hooks) ALL_TEST_CASES="YES" ; shift ;;
-n|--none) if [[ "${CLI_OPTION}" != "" ]] ; then
-n|--none) if [[ "${CLI_OPTION}" != "" ]] ; then # #18
new_message "${SCRIPT_NAME}" "${LINENO}" "ERROR" " Only one of these option -a, --all, -c, --clean, -n, or -none can be selected." 1>&2 ; exit 1
else
CLI_OPTION="n" ; shift
Expand All @@ -179,14 +179,14 @@ if [[ "${CLI_OPTION}" == "f" ]] ; then
if [[ -x "SA-setup.sh" ]] ; then ./SA-setup.sh ; fi
cd "${REPOSITORY_DIR}"
if [[ "${ALL_TEST_CASES}" == "YES" ]] ; then
echo ">>> words go here, add later . . . . find anywhere"
find . -print | grep --color=auto "${FILE_NAME}"
echo ">>> words go here, add later . . maybe new_message . . find anywhere"
else
echo ">>> words go here, add later . . . . f not found try using --hooks option find anywhere NOT in /hooks"
find . -print | grep -v 'hooks/' | grep --color=auto "${FILE_NAME}"
echo ">>> words go here, add later . . maybe new_message . . file not found try using --hooks option find anywhere NOT in /hooks"
fi
else
if [[ "${CLI_OPTION}" == "n" ]] ; then
if [[ "${CLI_OPTION}" == "n" ]] ; then # #18
TMP_GITALLFILES=$(mktemp /tmp/GITALLFILESXXXXXX) # create temporary file for all files in repository
TMP_GITALLFILES_NOTESTDIR=$(mktemp /tmp/GITALLFILES_NOTESTDIRXXXXXX) # create temporary file for all files in repository that have a /TEST/<filename>/ directory
if [[ "${ALL_TEST_CASES}" == "YES" ]] ; then
Expand Down

0 comments on commit a6838a7

Please sign in to comment.