Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmd] Fix html generation for report directory without plists #3610

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions analyzer/codechecker_analyzer/cmd/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,14 @@ def get_output_file_path(default_file_name: str) -> Optional[str]:
changed_files: Set[str] = set()
processed_path_hashes = set()
processed_file_paths = set()
html_builder: Optional[report_to_html.HtmlBuilder] = None
print_steps = 'print_steps' in args

html_builder: Optional[report_to_html.HtmlBuilder] = None
if export == 'html':
html_builder = report_to_html.HtmlBuilder(
context.path_plist_to_html_dist,
context.checker_labels)

for dir_path, file_paths in report_file.analyzer_result_files(args.input):
metadata = get_metadata(dir_path)
for file_path in file_paths:
Expand Down Expand Up @@ -427,11 +432,6 @@ def get_output_file_path(default_file_name: str) -> Optional[str]:
plaintext.convert(
file_report_map, processed_file_paths, print_steps)
elif export == 'html':
if not html_builder:
html_builder = report_to_html.HtmlBuilder(
context.path_plist_to_html_dist,
context.checker_labels)

print(f"Parsing input file '{file_path}'.")
report_to_html.convert(
file_path, reports, output_dir_path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,25 @@ def test_html_output_for_macros(self):
self.assertTrue('Summary' in out)
self.assertTrue('Statistics' in out)

def test_html_output_for_empty_dir(self):
""" Test parse HTML output for an empty directory. """
with tempfile.TemporaryDirectory() as tmp_dir:
output_path = os.path.join(self.test_workspaces['OUTPUT'], 'html')
extract_cmd = [
'CodeChecker', 'parse',
'-e', 'html',
'-o', output_path,
tmp_dir]

out, err, result = call_command(
extract_cmd, cwd=self.test_dir, env=self.env)
self.assertEqual(result, 0)
self.assertFalse(err)

self.assertTrue('Summary' in out)
self.assertFalse('Html file was generated' in out)
self.assertFalse('Statistics' in out)

def test_codeclimate_export(self):
""" Test exporting codeclimate output. """
test_project_notes = os.path.join(self.test_workspaces['NORMAL'],
Expand Down