diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-12-10 18:50:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-10 18:50:10 (GMT) |
commit | 95f5c8c46c16b53c664d9d86eca2682e31167825 (patch) | |
tree | 5036ff581bc4bd718448f9a7523a03bc67c8187f | |
parent | 4cc9e875c2fa6be1759656db4558305e9bb9cb8d (diff) | |
download | cpython-95f5c8c46c16b53c664d9d86eca2682e31167825.zip cpython-95f5c8c46c16b53c664d9d86eca2682e31167825.tar.gz cpython-95f5c8c46c16b53c664d9d86eca2682e31167825.tar.bz2 |
[3.11] gh-109980: Fix test_tarfile_vs_tar on macOS (GH-112905) (#112928)
gh-109980: Fix test_tarfile_vs_tar on macOS (GH-112905)
On recentish macOS versions the system tar
command includes system metadata (ACLs, extended attributes
and resource forks) in the tar archive, which
shutil.make_archive will not do. This can cause
spurious test failures.
(cherry picked from commit dd2ebdf89ff144e89db180bd552c50615f712cb2)
Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
-rw-r--r-- | Lib/test/test_shutil.py | 11 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Tests/2023-12-09-21-27-46.gh-issue-109980.y--500.rst | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index 0879e7f..3d68be1 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1446,6 +1446,17 @@ class TestArchives(BaseTest, unittest.TestCase): # now create another tarball using `tar` tarball2 = os.path.join(root_dir, 'archive2.tar') tar_cmd = ['tar', '-cf', 'archive2.tar', base_dir] + if sys.platform == 'darwin': + # macOS tar can include extended attributes, + # ACLs and other mac specific metadata into the + # archive (an recentish version of the OS). + # + # This feature can be disabled with the + # '--no-mac-metadata' option on macOS 11 or + # later. + import platform + if int(platform.mac_ver()[0].split('.')[0]) >= 11: + tar_cmd.insert(1, '--no-mac-metadata') subprocess.check_call(tar_cmd, cwd=root_dir, stdout=subprocess.DEVNULL) diff --git a/Misc/NEWS.d/next/Tests/2023-12-09-21-27-46.gh-issue-109980.y--500.rst b/Misc/NEWS.d/next/Tests/2023-12-09-21-27-46.gh-issue-109980.y--500.rst new file mode 100644 index 0000000..c475a33 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2023-12-09-21-27-46.gh-issue-109980.y--500.rst @@ -0,0 +1,2 @@ +Fix ``test_tarfile_vs_tar`` in ``test_shutil`` for macOS, where system tar +can include more information in the archive than :mod:`shutil.make_archive`. |