Skip to content

Commit

Permalink
Merge pull request #3474 from ferkulat/fix_check_for_response_files
Browse files Browse the repository at this point in the history
[analyzer] Fix check for response files
  • Loading branch information
csordasmarton authored Nov 3, 2021
2 parents 4be1eca + 3df3711 commit 902d989
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion analyzer/codechecker_analyzer/buildlog/log_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ def extend_compilation_database_entries(compilation_database):

entry['command'] = ' '.join(cmd)

if '@' in entry['file']:
if entry['file'].startswith('@'):
for source_file in source_files:
new_entry = dict(entry)
new_entry['file'] = source_file
Expand Down
26 changes: 26 additions & 0 deletions analyzer/tests/unit/test_log_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,3 +526,29 @@ def test_response_file_contains_multiple_source_files(self):
if b.source == b_file_path][0]
self.assertEqual(len(b_build_action.analyzer_options), 1)
self.assertEqual(b_build_action.analyzer_options[0], '-DVARIABLE=some')

def test_source_file_contains_at_sign(self):
"""
Test source file which path contains '@' sign in path.
Source file path can contain '@' sign which doesn't mean it is a
response file.
"""
with tempfile.TemporaryDirectory(suffix='@') as tmp_dir:
src_file_path = shutil.copy(self.src_file_path, tmp_dir)

with open(self.compile_command_file_path, "w",
encoding="utf-8", errors="ignore") as f:
f.write(json.dumps([dict(
directory=tmp_dir,
command=f"g++ {src_file_path}",
file=src_file_path
)]))

build_actions, _ = log_parser.parse_unique_log(load_json_or_empty(
self.compile_command_file_path), self.__this_dir)

self.assertEqual(len(build_actions), 1)

build_action = build_actions[0]
self.assertEqual(build_action.source, src_file_path)

0 comments on commit 902d989

Please sign in to comment.