Debian Codegraph @

testsuite/delay-updates_test.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 # Python rewrite of testsuite/delay-updates.test.
3 #
4 # Exercise --delay-updates: pre-seed the destination's staging directory
5 # with a stale file then re-sync; the final destination must match the
6 # source regardless of what the staging dir already contained.
7
8 import os
9
10 from rsyncfns import FROMDIR, TODIR, checkit
11
12
13 FROMDIR.mkdir(parents=True, exist_ok=True)
14 (FROMDIR / 'foo').write_text("1\n")
15
16 checkit(['-aiv', '--delay-updates', f'{FROMDIR}/', f'{TODIR}/'], FROMDIR, TODIR)
17
18 # Plant a stale "in-progress" update in the staging dir and a mismatched
19 # destination file, then re-sync. --delay-updates should overwrite cleanly.
20 (TODIR / '.~tmp~').mkdir(exist_ok=True)
21 (TODIR / '.~tmp~' / 'foo').write_text("2\n")
22 # Touch both to a fixed time in the past so they look stale and the source's
23 # fresh "3" clearly post-dates them. (A real timestamp, not os.stat('..') --
24 # whose shared parent dir is bumped by concurrent -j tests to ~now -- avoids a
25 # same-second quick-check collision that would skip the update.)
26 stale = 1_000_000_000 # 2001-09-09, well in the past
27 os.utime(TODIR / '.~tmp~' / 'foo', (stale, stale))
28 os.utime(TODIR / 'foo', (stale, stale))
29 (FROMDIR / 'foo').write_text("3\n")
30
31 checkit(['-aiv', '--delay-updates', f'{FROMDIR}/', f'{TODIR}/'], FROMDIR, TODIR)