From 64892484ad96dc56304c256396a7aa40b652390c Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 19 Sep 2026 21:22:30 +0200 Subject: [PATCH] benchmark tests: extract into an empty directory, fixes #10057 regression test_extract ran "borg extract" with the cwd set to the tmpdir that the repo_url fixture also uses for the repository, the keys dir and the cache dir. That directory is therefore never empty, so since extract refuses to extract into a non-empty directory (see #10057), all 8 parametrisations failed with rc 33 (ExtractionDirNotEmpty) already on the first (and, with the pedantic defaults rounds=1/iterations=1/warmup_rounds=0, only) call. Extract into a dedicated, per-round empty subdirectory created by pedantic's setup hook, which is not timed. Using --continue instead would keep the test green, but it makes extract stat and compare the files that are already there, which is not the extract that this benchmark is supposed to measure. The per-round directory also keeps the benchmark correct if rounds or warmup_rounds are ever raised above the defaults. The other benchmark tests are not affected: they do not write into the cwd. Co-Authored-By: Claude Opus 5 --- src/borg/testsuite/benchmark_test.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/borg/testsuite/benchmark_test.py b/src/borg/testsuite/benchmark_test.py index 2be77f6e82..7f1e7cca49 100644 --- a/src/borg/testsuite/benchmark_test.py +++ b/src/borg/testsuite/benchmark_test.py @@ -6,6 +6,7 @@ py.test --benchmark-only """ +import itertools import os import pytest @@ -81,8 +82,14 @@ def test_create_lz4(benchmark, cmd_fixture, repo, testdata): def test_extract(benchmark, cmd_fixture, repo_archive, tmpdir): repo, archive = repo_archive + counter = itertools.count() + + def setup(): + # extract refuses a non-empty directory, so give each round a fresh empty one, see #10057 + os.chdir(str(tmpdir.mkdir(f"extract{next(counter)}"))) + with changedir(str(tmpdir)): - result, out = benchmark.pedantic(cmd_fixture, (f"--repo={repo}", "extract", archive)) + result, out = benchmark.pedantic(cmd_fixture, (f"--repo={repo}", "extract", archive), setup=setup) assert result == 0