Skip to content

Commit

Permalink
Merge pull request #82 from lazka/cygwin-test
Browse files Browse the repository at this point in the history
CI: Add a test job for Cygwin
  • Loading branch information
jaraco committed Dec 18, 2021
2 parents dd3376e + 1d98a15 commit 460b59f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 16 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@ jobs:
- name: Run tests
run: tox

test_cygwin:
strategy:
matrix:
python: [39]
platform: [windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- name: Install Cygwin
uses: cygwin/cygwin-install-action@v1
with:
platform: x86_64
packages: >-
python${{ matrix.python }},
python${{ matrix.python }}-devel,
python${{ matrix.python }}-pytest,
gcc-core,
gcc-g++,
ncompress
- name: Run tests
shell: C:\cygwin\bin\env.exe CYGWIN_NOWINPATH=1 CHERE_INVOKING=1 C:\cygwin\bin\bash.exe -leo pipefail -o igncr {0}
run: |
pytest -rs
ci_setuptools:
# Integration testing with setuptools
strategy:
Expand Down
12 changes: 4 additions & 8 deletions distutils/tests/test_archive_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,11 @@
from distutils.spawn import find_executable, spawn
from distutils.tests import support
from test.support import run_unittest, patch
from .unix_compat import require_unix_id, require_uid_0, grp, pwd, UID_0_SUPPORT

from .py38compat import change_cwd
from .py38compat import check_warnings

try:
import grp
import pwd
UID_GID_SUPPORT = True
except ImportError:
UID_GID_SUPPORT = False

try:
import zipfile
Expand Down Expand Up @@ -339,7 +334,7 @@ def test_make_archive_xztar(self):
def test_make_archive_owner_group(self):
# testing make_archive with owner and group, with various combinations
# this works even if there's not gid/uid support
if UID_GID_SUPPORT:
if UID_0_SUPPORT:
group = grp.getgrgid(0)[0]
owner = pwd.getpwuid(0)[0]
else:
Expand All @@ -364,7 +359,8 @@ def test_make_archive_owner_group(self):
self.assertTrue(os.path.exists(res))

@unittest.skipUnless(ZLIB_SUPPORT, "Requires zlib")
@unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
@require_unix_id
@require_uid_0
def test_tarfile_root_owner(self):
tmpdir = self._create_files()
base_name = os.path.join(self.mkdtemp(), 'archive')
Expand Down
11 changes: 3 additions & 8 deletions distutils/tests/test_sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from os.path import join
from textwrap import dedent
from test.support import captured_stdout, run_unittest
from .unix_compat import require_unix_id, require_uid_0, pwd, grp

from .py38compat import check_warnings

Expand All @@ -16,13 +17,6 @@
except ImportError:
ZLIB_SUPPORT = False

try:
import grp
import pwd
UID_GID_SUPPORT = True
except ImportError:
UID_GID_SUPPORT = False

from distutils.command.sdist import sdist, show_formats
from distutils.core import Distribution
from distutils.tests.test_config import BasePyPIRCCommandTestCase
Expand Down Expand Up @@ -440,7 +434,8 @@ def test_manual_manifest(self):
'fake-1.0/README.manual'])

@unittest.skipUnless(ZLIB_SUPPORT, "requires zlib")
@unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
@require_unix_id
@require_uid_0
@unittest.skipIf(find_executable('tar') is None,
"The tar command is not found")
@unittest.skipIf(find_executable('gzip') is None,
Expand Down
16 changes: 16 additions & 0 deletions distutils/tests/unix_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import sys
import unittest

try:
import grp
import pwd
except ImportError:
grp = pwd = None


UNIX_ID_SUPPORT = grp and pwd
UID_0_SUPPORT = UNIX_ID_SUPPORT and sys.platform != "cygwin"

require_unix_id = unittest.skipUnless(
UNIX_ID_SUPPORT, "Requires grp and pwd support")
require_uid_0 = unittest.skipUnless(UID_0_SUPPORT, "Requires UID 0 support")

0 comments on commit 460b59f

Please sign in to comment.