Debian Codegraph @

testsuite/cvs-exclude_test.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 """Coverage of -C / --cvs-exclude at depth.
3
4 -C ignores the usual CVS cruft (object files, core, editor backups, VCS dirs,
5 ...) and also honours a per-directory .cvsignore. Verify both the built-in
6 patterns and a deep .cvsignore on a >=3-level tree.
7 """
8
9 from rsyncfns import (
10 FROMDIR, TODIR,
11 assert_exists, assert_not_exists, makepath, rmtree, run_rsync,
12 )
13
14 src = FROMDIR
15 rmtree(src)
16 rmtree(TODIR)
17 makepath(src / 'd1' / 'd2' / 'd3')
18
19 # A real file plus default-CVS-cruft at every level.
20 cur = src
21 for lvl in range(4):
22 (cur / f'real{lvl}.c').write_text('code\n')
23 (cur / f'obj{lvl}.o').write_text('obj\n') # *.o is built-in cruft
24 (cur / f'back{lvl}~').write_text('backup\n') # *~ is built-in cruft
25 cur = cur / f'd{lvl + 1}'
26
27 # A per-directory .cvsignore deep in the tree adds "*.junk" for that subtree.
28 (src / 'd1' / 'd2' / '.cvsignore').write_text('*.junk\n')
29 (src / 'd1' / 'd2' / 'local.junk').write_text('j\n')
30 (src / 'top.junk').write_text('j\n') # not covered by that .cvsignore
31
32 run_rsync('-aC', f'{src}/', f'{TODIR}/')
33
34 cur = TODIR
35 for lvl in range(4):
36 assert_exists(cur / f'real{lvl}.c', label=f'-C kept real L{lvl}')
37 assert_not_exists(cur / f'obj{lvl}.o', label=f'-C dropped *.o L{lvl}')
38 assert_not_exists(cur / f'back{lvl}~', label=f'-C dropped *~ L{lvl}')
39 cur = cur / f'd{lvl + 1}'
40
41 # .cvsignore is scoped to its directory subtree.
42 assert_not_exists(TODIR / 'd1' / 'd2' / 'local.junk',
43 label='-C deep .cvsignore applied')
44 assert_exists(TODIR / 'top.junk', label='-C deep .cvsignore not applied above')
45
46 print("cvs-exclude: built-in patterns + deep .cvsignore honoured at depth")