-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
test_tarfile_vs_tar
of test_shutil
fails on macos Sonoma
#109980
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
Comments
The difference appears to be archiving of extended attributes (given the names starting with "._"). Listing the extended attributes for the source directory could help find what's going on here. I don't get this when running A fresh checkout of main ( All of this on an M1 macbook running Sonoma and using Xcode 15. |
@ronaldoussoren I easily repoduce it on a fresh
|
Does adding Are there extended attributes on the source tree? ( |
The reason for asking to check for extended attributes: tar on macOS will by default archive extended attributes when creating a tar archive (e.g., "--xattr" is on by default for "tar -c"). This can be disabled by adding "--no-xattr" to the command-line, or possibly "--no-mac-metadata" if the problem is in extended ACLs. Those are Mac-specific arguments though, leading to more complicated test code. |
@ronaldoussoren adding the suggested line to 1591: diff --git Lib/test/test_shutil.py Lib/test/test_shutil.py
index a2ca4df1358..dadc4735f7e 100644
--- Lib/test/test_shutil.py
+++ Lib/test/test_shutil.py
@@ -1588,6 +1588,7 @@ def test_tarfile_vs_tar(self):
stdout=subprocess.DEVNULL)
self.assertTrue(os.path.isfile(tarball2))
+ subprocess.check_call(["xattr", "-r", base_dir])
# let's compare both tarballs
self.assertEqual(self._tarinfo(tarball), self._tarinfo(tarball2)) It produces:
|
Just ran into this too. Can one of you come up with a fix? |
Maybe. Is this something you can reproduce? I can reproduce the error with the following patch: diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index d7061b2f9d..b5e4c05d74 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -1660,6 +1660,13 @@ def _create_files(self, base_dir='dist'):
def test_tarfile_vs_tar(self):
root_dir, base_dir = self._create_files()
base_name = os.path.join(self.mkdtemp(), 'archive')
+
+ subprocess.check_call([
+ 'chmod', '+a', "admin allow write,chown,directory_inherit",
+ f"{root_dir}/dist/sub2"])
+
+ subprocess.check_call(["ls", "-@lRre", root_dir])
+
with no_chdir:
tarball = make_archive(base_name, 'gztar', root_dir, base_dir)
Running as If you can reproduce this at will I'm interested in the output of |
And if anyone can reproduce the issue with my patch, the following should fix it: diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index d7061b2f9d..b5e4c05d74 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -1670,9 +1677,13 @@ def test_tarfile_vs_tar(self):
# 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':
+ tar_cmd.insert(1, '--no-mac-metadata')
subprocess.check_call(tar_cmd, cwd=root_dir,
stdout=subprocess.DEVNULL) The line numbers are a bit off, the patch is on top of my previous one. I haven't created a PR yet because I haven't checked yet how far back the |
I cannot reproduce it anymore. @ronaldoussoren I believe that this flag exists:
|
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.
The attached PR uses |
I'd love to find what's causing the test failure. Something must cause additional metadata to be present in the to-be-archived directory, and given the test error this is likely an inherited ACL on the directory used by |
It happens every time on the unchanged main branch when I run this:
This is on a new M3 Macbook Pro running Sonoma 14.1.2. On Monday I can test on an older i86 Mac running macOS 13.something. |
I should add that, while the Mac is brand new, when I configured it I let it copy all the filesystem contents from my old Intel Mac; this was so thorough that initially the compiler seemed to be building i86 code. Possibly this did something to the temp dir ACL so as to cause the problem. Anyway, your PR fixes it. |
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.
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 dd2ebdf) Co-authored-by: Ronald Oussoren <[email protected]>
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 dd2ebdf) Co-authored-by: Ronald Oussoren <[email protected]>
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 dd2ebdf) Co-authored-by: Ronald Oussoren <[email protected]>
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 dd2ebdf) Co-authored-by: Ronald Oussoren <[email protected]>
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.
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.
Bug report
Running locally on macos 14.0
Linked PRs
The text was updated successfully, but these errors were encountered: