55
66import platform
77import 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
3511def 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
0 commit comments