Skip to content

Commit 6bd5694

Browse files
committed
Add integration test for "thin pack" reference handling
The `github.com/go-git/go-git/v5@v5.4.2` dependency used by this project to work with the Git repositories of the libraries is not able to correctly handle specific types of references in Git "thin packs", causing a spurious failure of the sync process for the affected libraries: Error fetching repository: reference delta not found This test is intended to check whether the project is able to correctly handle these libraries. I have simply used the two libraries from the report as test data. I am not confident they will continue to serve as effective test data indefinitely, but also don't know how to do the generation of test data that would serve as a reliable replacement for them, and noticed that those working on the `github.com/go-git/go-git` bug also did not find an easy way to do it.
1 parent 4999750 commit 6bd5694

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

tests/test_sync.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,35 @@ def test_clean_checkout(configuration, run_command):
276276
for release in library_index["libraries"]:
277277
# ssd1306@1.0.0 contains a .exe and so should fail validation.
278278
assert not (release["name"] == "ssd1306" and release["version"] == "1.0.0")
279+
280+
281+
# A Git "thin pack" may reference objects outside the pack.
282+
def test_thin_pack(configuration, run_command):
283+
libraries_repository_engine_command = [
284+
"sync",
285+
"--config-file",
286+
configuration.path,
287+
test_data_path.joinpath("test_thin_pack", "repos.txt"),
288+
]
289+
290+
# Run the engine
291+
result = run_command(cmd=libraries_repository_engine_command)
292+
assert result.ok
293+
294+
# Load generated index
295+
with pathlib.Path(configuration.data["LibrariesIndex"]).open(mode="r", encoding="utf-8") as library_index_file:
296+
library_index = json.load(fp=library_index_file)
297+
298+
def index_has_release(library_name, version):
299+
for release in library_index["libraries"]:
300+
if release["name"] == library_name and release["version"] == version:
301+
return True
302+
303+
return False
304+
305+
# These libraries had repositories that were not compatible with the "thin pack" handling code of
306+
# `github.com/go-git/go-git/v5@v5.4.2` (https://github.com/arduino/libraries-repository-engine/issues/109).
307+
# I am not confident they will continue to serve as effective test data indefinitely, but also don't know how to
308+
# do the generation of test data that would serve as a reliable replacement for them.
309+
assert index_has_release(library_name="RAKwireless LED Matrix", version="1.0.0")
310+
assert index_has_release(library_name="RAKwireless-RAK12021-TCS37725", version="1.0.0")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
https://github.com/RAKWireless/RAK14012-LED-Matrix.git|Contributed|RAKwireless LED Matrix
2+
https://github.com/RAKWireless/RAK12021-TCS37725.git|Contributed|RAKwireless-RAK12021-TCS37725

0 commit comments

Comments
 (0)