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

[3.11] gh-89792: Prevent test_tools from copying 1000M of "source" in freeze test (GH-101837) #101839

Merged
merged 1 commit into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
``test_tools`` now copies up to 10x less source data to a temporary
directory during the ``freeze`` test by ignoring git metadata and other
artifacts.
14 changes: 13 additions & 1 deletion Tools/freeze/test/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,19 @@ def copy_source_tree(newroot, oldroot):
if newroot == SRCDIR:
raise Exception('this probably isn\'t what you wanted')
shutil.rmtree(newroot)
shutil.copytree(oldroot, newroot)

def ignore_non_src(src, names):
"""Turns what could be a 1000M copy into a 100M copy."""
# Don't copy the ~600M+ of needless git repo metadata.
# source only, ignore cached .pyc files.
subdirs_to_skip = {'.git', '__pycache__'}
if os.path.basename(src) == 'Doc':
# Another potential ~250M+ of non test related data.
subdirs_to_skip.add('build')
subdirs_to_skip.add('venv')
return subdirs_to_skip

shutil.copytree(oldroot, newroot, ignore=ignore_non_src)
if os.path.exists(os.path.join(newroot, 'Makefile')):
_run_quiet([MAKE, 'clean'], newroot)

Expand Down