Skip to content

Commit 460b59f

Browse files
authored
Merge pull request #82 from lazka/cygwin-test
CI: Add a test job for Cygwin
2 parents dd3376e + 1d98a15 commit 460b59f

File tree

4 files changed

+47
-16
lines changed

4 files changed

+47
-16
lines changed

.github/workflows/main.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,30 @@ jobs:
2121
- name: Run tests
2222
run: tox
2323

24+
test_cygwin:
25+
strategy:
26+
matrix:
27+
python: [39]
28+
platform: [windows-latest]
29+
runs-on: ${{ matrix.platform }}
30+
steps:
31+
- uses: actions/checkout@v2
32+
- name: Install Cygwin
33+
uses: cygwin/cygwin-install-action@v1
34+
with:
35+
platform: x86_64
36+
packages: >-
37+
python${{ matrix.python }},
38+
python${{ matrix.python }}-devel,
39+
python${{ matrix.python }}-pytest,
40+
gcc-core,
41+
gcc-g++,
42+
ncompress
43+
- name: Run tests
44+
shell: C:\cygwin\bin\env.exe CYGWIN_NOWINPATH=1 CHERE_INVOKING=1 C:\cygwin\bin\bash.exe -leo pipefail -o igncr {0}
45+
run: |
46+
pytest -rs
47+
2448
ci_setuptools:
2549
# Integration testing with setuptools
2650
strategy:

distutils/tests/test_archive_util.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,11 @@
1414
from distutils.spawn import find_executable, spawn
1515
from distutils.tests import support
1616
from test.support import run_unittest, patch
17+
from .unix_compat import require_unix_id, require_uid_0, grp, pwd, UID_0_SUPPORT
1718

1819
from .py38compat import change_cwd
1920
from .py38compat import check_warnings
2021

21-
try:
22-
import grp
23-
import pwd
24-
UID_GID_SUPPORT = True
25-
except ImportError:
26-
UID_GID_SUPPORT = False
2722

2823
try:
2924
import zipfile
@@ -339,7 +334,7 @@ def test_make_archive_xztar(self):
339334
def test_make_archive_owner_group(self):
340335
# testing make_archive with owner and group, with various combinations
341336
# this works even if there's not gid/uid support
342-
if UID_GID_SUPPORT:
337+
if UID_0_SUPPORT:
343338
group = grp.getgrgid(0)[0]
344339
owner = pwd.getpwuid(0)[0]
345340
else:
@@ -364,7 +359,8 @@ def test_make_archive_owner_group(self):
364359
self.assertTrue(os.path.exists(res))
365360

366361
@unittest.skipUnless(ZLIB_SUPPORT, "Requires zlib")
367-
@unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
362+
@require_unix_id
363+
@require_uid_0
368364
def test_tarfile_root_owner(self):
369365
tmpdir = self._create_files()
370366
base_name = os.path.join(self.mkdtemp(), 'archive')

distutils/tests/test_sdist.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from os.path import join
88
from textwrap import dedent
99
from test.support import captured_stdout, run_unittest
10+
from .unix_compat import require_unix_id, require_uid_0, pwd, grp
1011

1112
from .py38compat import check_warnings
1213

@@ -16,13 +17,6 @@
1617
except ImportError:
1718
ZLIB_SUPPORT = False
1819

19-
try:
20-
import grp
21-
import pwd
22-
UID_GID_SUPPORT = True
23-
except ImportError:
24-
UID_GID_SUPPORT = False
25-
2620
from distutils.command.sdist import sdist, show_formats
2721
from distutils.core import Distribution
2822
from distutils.tests.test_config import BasePyPIRCCommandTestCase
@@ -440,7 +434,8 @@ def test_manual_manifest(self):
440434
'fake-1.0/README.manual'])
441435

442436
@unittest.skipUnless(ZLIB_SUPPORT, "requires zlib")
443-
@unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
437+
@require_unix_id
438+
@require_uid_0
444439
@unittest.skipIf(find_executable('tar') is None,
445440
"The tar command is not found")
446441
@unittest.skipIf(find_executable('gzip') is None,

distutils/tests/unix_compat.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import sys
2+
import unittest
3+
4+
try:
5+
import grp
6+
import pwd
7+
except ImportError:
8+
grp = pwd = None
9+
10+
11+
UNIX_ID_SUPPORT = grp and pwd
12+
UID_0_SUPPORT = UNIX_ID_SUPPORT and sys.platform != "cygwin"
13+
14+
require_unix_id = unittest.skipUnless(
15+
UNIX_ID_SUPPORT, "Requires grp and pwd support")
16+
require_uid_0 = unittest.skipUnless(UID_0_SUPPORT, "Requires UID 0 support")

0 commit comments

Comments
 (0)