Skip to content

Commit d34d8fc

Browse files
authored
bpo-29185: Fix test_distutils failures on Android (GH-4438)
* Run gzip with separate command line options (Android understands '-f9' as the name of a file). * Creation of a hard link is controled by SELinux on Android.
1 parent 9001d1f commit d34d8fc

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Lib/distutils/tests/test_archive_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def test_tarfile_vs_tar(self):
162162
# now create another tarball using `tar`
163163
tarball2 = os.path.join(tmpdir, 'archive2.tar.gz')
164164
tar_cmd = ['tar', '-cf', 'archive2.tar', 'dist']
165-
gzip_cmd = ['gzip', '-f9', 'archive2.tar']
165+
gzip_cmd = ['gzip', '-f', '-9', 'archive2.tar']
166166
old_dir = os.getcwd()
167167
os.chdir(tmpdir)
168168
try:

Lib/distutils/tests/test_file_util.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from distutils import log
99
from distutils.tests import support
1010
from distutils.errors import DistutilsFileError
11-
from test.support import run_unittest
11+
from test.support import run_unittest, unlink
1212

1313
class FileUtilTestCase(support.TempdirManager, unittest.TestCase):
1414

@@ -80,6 +80,14 @@ def test_move_file_exception_unpacking_unlink(self):
8080
def test_copy_file_hard_link(self):
8181
with open(self.source, 'w') as f:
8282
f.write('some content')
83+
# Check first that copy_file() will not fall back on copying the file
84+
# instead of creating the hard link.
85+
try:
86+
os.link(self.source, self.target)
87+
except OSError as e:
88+
self.skipTest('os.link: %s' % e)
89+
else:
90+
unlink(self.target)
8391
st = os.stat(self.source)
8492
copy_file(self.source, self.target, link='hard')
8593
st2 = os.stat(self.source)

0 commit comments

Comments
 (0)