|
4 | 4 | import subprocess |
5 | 5 | import re |
6 | 6 |
|
| 7 | + |
7 | 8 | def check_author_file(project_path: str): |
8 | 9 | """ |
9 | 10 | :param project_path: The path of the project where you want to check the author file |
@@ -221,6 +222,23 @@ def check_forbidden_functions(project_path: str, binary: str): |
221 | 222 | return 0 |
222 | 223 |
|
223 | 224 |
|
| 225 | +def run_libftest(project_path: str): |
| 226 | + try: |
| 227 | + open("libftest/my_config.sh", 'r') |
| 228 | + except FileNotFoundError: |
| 229 | + subprocess.run(['bash', "libftest/grademe.sh"]) |
| 230 | + with open('libftest/my_config.sh', 'r') as file: |
| 231 | + filedata = file.read() |
| 232 | + filedata = filedata.replace('PATH_LIBFT=~/libft', "PATH_LIBFT=" + project_path) |
| 233 | + filedata = filedata.replace('PATH_DEEPTHOUGHT=${PATH_TEST}', "PATH_DEEPTHOUGHT=" + os.path.dirname(os.path.realpath(__file__))) |
| 234 | + with open('libftest/my_config.sh', 'w') as file: |
| 235 | + file.write(filedata) |
| 236 | + # @todo Parse libftest output for UI and parse score for display and return values. |
| 237 | + subprocess.run(['bash', "libftest/grademe.sh", "-s -f -n -u"]) |
| 238 | + os.rename("deepthought", ".mylibftest") |
| 239 | + return 0 |
| 240 | + |
| 241 | + |
224 | 242 | def check_libft(project_path: str): |
225 | 243 | required_functions = ['libft.h', 'ft_strcat.c', 'ft_strncat.c', |
226 | 244 | 'ft_strlcat.c', 'ft_strchr.c', 'ft_strnstr.c', |
@@ -265,10 +283,11 @@ def check_libft(project_path: str): |
265 | 283 | file.write(result) |
266 | 284 | check_makefile(project_path, "libft.a") |
267 | 285 | check_forbidden_functions(project_path, "libft.a") |
| 286 | + run_libftest(project_path) |
268 | 287 | #moulitest |
269 | 288 | #libft-unit-test |
270 | 289 | #maintest |
271 | 290 | return 0 |
272 | 291 |
|
273 | 292 |
|
274 | | -sys.exit(check_forbidden_functions("/tmp/libft", "libft.a")) |
| 293 | +sys.exit(check_libft("/tmp/libft")) |
0 commit comments