Skip to content

Commit

Permalink
TST: fix test to work correctly outside git work directory
Browse files Browse the repository at this point in the history
Fixes #695.
  • Loading branch information
dnicolodi committed Oct 23, 2024
1 parent f497dc0 commit 4f5c136
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tests/test_sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,13 @@ def test_long_path(sdist_long_path):


def test_reproducible(package_pure, tmp_path):
t1 = time.time()
sdist_path_a = mesonpy.build_sdist(tmp_path / 'a')
t2 = time.time()
# Ensure that the two sdists are build at least one second apart.
time.sleep(max(t1 + 1.0 - t2, 0.0))
sdist_path_b = mesonpy.build_sdist(tmp_path / 'b')
with in_git_repo_context():
t1 = time.time()
sdist_path_a = mesonpy.build_sdist(tmp_path / 'a')
t2 = time.time()
# Ensure that the two sdists are build at least one second apart.
time.sleep(max(t1 + 1.0 - t2, 0.0))
sdist_path_b = mesonpy.build_sdist(tmp_path / 'b')

assert sdist_path_a == sdist_path_b
assert tmp_path.joinpath('a', sdist_path_a).read_bytes() == tmp_path.joinpath('b', sdist_path_b).read_bytes()

0 comments on commit 4f5c136

Please sign in to comment.