Debian Codegraph @

testsuite/dirs_test.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 """Coverage of -d / --dirs: transfer directories without recursing into them.
3
4 -d copies the entries directly named (or directly inside a trailing-slash
5 source): regular files at the top level are copied, and a top-level directory
6 is created as an empty directory -- its contents are NOT transferred. Verify
7 that on a tree that is several levels deep, only the top layer materialises.
8 """
9
10 from rsyncfns import (
11 FROMDIR, TODIR,
12 assert_same, make_tree, rmtree, run_rsync, test_fail,
13 )
14
15 src = FROMDIR
16 rmtree(src)
17 rmtree(TODIR)
18 make_tree(src, depth=3) # f0 at root; d1/{f1, d2/{f2, d3/f3}}
19
20 run_rsync('-d', f'{src}/', f'{TODIR}/')
21
22 # The top-level file is copied.
23 assert_same(TODIR / 'f0', src / 'f0', label='-d top-level file')
24 # The top-level directory is created...
25 if not (TODIR / 'd1').is_dir():
26 test_fail("-d did not create the top-level directory")
27 # ...but NOT recursed into.
28 if (TODIR / 'd1' / 'f1').exists():
29 test_fail("-d recursed into a directory (f1 should not exist)")
30 if list((TODIR / 'd1').iterdir()):
31 test_fail("-d populated the directory; it should be empty")
32
33 print("dirs: -d copies the top layer without recursing")