@@ -58,7 +58,6 @@ def __init__(self, selected_mod_names=None, selected_mod_paths=None, loaded_help
5858 self .enable_cli_own = enable_cli_own
5959 self .all_commands = {m : [] for m in self .selected_mod_names }
6060 self .all_tested_commands = {m : [] for m in self .selected_mod_names }
61- self .all_live_commands = []
6261 self .all_untested_commands = {}
6362 self .command_test_coverage = {'Total' : [0 , 0 , 0 ]}
6463 self .date = time .strftime ("%Y-%m-%d %H:%M:%S" , time .localtime ())
@@ -73,8 +72,6 @@ def run(self):
7372 self ._get_all_tested_commands_from_regex ()
7473 self ._get_all_tested_commands_from_record ()
7574 self ._run_command_test_coverage ()
76- self ._get_all_tested_commands_from_live ()
77- self ._run_command_test_coverage_enhance ()
7875 html_file = self ._render_html ()
7976 if self .enable_cli_own :
8077 command_test_coverage = {k : v for k , v in self .command_test_coverage .items () if k in CLI_OWN_MODULES }
@@ -191,10 +188,6 @@ def _get_all_tested_commands_from_record(self):
191188 cmd = command + ' ' + argument
192189 self .all_tested_commands [self .selected_mod_names [idx ]].append (cmd )
193190
194- def _get_all_tested_commands_from_live (self ):
195- with open (os .path .join (self .cmdcov_path , 'tested_command.txt' ), 'r' ) as f :
196- self .all_live_commands = f .readlines ()
197-
198191 def _run_command_test_coverage (self ):
199192 """
200193 all_commands: All commands that need to be test
@@ -247,56 +240,6 @@ def _run_command_test_coverage(self):
247240 logger .warning (self .command_test_coverage )
248241 return self .command_test_coverage
249242
250- def _run_command_test_coverage_enhance (self ):
251- """
252- all_untest_commands: {[module]:[],}
253- all_tested_commands_from_file: []
254- command_test_coverage: {[module: [test, untested, pct]
255- module: vm
256- percentage: xx.xxx%
257- """
258- import ast
259- total_tested = 0
260- total_untested = 0
261- # pylint: disable=too-many-nested-blocks
262- for module , untested_commands in self .all_untested_commands .items ():
263- for cmd_idx , command in enumerate (untested_commands ):
264- exist_flag = False
265- prefix = command .rsplit ('[' , maxsplit = 1 )[0 ]
266- opt_list = ast .literal_eval ('[' + command .rsplit ('[' , maxsplit = 1 )[1 ]) if self .level == 'argument' \
267- else []
268- for cmd in self .all_live_commands :
269- if prefix in cmd :
270- if self .level == 'argument' :
271- for opt in opt_list :
272- if opt in cmd :
273- self .command_test_coverage [module ][0 ] += 1
274- untested_commands .pop (cmd_idx )
275- exist_flag = True
276- if exist_flag :
277- break
278- else :
279- self .command_test_coverage [module ][0 ] += 1
280- untested_commands .pop (cmd_idx )
281- exist_flag = True
282- if exist_flag :
283- break
284- if exist_flag :
285- break
286- try :
287- self .command_test_coverage [module ][1 ] = len (untested_commands )
288- self .command_test_coverage [module ][2 ] = f'''{ self .command_test_coverage [module ][0 ] /
289- (self .command_test_coverage [module ][0 ] +
290- self .command_test_coverage [module ][1 ]):.3%} '''
291- except ZeroDivisionError :
292- self .command_test_coverage [module ] = [0 , 0 , 'N/A' ]
293- total_tested += self .command_test_coverage [module ][0 ] if self .command_test_coverage [module ] else 0
294- total_untested += self .command_test_coverage [module ][1 ] if self .command_test_coverage [module ] else 0
295- self .command_test_coverage ['Total' ][0 ] = total_tested
296- self .command_test_coverage ['Total' ][1 ] = total_untested
297- self .command_test_coverage ['Total' ][2 ] = f'{ total_tested / (total_tested + total_untested ):.3%} '
298- logger .warning (self .command_test_coverage )
299-
300243 def _render_html (self ):
301244 """
302245 :return: Return a HTML string
0 commit comments