Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_shutil cross-file-system tests are fragile (may not test what they purport to test) #54208

Closed
bitdancer opened this issue Sep 30, 2010 · 5 comments
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@bitdancer
Copy link
Member

BPO 9999
Nosy @tarekziade, @merwok, @bitdancer, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2018-12-12.09:25:10.613>
created_at = <Date 2010-09-30.15:29:09.440>
labels = ['type-bug', 'tests']
title = 'test_shutil cross-file-system tests are fragile (may not test what they purport to test)'
updated_at = <Date 2018-12-12.09:25:10.604>
user = 'https://github.com/bitdancer'

bugs.python.org fields:

activity = <Date 2018-12-12.09:25:10.604>
actor = 'serhiy.storchaka'
assignee = 'none'
closed = True
closed_date = <Date 2018-12-12.09:25:10.613>
closer = 'serhiy.storchaka'
components = ['Tests']
creation = <Date 2010-09-30.15:29:09.440>
creator = 'r.david.murray'
dependencies = []
files = []
hgrepos = []
issue_num = 9999
keywords = []
message_count = 5.0
messages = ['117744', '117753', '141965', '221758', '331684']
nosy_count = 6.0
nosy_names = ['tarek', 'eric.araujo', 'r.david.murray', 'BreamoreBoy', 'jniehof', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue9999'
versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

@bitdancer
Copy link
Member Author

In investigating bpo-9993, I noticed that test_shutil wants to test things that require cross-file-system links, and arranges to have such links by creating a files and directories in the cwd and using tempfile. Presumably the hope (and the comments make it clear it is a hope) is that frequently these will be different filesystems. This is likely to be true on some systems (principally those that put /tmp on a memory file system), there is no guarantee that it is true for any system in the buildbot fleet (for example).

In addition, relatively recent changes to regrtest ensure that when the tests are run for an installed Python, the cwd is *guaranteed* to be in the same file system as things created by tempfile, since in that case the tempfile module is used by regrtest to run all tests in a temporary cwd.

It is this latter case that most concerns me and prompts this bug report, since a distribution should be able to reasonably expect that running the tests after installation (either real or sandboxed) should in fact test python on the target system.

Unfortunately I don't currently have a suggestion for how to reliably create a cross-file-system link for testing purposes.

@bitdancer bitdancer added tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Sep 30, 2010
@jniehof
Copy link
Mannequin

jniehof mannequin commented Sep 30, 2010

Might it make sense to skip-decorate those tests which require cross-filesystem? Put a test above the TestMove definition which compares tempfile.gettempdir() and os.path.dirname(file).

I don't know of an out-of-the-box function to see if two paths are on the same filesystem; I suppose one approach would be to walk up the directory tree of each, checking ismount. (Looks like somebody's tried it: http://stackoverflow.com/questions/1138383/python-get-mount-point-on-windows-or-linux)

@merwok merwok changed the title test_shutil cross-file-system tests are fragile (may not test what they pruport to test) test_shutil cross-file-system tests are fragile (may not test what they purport to test) Nov 2, 2010
@merwok
Copy link
Member

merwok commented Aug 12, 2011

Unfortunately I don't currently have a suggestion for how to reliably
create a cross-file-system link for testing purposes.

We could try walking a list of common mount points (/run, /dev, /tmp, /home, etc.), compiled from as many OSes as possible, and filter it with os.path.ismount to see if we have more than one partition.

@BreamoreBoy
Copy link
Mannequin

BreamoreBoy mannequin commented Jun 28, 2014

Would you like to take this forward, or has it already happened but not been documented here?

@serhiy-storchaka
Copy link
Member

Starting from bpo-11560 test_shutil patches os.rename to imitate a failure in cross-file-system move.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants