Skip to content

Commit

Permalink
Merge pull request #24 from ColColty/dev
Browse files Browse the repository at this point in the history
Adding reformed code v1.2
  • Loading branch information
ColColty authored May 25, 2019
2 parents f950e42 + ba550c2 commit 48dca63
Show file tree
Hide file tree
Showing 15 changed files with 387 additions and 448 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pyc
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ jobs:
- make
- chmod +x ./ci/test_remove.sh
- ./ci/test_move.sh
-
name: "All tests with the same environment"
script:
- make tests_run
- stage: Deployment
name: "Push to docker hub"
script:
- docker build . -t makefile_completer
- docker build . -t colcolt/makefile_completer
- docker push colcolt/makefile_completer:latest

stages:
Expand All @@ -52,4 +56,4 @@ stages:

env:
global:
secure: Z/7Iv2cNGxCZBdHPos+CSvjkk92ru4dCSynHT50SuYJAi58IZOg/WcbjEKzSwMylpi+1SJqLXAoF7ugutTcW+XAmlbPUei+T6KFHmWsNcgZeUM2dmWQy6OI7UX3drBmBGIa50YUwNmay1QdsTMGeN5QiqebNs1FBdMyAk8zHRLqBBxO2M82rcE/KhRElSMghGdOlec2BJQp13I2dS+uodr5DB68Dr9k4nAFWlHjNwLjWQo5TJZzpYut2eJcmSHMOkEXzTiFyXyw/bW9VUrO2AfUtEnqFOD8m/vpBWS5l9JeuL+m8wLUjjr6REU+R7dlzTo+n6eVSo998iOlpusaiNvjYdE2Na6KodBZjm7V0/JLlF2GJLO/6Ht/K5L7fPAftFjrmylGsyiuYJy+xp7s5NYuRy4229z7hsK2/pNt563zG5ZnPcoe/BQLGEAXjrbgcsvn/pEqZHMDt4UhhmF31q7IWe+16wT8OQSmsuEmz1EQ1QiRAkcTbcWotgcyE/oxLujP37KRNU/qBZ4lpAxPol7mgtsAb0hOkuPLI/FXO4xzjPbAnK8+1DcvSO2uLi6l53ZR/wfKr4ASKt/6CRXMiXus8GEbLgXj8JnOiPJOzb/tbEkcWfcVc07w3ldoMgP4peYYgEw6mKXAqut1uQJwPGVcP+q0Cx2Q9M/knB4ud2w8=
secure: Z/7Iv2cNGxCZBdHPos+CSvjkk92ru4dCSynHT50SuYJAi58IZOg/WcbjEKzSwMylpi+1SJqLXAoF7ugutTcW+XAmlbPUei+T6KFHmWsNcgZeUM2dmWQy6OI7UX3drBmBGIa50YUwNmay1QdsTMGeN5QiqebNs1FBdMyAk8zHRLqBBxO2M82rcE/KhRElSMghGdOlec2BJQp13I2dS+uodr5DB68Dr9k4nAFWlHjNwLjWQo5TJZzpYut2eJcmSHMOkEXzTiFyXyw/bW9VUrO2AfUtEnqFOD8m/vpBWS5l9JeuL+m8wLUjjr6REU+R7dlzTo+n6eVSo998iOlpusaiNvjYdE2Na6KodBZjm7V0/JLlF2GJLO/6Ht/K5L7fPAftFjrmylGsyiuYJy+xp7s5NYuRy4229z7hsK2/pNt563zG5ZnPcoe/BQLGEAXjrbgcsvn/pEqZHMDt4UhhmF31q7IWe+16wT8OQSmsuEmz1EQ1QiRAkcTbcWotgcyE/oxLujP37KRNU/qBZ4lpAxPol7mgtsAb0hOkuPLI/FXO4xzjPbAnK8+1DcvSO2uLi6l53ZR/wfKr4ASKt/6CRXMiXus8GEbLgXj8JnOiPJOzb/tbEkcWfcVc07w3ldoMgP4peYYgEw6mKXAqut1uQJwPGVcP+q0Cx2Q9M/knB4ud2w8=
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM python:3

COPY makefile_completer.py /app/makefile_completer.py
COPY . /app

RUN pip install --upgrade pip
RUN pip install watchdog

CMD [ "python3", "/app/makefile_completer.py" ]
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ repo_run:
echo "$(GREEN)Docker running in background, your Makefiles will be completed$(DEFAULT)" || \
echo "$(RED)There is a problem starting the docker on background$(DEFAULT)"

# TODO Create the program to create a Makefile and enable this rule
# new_makefile:
# @python3 scripts/makefile_creator.py && \
# echo "$(GREEN)The new Makefile was well created$(DEFAULT)" || \
Expand Down
137 changes: 37 additions & 100 deletions ci/test_add.sh
Original file line number Diff line number Diff line change
@@ -1,126 +1,63 @@
#!/bin/bash

echo -e "\033[1m Testing whem we the file has a bad extension\033[0m"

