Skip to content

Commit

Permalink
[cmd] Get failed files with "CodeChecker cmd runs"
Browse files Browse the repository at this point in the history
CodeChecker cmd runs is added `--details` flag which extends JSON
output with the list of files that are failed to analyze.
  • Loading branch information
bruntib committed May 6, 2022
1 parent 0e87e35 commit 5b1e318
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/web/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,9 @@ optional arguments:
you have run_1_a_name, run_2_b_name, run_2_c_name,
run_3_d_name then "run_2* run_3_d_name" shows the last
three runs.
--details Adds extra details to the run information in JSON
format, such as the list of files that are failed to
analyze.
--all-before-run RUN_NAME
Get all runs that were stored to the server BEFORE the
specified one.
Expand Down
8 changes: 8 additions & 0 deletions web/client/codechecker_client/cmd/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,14 @@ def __register_runs(parser):
"run_2_c_name, run_3_d_name then \"run_2* "
"run_3_d_name\" shows the last three runs.")

group.add_argument('--details',
default=argparse.SUPPRESS,
action='store_true',
required=False,
help="Adds extra details to the run information in "
"JSON format, such as the list of files that are "
"failed to analyze.")

group.add_argument('--all-before-run',
type=str,
dest="all_before_run",
Expand Down
3 changes: 3 additions & 0 deletions web/client/codechecker_client/cmd_line_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,9 @@ def handle_list_runs(args):
# to a json format.
results = []
for run in runs:
if 'details' in args and args.details:
run.analyzerStatistics = \
client.getAnalysisStatistics(run.runId, None)
results.append({run.name: run})
print(CmdLineOutputEncoder().encode(results))

Expand Down
4 changes: 4 additions & 0 deletions web/client/codechecker_client/helpers/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ def allowsStoringAnalysisStatistics(self):
def getAnalysisStatisticsLimits(self):
pass

@ThriftClientCall
def getAnalysisStatistics(self, run_id, run_history_id):
pass

@ThriftClientCall
def storeAnalysisStatistics(self, run_name, zip_file):
pass
2 changes: 1 addition & 1 deletion web/server/codechecker_server/api/report_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3107,7 +3107,7 @@ def getAnalysisStatistics(self, run_id, run_history_id):

for stat, run_id in query:
failed_files = zlib.decompress(stat.failed_files).decode(
'utf-8').split('\n') if stat.failed_files else None
'utf-8').split('\n') if stat.failed_files else []
analyzer_version = zlib.decompress(
stat.version).decode('utf-8') if stat.version else None

Expand Down
27 changes: 27 additions & 0 deletions web/tests/functional/cmdline/test_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,33 @@ def test_runs_filter(self):
self.assertEqual(0, ret)
self.assertEqual(1, len(json.loads(res)))

def test_runs_analysis_statistics(self):
""" Test analysis statistics in detailed mode. """

env = self._test_config['codechecker_cfg']['check_env']

res_cmd = [self._codechecker_cmd, 'cmd', 'runs',
'-o', 'json', '--url', str(self.server_url)]
ret, res, _ = run_cmd(res_cmd, env=env)

self.assertEqual(0, ret)
for run in json.loads(res):
for data in run.values():
self.assertIsNone(
data['analyzerStatistics']['clangsa']['failedFilePaths'])

res_cmd = [self._codechecker_cmd, 'cmd', 'runs',
'-o', 'json', '--url', str(self.server_url),
'--details']
ret, res, _ = run_cmd(res_cmd, env=env)

self.assertEqual(0, ret)
for run in json.loads(res):
for data in run.values():
self.assertEqual(
data['analyzerStatistics']['clangsa']['failedFilePaths'],
[])

def test_proxy_settings(self):
""" Test proxy settings validation. """
server_url = f"{self.codechecker_cfg['viewer_host']}:" \
Expand Down

0 comments on commit 5b1e318

Please sign in to comment.