diff --git a/tests/TESTS_RUNNER.sh b/tests/TESTS_RUNNER.sh index 41c5f4a..7e680b4 100755 --- a/tests/TESTS_RUNNER.sh +++ b/tests/TESTS_RUNNER.sh @@ -1,10 +1,19 @@ #!/bin/bash -# ADD AS MANY LINES AS TESTS FILE YOU HAVE TO RUN THEM ALL +LGREEN='\033[0;32m' +NC='\033[0m' # No Color +TESTS_TRASH_DIR="tests/.ignore.tests_trash/" +declare -a files=("tests/project_scaffolding_test.sh" "tests/custom_data_test.sh") # all the tests -mkdir -p tests/.ignore.tests_trash +center() { + term_width="$(tput cols)" + padding="$(printf '%0.1s' +{1..500})" + echo -e "\n\n${LGREEN}$(printf '%*.*s %s %*.*s\n' 0 "$(((term_width - 2 - ${#1}) / 2))" "$padding" "$1" 0 "$(((term_width - 1 - ${#1}) / 2))" "$padding")${NC}\n" +} -echo -e "\n\n--------------------------------\nrunning ./tests/project_scaffolding.sh" -./tests/project_scaffolding.sh - -#rm -r tests/.ignore.tests_trash +for file in "${files[@]}"; do + mkdir -p tests/.ignore.tests_trash + center "TEST: running test ./$file" + ./"$file" + rm -r $TESTS_TRASH_DIR +done diff --git a/tests/project_scaffolding.sh b/tests/custom_data_test.sh similarity index 78% rename from tests/project_scaffolding.sh rename to tests/custom_data_test.sh index bb5611f..393b993 100755 --- a/tests/project_scaffolding.sh +++ b/tests/custom_data_test.sh @@ -1,5 +1,5 @@ #! /bin/bash -# file: examples/arguments_test.sh +# file: examples/custom_data_test.sh TESTS_TRASH_DIR="tests/.ignore.tests_trash" USERNAME="FAKE_USERNAME_TESTS" @@ -7,25 +7,28 @@ NAME="FAKE_NAME_TESTS" MAIL="FAKE_EMAIL_TESTS" OMIT_STR="--omit-commit-and-confirmation" -cp -r * $TESTS_TRASH_DIR --copy-content 2>/dev/null || : -cp -r .github/ $TESTS_TRASH_DIR --copy-contents -cp -r bin/ $TESTS_TRASH_DIR --copy-contents -cp .gitignore $TESTS_TRASH_DIR --copy-contents -rm -r $TESTS_TRASH_DIR/tests/ 2>/dev/null || : -rm -r $TESTS_TRASH_DIR/.git/ 2>/dev/null || : +oneTimeSetUp() { + cp -r * $TESTS_TRASH_DIR --copy-content 2>/dev/null || : + cp -r .github/ $TESTS_TRASH_DIR --copy-contents + cp -r bin/ $TESTS_TRASH_DIR --copy-contents + cp .gitignore $TESTS_TRASH_DIR --copy-contents + rm -r $TESTS_TRASH_DIR/tests/ 2>/dev/null || : + rm -r $TESTS_TRASH_DIR/.git/ 2>/dev/null || : + cd $TESTS_TRASH_DIR || exit + bash SETUP_TEMPLATE.sh $USERNAME $NAME $MAIL $OMIT_STR >/dev/null +} -# TESTS +oneTimeTearDown() { + cd "../.." || exit +} +# TESTS suite() { - cd $TESTS_TRASH_DIR || exit - - bash SETUP_TEMPLATE.sh $USERNAME $NAME $MAIL $OMIT_STR suite_addTest testDotGithubFolder suite_addTest testDotGithubISSUE_TEMPLATE suite_addTest testDotGithubISSUE_TEMPLATEFiles suite_addTest testDotGithubFiles - } testDotGithubFolder() { @@ -63,4 +66,3 @@ testDotGithubFiles() { # Load and run shUnit2. . tests/shunit2 -cd "../.." || exit diff --git a/tests/project_scaffolding_test.sh b/tests/project_scaffolding_test.sh new file mode 100755 index 0000000..b4dad54 --- /dev/null +++ b/tests/project_scaffolding_test.sh @@ -0,0 +1,68 @@ +#! /bin/bash +# file: examples/project_scaffolding_test.sh + +TESTS_TRASH_DIR="tests/.ignore.tests_trash" +USERNAME="FAKE_USERNAME_TESTS" +NAME="FAKE_NAME_TESTS" +MAIL="FAKE_EMAIL_TESTS" +OMIT_STR="--omit-commit-and-confirmation" + +oneTimeSetUp() { + cp -r * $TESTS_TRASH_DIR --copy-content 2>/dev/null || : + cp -r .github/ $TESTS_TRASH_DIR --copy-contents + cp -r bin/ $TESTS_TRASH_DIR --copy-contents + cp .gitignore $TESTS_TRASH_DIR --copy-contents + rm -r $TESTS_TRASH_DIR/tests/ 2>/dev/null || : + rm -r $TESTS_TRASH_DIR/.git/ 2>/dev/null || : + cd $TESTS_TRASH_DIR || exit + bash SETUP_TEMPLATE.sh $USERNAME $NAME $MAIL $OMIT_STR >/dev/null +} + +oneTimeTearDown() { + cd "../.." || exit +} + +# TESTS +suite() { + + suite_addTest testDotGithubFolder + suite_addTest testDotGithubISSUE_TEMPLATE + suite_addTest testDotGithubISSUE_TEMPLATEFiles + suite_addTest testDotGithubFiles +} + +testDotGithubFolder() { + githubFolderFound=0 + if [ -e ".github/" ]; then + githubFolderFound=1 + fi + assertEquals 1 $githubFolderFound + +} + +testDotGithubISSUE_TEMPLATE() { + folderFound=0 + if [ -e ".github/ISSUE_TEMPLATE" ]; then + folderFound=1 + fi + assertEquals 1 $folderFound +} + +testDotGithubISSUE_TEMPLATEFiles() { + filesFound=0 + if [ -e ".github/ISSUE_TEMPLATE/1-bug-report.md" ] && [ -e ".github/ISSUE_TEMPLATE/2-failing-test.md" ] && [ -e ".github/ISSUE_TEMPLATE/3-docs-bug.md" ] && [ -e ".github/ISSUE_TEMPLATE/4-feature-request.md" ] && [ -e ".github/ISSUE_TEMPLATE/5-enhancement-request.md" ] && [ -e ".github/ISSUE_TEMPLATE/6-security-report.md" ] && [ -e ".github/ISSUE_TEMPLATE/7-question-support.md" ] && [ -e ".github/ISSUE_TEMPLATE/config.yml" ]; then + filesFound=1 + fi + assertEquals 1 $filesFound +} + +testDotGithubFiles() { + filesFound=0 + if [ -e ".github/CODEOWNERS" ] && [ -e ".github/CODE_OF_CONDUCT.md" ] && [ -e ".github/CONTRIBUTING.md" ] && [ -e ".github/ISSUE_TEMPLATE.md" ] && [ -e ".github/pull_request_template.md" ] && [ -e ".github/SECURITY.md" ] && [ -e ".github/SUPPORT.md" ] && [ -e ".github/issue_label_bot.yaml" ] && [ -e ".github/config.yml" ] && [ -e ".github/FUNDING.yml" ] && [ -e ".github/settings.yml" ]; then + filesFound=1 + fi + assertEquals 1 $filesFound +} + +# Load and run shUnit2. +. tests/shunit2