Skip to content
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
1 change: 1 addition & 0 deletions infra/base-images/base-builder/indexer/clang_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ def load_cdbs(directory: Path) -> Iterator[tuple[Path, dict[str, Any]]]:
if output_path in existing_output_files:
# Remove existing entry for the output file.
os.unlink(existing_output_files[output_path])
del existing_output_files[output_path]

shutil.copy2(file, merged_cdb_path / file.name)

Expand Down
32 changes: 32 additions & 0 deletions infra/base-images/base-builder/indexer/clang_wrapper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,38 @@ def test_merge_incremental_cdb(self):
],
)

def test_merge_incremental_cdb_duplicate_outputs(self):
"""Tests that incremental cdb is merged correctly with duplicate outputs."""
cdb_path = pathlib.Path(self.create_tempdir().full_path)
merged_cdb_path = pathlib.Path(self.create_tempdir().full_path)

fragment1 = {
"directory": "/build",
"file": "test.c",
"output": "test.o",
}
(merged_cdb_path / "1.json").write_text(json.dumps(fragment1) + ",\n")

fragment2 = {
"directory": "/build",
"file": "test.c",
"output": "test.o",
}
(cdb_path / "2.json").write_text(json.dumps(fragment2) + ",\n")
(cdb_path / "3.json").write_text(json.dumps(fragment2) + ",\n")

clang_wrapper.merge_incremental_cdb(cdb_path, merged_cdb_path)

self.assertCountEqual(
merged_cdb_path.iterdir(),
[
merged_cdb_path / ".lock",
merged_cdb_path / "2.json",
merged_cdb_path / "3.json",
],
)
self.assertFalse((merged_cdb_path / "1.json").exists())


if __name__ == "__main__":
unittest.main()
Loading