Debian Codegraph @

testsuite/files-from_test.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 # Python rewrite of testsuite/files-from.test.
3 #
4 # Verify that --files-from=LIST drives rsync correctly both for a plain
5 # local sync and across the lsh.sh "remote shell" with each of the four
6 # files-host / src-host / dest-host placement combinations.
7
8 from rsyncfns import (
9 CHKDIR, FROMDIR, RSYNC, RSYNC_PEER, SCRATCHDIR, SRCDIR, TODIR,
10 checkit, hands_setup, rmtree, run_rsync, rsync_path_arg, rsh_cmd,
11 )
12
13
14 SSH = rsh_cmd()
15
16 hands_setup()
17
18 # Files-from list: skip the contents of subsubdir but include subsubdir2/
19 # in full (the trailing slash on subsubdir2/ is what flips it).
20 filelist = SCRATCHDIR / 'filelist'
21 filelist.write_text(
22 "from/./\n"
23 "from/./dir/subdir\n"
24 "from/./dir/subdir/subsubdir\n"
25 "from/./dir/subdir/subsubdir2/\n"
26 "from/./dir/subdir/foobar.baz\n"
27 )
28
29 # chkdir is what we expect the transfer to produce: source minus
30 # dir/text and minus everything under subsubdir/.
31 run_rsync('-a', '--exclude=dir/text', '--exclude=subsubdir/**',
32 f'{FROMDIR}/', f'{CHKDIR}/')
33
34 # Local case.
35 checkit(['-av', f'--files-from={filelist}', str(SCRATCHDIR), f'{TODIR}/'],
36 CHKDIR, TODIR)
37
38 # All four combinations of files-host / source-host / dest-host across the
39 # lsh.sh "remote shell". In each loop iteration exactly one of source or
40 # dest is remote (matches the original test's branch logic).
41 for filehost in ('', 'localhost:'):
42 for srchost in ('', 'localhost:'):
43 desthost = 'localhost:' if not srchost else ''
44
45 rmtree(TODIR)
46 checkit(
47 ['-avse', SSH, f'--rsync-path={rsync_path_arg()}',
48 f'--files-from={filehost}{filelist}',
49 f'{srchost}{SCRATCHDIR}', f'{desthost}{TODIR}/'],
50 CHKDIR, TODIR,
51 )