mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-08-01 00:06:28 -04:00
Replace the entire shell-based testsuite with Python. runtests.py
already drove the suite (it had replaced runtests.sh earlier); this
converts all 60 test scripts from *.test shell to *_test.py and adds
testsuite/rsyncfns.py as the shared helper module -- the Python
counterpart of the now-removed rsync.fns.
runtests.py:
* Discovers and runs both *.test and *_test.py; dispatches the
Python tests via the same python3 that runs the harness.
* Extends PYTHONPATH so tests can `import rsyncfns`.
testsuite/rsyncfns.py provides everything the ports need:
* environment wiring (scratchdir / srcdir / TOOLDIR / RSYNC /
TLS_ARGS, and HOME pointed at the per-test scratch dir);
* result reporting -- test_fail / test_skipped / test_xfail mapping
to the 0 / 1 / 77 / 78 exit-code convention;
* the transfer-and-verify helpers checkit, checkdiff, verify_dirs,
rsync_ls_lR, check_perms and the v_filt output filter;
* fixture builders hands_setup, build_symlinks, build_rsyncd_conf,
make_data_file, cp_p / cp_touch, makepath / rmtree.
All 60 tests are converted, including the four split-variant tests
that share one source via a Makefile-built symlink (chown/chown-fake,
devices/devices-fake, xattrs/xattrs-hlink, exclude/exclude-lsh);
Makefile.in's CHECK_SYMLINKS now points at the *_test.py names.
The dead rsync.fns shell library is removed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
# Python rewrite of testsuite/files-from.test.
|
|
#
|
|
# Verify that --files-from=LIST drives rsync correctly both for a plain
|
|
# local sync and across the lsh.sh "remote shell" with each of the four
|
|
# files-host / src-host / dest-host placement combinations.
|
|
|
|
from rsyncfns import (
|
|
CHKDIR, FROMDIR, RSYNC, SCRATCHDIR, SRCDIR, TODIR,
|
|
checkit, hands_setup, rmtree, run_rsync,
|
|
)
|
|
|
|
|
|
SSH = str(SRCDIR / 'support' / 'lsh.sh')
|
|
|
|
hands_setup()
|
|
|
|
# Files-from list: skip the contents of subsubdir but include subsubdir2/
|
|
# in full (the trailing slash on subsubdir2/ is what flips it).
|
|
filelist = SCRATCHDIR / 'filelist'
|
|
filelist.write_text(
|
|
"from/./\n"
|
|
"from/./dir/subdir\n"
|
|
"from/./dir/subdir/subsubdir\n"
|
|
"from/./dir/subdir/subsubdir2/\n"
|
|
"from/./dir/subdir/foobar.baz\n"
|
|
)
|
|
|
|
# chkdir is what we expect the transfer to produce: source minus
|
|
# dir/text and minus everything under subsubdir/.
|
|
run_rsync('-a', '--exclude=dir/text', '--exclude=subsubdir/**',
|
|
f'{FROMDIR}/', f'{CHKDIR}/')
|
|
|
|
# Local case.
|
|
checkit(['-av', f'--files-from={filelist}', str(SCRATCHDIR), f'{TODIR}/'],
|
|
CHKDIR, TODIR)
|
|
|
|
# All four combinations of files-host / source-host / dest-host across the
|
|
# lsh.sh "remote shell". In each loop iteration exactly one of source or
|
|
# dest is remote (matches the original test's branch logic).
|
|
for filehost in ('', 'localhost:'):
|
|
for srchost in ('', 'localhost:'):
|
|
desthost = 'localhost:' if not srchost else ''
|
|
|
|
rmtree(TODIR)
|
|
checkit(
|
|
['-avse', SSH, f'--rsync-path={RSYNC}',
|
|
f'--files-from={filehost}{filelist}',
|
|
f'{srchost}{SCRATCHDIR}', f'{desthost}{TODIR}/'],
|
|
CHKDIR, TODIR,
|
|
)
|