mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-07-30 23:36:21 -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>
50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
# Python rewrite of testsuite/wildmatch.test.
|
|
#
|
|
# Exercise the wildmatch() function (with no options) and wildmatch_join()
|
|
# (via -x and/or -e) by running the wildtest helper across a variety of
|
|
# option combinations and confirming each reports no errors.
|
|
|
|
import subprocess
|
|
|
|
from rsyncfns import SRCDIR, TOOLDIR, test_fail
|
|
|
|
|
|
OPTION_SETS = [
|
|
[],
|
|
['-x1'],
|
|
['-x1', '-e1'],
|
|
['-x1', '-e1se'],
|
|
['-x2'],
|
|
['-x2', '-ese'],
|
|
['-x3'],
|
|
['-x3', '-e1'],
|
|
['-x4'],
|
|
['-x4', '-e2e'],
|
|
['-x5'],
|
|
['-x5', '-es'],
|
|
]
|
|
|
|
EXPECTED = "No wildmatch errors found.\n"
|
|
|
|
wildtest = str(TOOLDIR / 'wildtest')
|
|
wildtest_txt = str(SRCDIR / 'wildtest.txt')
|
|
|
|
for opts in OPTION_SETS:
|
|
print(f"Running wildtest with {' '.join(opts)}")
|
|
proc = subprocess.run(
|
|
[wildtest, *opts, wildtest_txt],
|
|
capture_output=True, text=True,
|
|
)
|
|
if proc.returncode != 0:
|
|
test_fail(
|
|
f"wildtest {' '.join(opts)} exited {proc.returncode}\n"
|
|
f"stderr:\n{proc.stderr}\nstdout:\n{proc.stdout}"
|
|
)
|
|
if proc.stdout != EXPECTED:
|
|
test_fail(
|
|
f"wildtest {' '.join(opts)} output did not match expected.\n"
|
|
f"--- expected ---\n{EXPECTED}"
|
|
f"--- got ---\n{proc.stdout}"
|
|
)
|