Skip to content

Commit bd6e7ed

Browse files
committed
[FIX] This fixes #47 (checks for the test name in moulitest)
1 parent 0fc7388 commit bd6e7ed

File tree

3 files changed

+10
-33
lines changed

3 files changed

+10
-33
lines changed

42PyChecker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def main():
4141
# @todo Check what option is given based on the selected project.
4242
parser.add_argument("--no-required", help="Disables required functions check", action="store_true")
4343
parser.add_argument("--no-libft-unit-test", help="Disables libft-unit-test", action="store_true")
44-
parser.add_argument("--no-benchmark", help="Disables libft-unit-test benchmarking", action="store_false")
44+
# @todo: Fix --do-benchmark option for libft-unit-test
45+
parser.add_argument("--do-benchmark", help="Disables libft-unit-test benchmarking", action="store_false")
4546

4647
args = parser.parse_args()
4748
if args.show_w:

PyChecker/testing_suite/libft_unit_test.py

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,7 @@
55

66
import platform
77
import subprocess
8-
9-
from chardet.universaldetector import UniversalDetector
10-
11-
detector = UniversalDetector()
12-
13-
14-
def get_encoding_type(current_file):
15-
detector.reset()
16-
for line in open(current_file):
17-
detector.feed(line)
18-
if detector.done: break
19-
detector.close()
20-
return detector.result['encoding']
21-
22-
23-
def convert(file: str, target:str):
24-
import codecs
25-
BLOCKSIZE = 1048576 # or some other, desired size in bytes
26-
with codecs.open(file, "r", get_encoding_type(file)) as sourceFile:
27-
with codecs.open(target, "w+", "utf-8") as targetFile:
28-
while True:
29-
contents = sourceFile.read(BLOCKSIZE)
30-
if not contents:
31-
break
32-
targetFile.write(contents)
8+
import os
339

3410

3511
def run(root_path: str, args):
@@ -47,12 +23,10 @@ def run(root_path: str, args):
4723
print(result)
4824
result = subprocess.run(['make', 'f', '-C', root_path + '/testing_suites/libft-unit-test', 'LIBFTDIR=' + args.path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode('utf-8')
4925
print(result)
50-
convert(root_path + '/testing_suites/libft-unit-test/result.log', root_path + '/result.log')
51-
with open(root_path + '/result.log', 'r') as file2:
52-
data = file2.read()
53-
file.write(data)
26+
file.write(result)
27+
os.rename(root_path + '/testing_suites/libft-unit-test/result.log', root_path + '/.mylibftunittest-results')
5428
if args.do_benchmark:
55-
result = subprocess.run([root_path + '/testing_suite/libft-unit-test/run_test', '-b'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode('utf-8')
29+
result = subprocess.run([root_path + '/testing_suites/libft-unit-test/run_test', '-b'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode('utf-8')
5630
print(result)
5731
file.write(result)
58-
# @todo return results from benchmark and tests
32+
# @todo return results from benchmark and tests

PyChecker/testing_suite/moulitest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def exclude_libft_bonuses(root_path: str):
3232

3333

3434
def execute_test(test_name: str, root_path: str):
35-
# @todo add a protection if test_name isn't compatible with the current project and if not in list of available test for moulitest
35+
available_tests = ['libft_part1', 'libft_part2', 'libft_bonus', 'get_next_line', 'gnl', 'ft_ls', 'ft_printf']
36+
if test_name not in available_tests:
37+
raise ValueError("Given test not in moulitest available tests.")
3638
with open(root_path + "/.mymoulitest", 'w+') as file:
3739
file.write("*------------------------------------------------------*\n")
3840
file.write("MOULITEST\n")

0 commit comments

Comments
 (0)