Skip to content

Commit 5b0da9f

Browse files
committed
[FEATURE] Added fillit and fillit_checker !
1 parent 74ce4bb commit 5b0da9f

File tree

6 files changed

+74
-8
lines changed

6 files changed

+74
-8
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010
[submodule "libft-unit-test"]
1111
path = testing_suites/libft-unit-test
1212
url = https://github.com/alelievr/libft-unit-test.git
13+
[submodule "fillit_checker"]
14+
path = testing_suites/fillit_checker
15+
url = https://github.com/anisg/fillit_checker.git

42PyChecker.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import argparse
77
import platform
8-
from PyChecker.projects import libft, ft_commandements, other
8+
from PyChecker.projects import libft, ft_commandements, other, fillit
99

1010

1111
def print_header():
@@ -35,7 +35,7 @@ def main():
3535
action="store_true")
3636
parser.add_argument("--no-gui", help="disables the Graphical User Interface",
3737
action="store_true")
38-
parser.add_argument("--project", help="Specifies the type of project you want to check", choices=['libft', '42commandements', 'other'], default=None)
38+
parser.add_argument("--project", help="Specifies the type of project you want to check", choices=['libft', '42commandements', 'other', 'fillit'], default=None)
3939
parser.add_argument("--no-libftest", help="Disables Libftest", action="store_true")
4040
parser.add_argument("--no-maintest", help="Disables Maintest", action="store_true")
4141
parser.add_argument("--no-moulitest", help="Disables Moulitest", action="store_true")
@@ -52,8 +52,8 @@ def main():
5252
# @todo: Check what option is given based on the selected project.
5353
parser.add_argument("--no-required", help="Disables required functions check", action="store_true")
5454
parser.add_argument("--no-libft-unit-test", help="Disables libft-unit-test", action="store_true")
55-
parser.add_argument("--do-benchmark", help="Disables libft-unit-test benchmarking", action="store_true")
56-
55+
parser.add_argument("--do-benchmark", help="Enables libft-unit-test benchmarking", action="store_true")
56+
parser.add_argument("--no-fillit-checker", help="Disables fillit_checker", action="store_true")
5757

5858
# Calls the parser for the arguments we asked to implement.
5959
args = parser.parse_args()
@@ -116,6 +116,8 @@ def main():
116116
# @todo: Handle options for other: No option can be passed (like --no-norm)
117117
if args.project == "other":
118118
other.check(root_path, args)
119+
if args.project == "fillit":
120+
fillit.check(root_path, args)
119121

120122

121123
if __name__ == '__main__':

PyChecker/projects/fillit.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
Copyright (C) 2018 Jules Lasne <jules.lasne@gmail.com>
3+
See full notice in `LICENSE'
4+
"""
5+
6+
from PyChecker.utils import author, norme, makefile, forbidden_functions
7+
from PyChecker.testing_suite import fillit_checker
8+
9+
def check(root_path: str, args):
10+
11+
authorized_functions = ['exit', 'open', 'close', 'write', 'read', 'malloc',
12+
'free', 'main']
13+
14+
if not args.no_author:
15+
author_results = author.check(args.path)
16+
if not args.no_norm:
17+
norm_results = norme.check(args.path, root_path)
18+
if not args.no_makefile:
19+
makefile_results = makefile.check(args.path, root_path)
20+
if not args.no_forbidden_functions:
21+
forbidden_functions_results = forbidden_functions.check(args.path, authorized_functions, root_path)
22+
# Extern
23+
if not args.no_fillit_checker:
24+
fillit_checker_results = fillit_checker.run(root_path, args.path)
25+
26+
print("\n\n\nThe results are in:\n")
27+
if not args.no_author:
28+
print("Author File: \n" + author_results + '\n')
29+
if not args.no_norm:
30+
print("Norme results: \n" + norm_results + '\n')
31+
if not args.no_makefile:
32+
print("Makefile: \n" + makefile_results + '\n')
33+
if not args.no_forbidden_functions:
34+
print("Forbidden Functions: \n" + forbidden_functions_results)
35+
if not args.no_fillit_checker:
36+
print("Fillit Checker: \n" + fillit_checker_results)
37+
return 0
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
Copyright (C) 2018 Jules Lasne <jules.lasne@gmail.com>
3+
See full notice in `LICENSE'
4+
"""
5+
6+
import subprocess
7+
8+
9+
def run(root_path: str, project_path: str):
10+
"""
11+
This function runs the fillit_checker to the given project.
12+
13+
:param project_path: The path of the project you want to test.
14+
"""
15+
print("*---------------------------------------------------------------*")
16+
print("*-------------------------fillit_checker------------------------*")
17+
print("*---------------------------------------------------------------*")
18+
19+
# @todo: Find a way to supress colors from output
20+
result = subprocess.run(['bash', root_path + "/testing_suites/fillit_checker/test.sh", project_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode('utf-8')
21+
print(result)
22+
with open(root_path + '/.myfillitchecker', 'w+') as file:
23+
file.write(result)
24+
with open(root_path + '/.myfillitchecker', 'r') as file:
25+
for line in file:
26+
if "NOTE" in line:
27+
return line

PyChecker/testing_suite/libftest.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
import os
77
import subprocess
88

9-
from tempfile import mkstemp
10-
from shutil import move
11-
from os import fdopen, remove
12-
139

1410
def replace_my_config(root_path: str, project_path: str):
1511
with open(root_path + "/testing_suites/libftest/my_config.sh", 'w+') as file:

testing_suites/fillit_checker

Submodule fillit_checker added at c8bae4d

0 commit comments

Comments
 (0)