touch testing/src/bad_extension_file.pdf
# ================ functions ======================
function test_add() {
touch $1

sleep 3
sleep 4

python3 ./ci/tests/find_file.py "./testing/" "SRC\t=" "/bad_extension_file.pdf"
python3 ./ci/tests/find_file.py $2 $3 $4

if [ $? -ne 84 ]; then
echo -e "When the file has another extension than \".c\" it won't be add to Makefile"
exit 84
fi
if [ $? -ne $5 ]; then
echo -e "$1 FAILED with code $?"
exit 84
else
echo -e "\033[1;32m$1 PASSED\033[0m"
fi

rm testing/src/bad_extension_file.pdf
rm $1
sleep 2
}

echo -e "\033[1;32mTest 1 passed\033[0m"
function test_add_wfolder() {
mkdir $1
touch $1/$2

echo -e "\033[1m Testing whem we add a file in src\033[0m"
sleep 4

touch testing/src/good_file.c
python3 ./ci/tests/find_file.py $3 $4 $5

sleep 3
if [ $? -ne $6 ]; then
echo "$1/$2 FAILED with exit code $?"
exit 84
else
echo -e "\033[1;32m$1/$2 PASSED\033[0m"
fi

python3 ./ci/tests/find_file.py "./testing/" "SRC\t=" "/good_file.c"
rm $1/$2
sleep 2
}

if [ $? -ne 0 ]; then
echo -e "When a file with \".c\" extension was created it would be added to Makefile"
exit 84
fi

rm testing/src/good_file.c
echo -e "\033[1m Testing whem we the file has a bad extension\033[0m"
test_add testing/src/bad_extension_file.pdf "./testing/" "SRC\t=" "/bad_extension_file.pdf" 84

echo -e "\033[1;32mTest 2 passed\033[0m"
echo -e "\033[1m Testing whem we add a file in src\033[0m"
test_add testing/src/good_file.c "./testing/" "SRC\t=" "/good_file.c" 0

echo -e "\033[1m Testing whem we add a file on a folder in src\033[0m"

mkdir testing/src/folder
touch testing/src/folder/good_file.c

sleep 3

python3 ./ci/tests/find_file.py "./testing/" "SRC\t=" "/folder/good_file.c"

if [ $? -ne 0 ]; then
echo -e "When a file with \".c\" extension was created it would be added to Makefile"
exit 84
fi

rm testing/src/folder/good_file.c

echo -e "\033[1;32mTest 3 passed\033[0m"
test_add_wfolder testing/src/folder good_file.c "./testing/" "SRC\t=" "/folder/good_file.c" 0

echo -e "\033[1m Testing whem we add a file on tests\033[0m"

touch testing/tests/good_tests_file.c

sleep 3

python3 ./ci/tests/find_file.py "./testing/" "TESTS\t=" "/good_tests_file.c"

if [ $? -ne 0 ]; then
echo -e "When a file with \".c\" extension was created it would be added to Makefile"
exit 84
fi

rm testing/tests/good_tests_file.c

echo -e "\033[1;32mTest 4 passed\033[0m"
test_add testing/tests/good_tests_file.c "./testing/" "TESTS\t=" "/good_tests_file.c" 0

echo -e "\033[1m Testing whem we add a file in a folder in tests\033[0m"

mkdir testing/tests/folder
touch testing/tests/folder/good_tests_file.c

sleep 3

python3 ./ci/tests/find_file.py "./testing/" "TESTS\t=" "/folder/good_tests_file.c"

if [ $? -ne 0 ]; then
echo -e "When a file with \".c\" extension was created it would be added to Makefile"
exit 84
fi

rm testing/tests/folder/good_tests_file.c

echo -e "\033[1;32mTest 5 passed\033[0m"
test_add_wfolder testing/tests/folder good_tests_file.c "./testing/" "TESTS\t=" "/folder/good_tests_file.c" 0

echo -e "\033[1m Testing whem we add a file in lib/my\033[0m"

touch testing/lib/my/good_lib_file.c

sleep 3

python3 ./ci/tests/find_file.py "./testing/lib/my/" "SRC\t=" "good_lib_file.c"

if [ $? -ne 0 ]; then
echo -e "When a file with \".c\" extension was created it would be added to Makefile"
exit 84
fi

rm testing/lib/my/good_lib_file.c

echo -e "\033[1;32mTest 6 passed\033[0m"
test_add testing/lib/my/good_lib_file.c "./testing/lib/my/" "SRC\t=" "good_lib_file.c" 0

echo -e "\033[1m Testing whem we add a file in a folder in lib/my\033[0m"


mkdir testing/lib/my/folder
touch testing/lib/my/folder/good_lib_file.c

sleep 3

python3 ./ci/tests/find_file.py "./testing/lib/my/" "SRC\t=" "folder/good_lib_file.c"

if [ $? -ne 0 ]; then
echo -e "When a file with \".c\" extension was created it would be added to Makefile"
exit 84
fi

rm testing/lib/my/folder/good_lib_file.c

echo -e "\033[1;32mTest 7 passed\033[0m"
test_add_wfolder testing/lib/my/folder good_lib_file.c "./testing/lib/my/" "SRC\t=" "folder/good_lib_file.c" 0

exit 0
Loading

0 comments on commit 48dca63

Please sign in to comment.