Debian Codegraph @

testsuite/fuzzy_test.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 # Python rewrite of testsuite/fuzzy.test.
3 #
4 # Test --fuzzy: with a matching-content file already in the destination
5 # under a different name, rsync should use it as a basis for the new name
6 # instead of re-transferring (and --delete-delay still removes the stale
7 # basis file at the end).
8
9 import time
10
11 from rsyncfns import (
12 FROMDIR, SRCDIR, TODIR, cp_p, cp_touch, run_rsync, test_fail, verify_dirs,
13 )
14
15
16 FROMDIR.mkdir(parents=True, exist_ok=True)
17 TODIR.mkdir(parents=True, exist_ok=True)
18
19 cp_p(SRCDIR / 'rsync.c', FROMDIR / 'rsync.c')
20 cp_touch(FROMDIR / 'rsync.c', TODIR / 'rsync2.c')
21 time.sleep(1)
22
23 # Drive rsync directly (rather than checkit) so we can capture --debug=FUZZY:
24 # a final tree match alone would also be produced by a full transfer that
25 # ignored --fuzzy, so assert the generator actually picked rsync2.c as the
26 # fuzzy basis for rsync.c (generator.c find_fuzzy / "fuzzy basis selected").
27 proc = run_rsync('-avvi', '--no-whole-file', '--fuzzy', '--delete-delay',
28 '--debug=FUZZY', f'{FROMDIR}/', f'{TODIR}/',
29 capture_output=True)
30 if 'fuzzy basis selected for rsync.c: rsync2.c' not in proc.stdout:
31 test_fail("--fuzzy did not select rsync2.c as the basis for rsync.c; "
32 f"--debug=FUZZY output was:\n{proc.stdout}")
33 # ...and --delete-delay still removes the stale basis, leaving TODIR == FROMDIR.
34 verify_dirs(FROMDIR, TODIR)