"""Exercise the deployment overlay with real files, including clone timestamp collisions.""" import os from pathlib import Path import shlex import shutil import subprocess import pytest def test_deployment_copies_same_size_changes_with_identical_timestamps(tmp_path): rsync = shutil.which('rsync') if not rsync: pytest.skip('rsync is required by the deployment runner') source, space = tmp_path/'source', tmp_path/'space' source.mkdir(); space.mkdir() new, old = source/'api.py', space/'api.py' new.write_text('version="1.7.1"\n'); old.write_text('version="1.7.0"\n') for file in (new, old): os.utime(file, (1700000000, 1700000000)) assert new.stat().st_size == old.stat().st_size # Space-only files must survive the overlay. retained = space/'space-only.txt' retained.write_text('keep') workflow = Path(__file__).parents[1]/'.github/workflows/deploy-huggingface.yml' command = next(line.strip() for line in workflow.read_text().splitlines() if line.strip().startswith('rsync ')) arguments = shlex.split(command) subprocess.run([rsync, *arguments[1:-2], str(source)+'/', str(space)+'/'], check=True) assert old.read_bytes() == new.read_bytes() assert retained.read_text() == 'keep'