Skip to content

Commit 3ec209a

Browse files
committed
test: do pre-PR A/B-test checkout into temporary directory
Otherwise, they clash with the directories used for the pre-compiled binaries (as the `build`-subdirectories now no longer contain checked out repositories, but instead only binaries). Since each pipeline only uses git_ab_test in precisely one test, loosing the re-use is not a big deal. Signed-off-by: Patrick Roy <[email protected]>
1 parent be6ec85 commit 3ec209a

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

tests/framework/ab_test.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import os
2525
import statistics
2626
from pathlib import Path
27+
from tempfile import TemporaryDirectory
2728
from typing import Callable, List, Optional, TypeVar
2829

2930
import scipy
@@ -82,19 +83,20 @@ def git_ab_test(
8283
(alternatively, your comparator can perform any required assertions and not return anything).
8384
"""
8485

85-
dir_a = git_clone(Path("../build") / a_revision, a_revision)
86-
result_a = test_runner(dir_a, True)
86+
with TemporaryDirectory() as tmp_dir:
87+
dir_a = git_clone(Path(tmp_dir) / a_revision, a_revision)
88+
result_a = test_runner(dir_a, True)
8789

88-
if b_revision:
89-
dir_b = git_clone(Path("../build") / b_revision, b_revision)
90-
else:
91-
# By default, pytest execution happens inside the `tests` subdirectory. Pass the repository root, as
92-
# documented.
93-
dir_b = Path.cwd().parent
94-
result_b = test_runner(dir_b, False)
90+
if b_revision:
91+
dir_b = git_clone(Path(tmp_dir) / b_revision, b_revision)
92+
else:
93+
# By default, pytest execution happens inside the `tests` subdirectory. Pass the repository root, as
94+
# documented.
95+
dir_b = Path.cwd().parent
96+
result_b = test_runner(dir_b, False)
9597

96-
comparison = comparator(result_a, result_b)
97-
return result_a, result_b, comparison
98+
comparison = comparator(result_a, result_b)
99+
return result_a, result_b, comparison
98100

99101

100102
DEFAULT_A_DIRECTORY = FC_WORKSPACE_DIR / "build" / "main"
@@ -266,8 +268,6 @@ def git_clone(clone_path, commitish):
266268
utils.check_output(f"git branch {branch_name} {commitish}")
267269
_, git_root, _ = utils.run_cmd("git rev-parse --show-toplevel")
268270
# split off the '\n' at the end of the stdout
269-
utils.check_output(
270-
f"git clone -b {branch_name} {git_root.strip()} {clone_path}"
271-
)
271+
utils.check_output(f"git clone -b {branch_name} {git_root.strip()} {clone_path}")
272272
utils.check_output(f"git branch -D {branch_name}")
273273
return clone_path

0 commit comments

Comments
 (0)