From 8cb87831b4abc294a9165162f00e0156176b129c Mon Sep 17 00:00:00 2001 From: Josee9988 Date: Thu, 8 Jul 2021 14:02:46 +0200 Subject: [PATCH] "improved and prepared all the folders for the tests" --- SETUP_TEMPLATE.sh | 2 +- bin/FUNCTION_HELPERS.sh | 4 ++-- tests/TESTS_RUNNER.sh | 4 ++-- tests/project_scaffolding.sh | 24 ++++++++++++++++-------- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/SETUP_TEMPLATE.sh b/SETUP_TEMPLATE.sh index 6e03f74..65f0719 100644 --- a/SETUP_TEMPLATE.sh +++ b/SETUP_TEMPLATE.sh @@ -86,7 +86,7 @@ y | Y) rm LICENSE # remove the license rm -r bin/ # remove the bin folder - rm -r tests/ # remove the tests folder + rm -r tests/ 2>/dev/null || : # remove the tests folder writeREADME # write the new README.md writeCHANGELOG # write the basic structure of the CHANGELOG.md echo -e "# add your own funding links" >.github/FUNDING.yml # remove author's custom funding links diff --git a/bin/FUNCTION_HELPERS.sh b/bin/FUNCTION_HELPERS.sh index 368005c..5cbc1f8 100644 --- a/bin/FUNCTION_HELPERS.sh +++ b/bin/FUNCTION_HELPERS.sh @@ -31,14 +31,14 @@ center() { checkFiles() { ### Check if the .github directory does exist ### - if [ ! -d ".github/" ] || [ ! -d ".github/ISSUE_TEMPLATE" ]; then + if [ ! -d ".github/" ] && [ ! -d ".github/ISSUE_TEMPLATE" ]; then echo -e "${RED}Directory .github/ DOES NOT EXIST WITH ALL THE FILES NEEDED.${NC}" displayErrorInstructions exit 1 # exit with error code 1 fi ### Checks if the root files exist and some extra important files ### - if [ ! -f "CHANGELOG.md" ] || [ ! -f "README.md" ] || [ ! -f ".gitignore" ] || [ ! -f "LICENSE" ] || [ ! -f ".github/settings.yml" ] || [ ! -f ".github/pull_request_template.md" ] || [ ! -f ".github/ISSUE_TEMPLATE/1-bug-report.md" ] || [ ! -f ".github/ISSUE_TEMPLATE/config.yml" ]; then + if [ ! -f "CHANGELOG.md" ] && [ ! -f "README.md" ] && [ ! -f ".gitignore" ] && [ ! -f "LICENSE" ] && [ ! -f ".github/settings.yml" ] && [ ! -f ".github/pull_request_template.md" ] && [ ! -f ".github/ISSUE_TEMPLATE/1-bug-report.md" ] && [ ! -f ".github/ISSUE_TEMPLATE/config.yml" ]; then echo -e "${RED}The script couldn't find one or many of the template main files${NC}." displayErrorInstructions exit 1 # exit with error code 1 diff --git a/tests/TESTS_RUNNER.sh b/tests/TESTS_RUNNER.sh index a0cb94d..41c5f4a 100755 --- a/tests/TESTS_RUNNER.sh +++ b/tests/TESTS_RUNNER.sh @@ -2,9 +2,9 @@ # ADD AS MANY LINES AS TESTS FILE YOU HAVE TO RUN THEM ALL -mkdir -p tests/.tests_trash/ +mkdir -p tests/.ignore.tests_trash echo -e "\n\n--------------------------------\nrunning ./tests/project_scaffolding.sh" ./tests/project_scaffolding.sh -rm -r tests/.tests_trash +#rm -r tests/.ignore.tests_trash diff --git a/tests/project_scaffolding.sh b/tests/project_scaffolding.sh index f12f365..bb5611f 100755 --- a/tests/project_scaffolding.sh +++ b/tests/project_scaffolding.sh @@ -1,18 +1,26 @@ #! /bin/bash # file: examples/arguments_test.sh -TESTS_TRASH_DIR="tests/.tests_trash" +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" 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 -rm -r $TESTS_TRASH_DIR/tests/ +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/.tests_trash" || 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 @@ -22,7 +30,7 @@ suite() { testDotGithubFolder() { githubFolderFound=0 - if [ -e "$TESTS_TRASH_DIR/.github/" ]; then + if [ -e ".github/" ]; then githubFolderFound=1 fi assertEquals 1 $githubFolderFound @@ -31,7 +39,7 @@ testDotGithubFolder() { testDotGithubISSUE_TEMPLATE() { folderFound=0 - if [ -e "$TESTS_TRASH_DIR/.github/ISSUE_TEMPLATE" ]; then + if [ -e ".github/ISSUE_TEMPLATE" ]; then folderFound=1 fi assertEquals 1 $folderFound @@ -39,7 +47,7 @@ testDotGithubISSUE_TEMPLATE() { testDotGithubISSUE_TEMPLATEFiles() { filesFound=0 - if [ -e "$TESTS_TRASH_DIR/.github/ISSUE_TEMPLATE/1-bug-report.md" ] && [ -e "$TESTS_TRASH_DIR/.github/ISSUE_TEMPLATE/2-failing-test.md" ] && [ -e "$TESTS_TRASH_DIR/.github/ISSUE_TEMPLATE/3-docs-bug.md" ] && [ -e "$TESTS_TRASH_DIR/.github/ISSUE_TEMPLATE/4-feature-request.md" ] && [ -e "$TESTS_TRASH_DIR/.github/ISSUE_TEMPLATE/5-enhancement-request.md" ] && [ -e "$TESTS_TRASH_DIR/.github/ISSUE_TEMPLATE/6-security-report.md" ] && [ -e "$TESTS_TRASH_DIR/.github/ISSUE_TEMPLATE/7-question-support.md" ] && [ -e "$TESTS_TRASH_DIR/.github/ISSUE_TEMPLATE/config.yml" ]; then + 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 @@ -47,12 +55,12 @@ testDotGithubISSUE_TEMPLATEFiles() { testDotGithubFiles() { filesFound=0 - if [ -e "$TESTS_TRASH_DIR/.github/CODEOWNERS" ] && [ -e "$TESTS_TRASH_DIR/.github/CODE_OF_CONDUCT.md" ] && [ -e "$TESTS_TRASH_DIR/.github/CONTRIBUTING.md" ] && [ -e "$TESTS_TRASH_DIR/.github/ISSUE_TEMPLATE.md" ] && [ -e "$TESTS_TRASH_DIR/.github/pull_request_template.md" ] && [ -e "$TESTS_TRASH_DIR/.github/SECURITY.md" ] && [ -e "$TESTS_TRASH_DIR/.github/SUPPORT.md" ] && [ -e "$TESTS_TRASH_DIR/.github/issue_label_bot.yaml" ] && [ -e "$TESTS_TRASH_DIR/.github/config.yml" ] && [ -e "$TESTS_TRASH_DIR/.github/FUNDING.yml" ] && [ -e "$TESTS_TRASH_DIR/.github/settings.yml" ]; then + 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. -#cd "../.." || exit . tests/shunit2 +cd "../.." || exit