mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-05-30 17:58:10 -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>
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
# Python rewrite of testsuite/executability.test.
|
|
#
|
|
# Test --executability (-E): -E should propagate only the executable bits
|
|
# from source to destination (other permission changes ignored), while a
|
|
# normal copy without -E should leave the destination permissions alone.
|
|
|
|
import os
|
|
|
|
from rsyncfns import FROMDIR, TODIR, check_perms, run_rsync, test_skipped
|
|
|
|
|
|
FROMDIR.mkdir(parents=True, exist_ok=True)
|
|
(FROMDIR / '1').write_text("#!/bin/sh\necho 'Program One!'\n")
|
|
(FROMDIR / '2').write_text("#!/bin/sh\necho 'Program Two!'\n")
|
|
|
|
# Setuid-and-rwx for owner, nothing else. Some platforms reject 1700 for
|
|
# non-root callers (no permission to set sticky); the shell test treats
|
|
# that case as a skip.
|
|
try:
|
|
os.chmod(FROMDIR / '1', 0o1700)
|
|
except PermissionError:
|
|
test_skipped("Can't chmod")
|
|
os.chmod(FROMDIR / '2', 0o600)
|
|
|
|
run_rsync('-rvv', f'{FROMDIR}/', f'{TODIR}/')
|
|
|
|
check_perms(TODIR / '1', 'rwx------')
|
|
check_perms(TODIR / '2', 'rw-------')
|
|
|
|
# Permute the source/destination perms; without -E nothing should change.
|
|
os.chmod(FROMDIR / '1', 0o600)
|
|
os.chmod(FROMDIR / '2', 0o601)
|
|
os.chmod(TODIR / '2', 0o604)
|
|
|
|
run_rsync('-rvv', f'{FROMDIR}/', f'{TODIR}/')
|
|
|
|
check_perms(TODIR / '1', 'rwx------')
|
|
check_perms(TODIR / '2', 'rw----r--')
|
|
|
|
# Now with -E: 1 loses its x (source has 600), 2 gains x (source has 601).
|
|
run_rsync('-rvvE', f'{FROMDIR}/', f'{TODIR}/')
|
|
|
|
check_perms(TODIR / '1', 'rw-------')
|
|
check_perms(TODIR / '2', 'rwx---r-x')
|