mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-06-08 06:05:57 -04:00
The Python rewrite of the suite carried over the shell habit of populating the test tree by capturing "ls -l /etc" / "ls -l /bin" (falling back to "ls /"): hands_setup() built etc-ltr-list / bin-lt-list that way, and longdir_test.py did the same for its leaf files. That ties the fixtures to the host filesystem layout -- those directories are absent or unreadable on Android/Termux and other minimal environments, where "ls /" fails outright -- and the captured content was never reproducible from run to run. Add a deterministic make_text_file() helper to rsyncfns.py and use it for hands_setup()'s two fixture files and longdir's leaf files. The names etc-ltr-list / bin-lt-list are unchanged (chmod, chmod-temp-dir and alt-dest reference them by name); only the content source changes, so the fixtures are now self-contained and identical on every platform. This also drops longdir_test.py's date(1) and ls(1) subprocess calls. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
# Python rewrite of testsuite/longdir.test.
|
|
#
|
|
# Regression test for a 2.0.11 bug: rsync used to mishandle paths nested
|
|
# inside a stupidly-long directory name. We build a three-deep nest of
|
|
# 175-char directory names, drop a couple of files in the leaf, and
|
|
# verify that --delete -avH still produces an identical destination.
|
|
|
|
from rsyncfns import (FROMDIR, TODIR, checkit, hands_setup, make_text_file,
|
|
test_skipped)
|
|
|
|
|
|
hands_setup()
|
|
|
|
longname = ('This-is-a-directory-with-a-stupidly-long-name-created-in-an-'
|
|
'attempt-to-provoke-an-error-found-in-2.0.11-that-should-'
|
|
'hopefully-never-appear-again-if-this-test-does-its-job')
|
|
longdir = FROMDIR / longname / longname / longname
|
|
|
|
try:
|
|
longdir.mkdir(parents=True)
|
|
except OSError:
|
|
test_skipped("unable to create long directory")
|
|
|
|
try:
|
|
(longdir / '1').touch()
|
|
except OSError:
|
|
test_skipped("unable to create files in long directory")
|
|
|
|
# Drop predictable, self-contained content into the two leaf files.
|
|
make_text_file(longdir / '1', 50)
|
|
make_text_file(longdir / '2', 100)
|
|
|
|
checkit(['--delete', '-avH', f'{FROMDIR}/', str(TODIR)], FROMDIR, TODIR)
|