From f83c5c5f5b3f87e72ef4b9ee6070a3b12e5ad936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 31 May 2021 23:13:02 +0300 Subject: [PATCH 01/12] test: add macOS test script --- test/macos-script.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 test/macos-script.sh diff --git a/test/macos-script.sh b/test/macos-script.sh new file mode 100755 index 00000000000..d1480312fce --- /dev/null +++ b/test/macos-script.sh @@ -0,0 +1,22 @@ +#!/bin/sh -eux + +# Note that this script is intended to be run only in throwaway environments; +# it may install undesirable things to system locations (if it succeeds in +# that). + +brew install \ + automake \ + bash + +python3 -m pip install -r test/requirements.txt + +export bashcomp_bash=bash +env + +autoreconf -i +./configure +make -j + +make distcheck \ + PYTESTFLAGS="${PYTESTFLAGS---verbose --numprocesses=auto --dist=loadfile}" +cp -p bash-completion-*.tar.* "$oldpwd/" From d3b5cd6e2464a972b9f55363ba8d13a00dfdb7b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Thu, 4 Apr 2024 21:46:12 +0000 Subject: [PATCH 02/12] ci(macos): add macOS CI test config --- .github/workflows/ci.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 08285b7b852..8657805f417 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -103,3 +103,11 @@ jobs: GH_TOKEN: ${{github.token}} RELEASE_PLEASE_TAG_NAME: ${{steps.release.outputs.tag_name}} if: steps.release.outputs.release_created + + distcheck-macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + - run: env PYTESTFLAGS=--verbose test/macos-script.sh From 6f9c1ca12d9c91e26e03aa9f944cdfc900a7fc70 Mon Sep 17 00:00:00 2001 From: Yedaya Katsman Date: Mon, 24 Feb 2025 22:36:34 +0200 Subject: [PATCH 03/12] ci(macos): Align macos script with current linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also use venv instead of global install brew/python doesn't like installing python packages globally: ``` error: externally-managed-environment × This environment is externally managed ``` --- .github/workflows/ci.yaml | 2 +- test/macos-script.sh | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8657805f417..6f03e36baff 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -110,4 +110,4 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - run: env PYTESTFLAGS=--verbose test/macos-script.sh + - run: env PYTESTFLAGS="--verbose -p no:cacheprovider" test/macos-script.sh diff --git a/test/macos-script.sh b/test/macos-script.sh index d1480312fce..d40142f66b4 100755 --- a/test/macos-script.sh +++ b/test/macos-script.sh @@ -8,6 +8,9 @@ brew install \ automake \ bash +python3 -m venv venv +#shellcheck disable=SC1091 +source venv/bin/activate python3 -m pip install -r test/requirements.txt export bashcomp_bash=bash @@ -18,5 +21,4 @@ autoreconf -i make -j make distcheck \ - PYTESTFLAGS="${PYTESTFLAGS---verbose --numprocesses=auto --dist=loadfile}" -cp -p bash-completion-*.tar.* "$oldpwd/" + PYTESTFLAGS="${PYTESTFLAGS---verbose -p no:cacheprovider --numprocesses=auto --dist=loadfile}" From bdbd53d6cdc13956a19e349f0b2ef0f37549497c Mon Sep 17 00:00:00 2001 From: Yedaya Katsman Date: Tue, 25 Feb 2025 21:30:50 +0200 Subject: [PATCH 04/12] ci(macos): Force colored output --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6f03e36baff..7c4b403ca5b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -110,4 +110,4 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - run: env PYTESTFLAGS="--verbose -p no:cacheprovider" test/macos-script.sh + - run: env PYTESTFLAGS="--verbose -p no:cacheprovider --color=yes" test/macos-script.sh From 1acaabdf3119873b0f3aa47ed436377216284809 Mon Sep 17 00:00:00 2001 From: Yedaya Katsman Date: Fri, 4 Jul 2025 17:08:34 +0300 Subject: [PATCH 05/12] test(vipw): Drop exception for macos vipw seems to have -d as an option on macos now. Partially reverts ccf7bf69d "test(dmesg,vipw): expect no options on macOS" --- test/t/test_vipw.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/t/test_vipw.py b/test/t/test_vipw.py index b78fcbda8b0..07b454bff4f 100644 --- a/test/t/test_vipw.py +++ b/test/t/test_vipw.py @@ -1,12 +1,7 @@ -import sys - import pytest class TestVipw: @pytest.mark.complete("vipw -", require_cmd=True) def test_1(self, completion): - if sys.platform == "darwin": - assert not completion # takes no options - else: - assert completion + assert completion From bd69016f2320814fc9eb7b040ceee813827bca0b Mon Sep 17 00:00:00 2001 From: Yedaya Katsman Date: Thu, 18 Sep 2025 20:26:36 +0300 Subject: [PATCH 06/12] test: Sort completion results items It seems there is some behaviour differences regarding the order completions are returned in between linux and macos, specifically regarding sorting of upper case and lowercase letters. Sorting them ourselves in the tests makes it consistent. --- test/t/conftest.py | 4 ++-- test/t/unit/test_unit_dequote.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/t/conftest.py b/test/t/conftest.py index 803d57cf69f..bf5a1cde3a7 100644 --- a/test/t/conftest.py +++ b/test/t/conftest.py @@ -784,7 +784,7 @@ def startswith(self, prefix: str) -> bool: return self.output.startswith(prefix) def _items(self) -> List[str]: - return [x.strip() for x in self.output.strip().splitlines()] + return sorted([x.strip() for x in self.output.strip().splitlines()]) def __eq__(self, expected: object) -> bool: """ @@ -799,7 +799,7 @@ def __eq__(self, expected: object) -> bool: return False else: expiter = expected - return self._items() == expiter + return self._items() == sorted(expiter) def __contains__(self, item: str) -> bool: return item in self._items() diff --git a/test/t/unit/test_unit_dequote.py b/test/t/unit/test_unit_dequote.py index 392b54266f7..a8a311ec361 100644 --- a/test/t/unit/test_unit_dequote.py +++ b/test/t/unit/test_unit_dequote.py @@ -1,3 +1,5 @@ +import re + import pytest from conftest import assert_bash_exec, bash_env_saved @@ -38,7 +40,8 @@ def test_5_brace(self, bash, functions): def test_6_glob(self, bash, functions): output = assert_bash_exec(bash, "__tester 'a?b'", want_output=True) - assert output.strip() == "" + items = sorted(re.findall(r"<[^>]*>", output)) + assert "".join(items) == "" def test_7_quote_1(self, bash, functions): output = assert_bash_exec( From 6c656e4df863a7b151419b524c3d53c5ba345010 Mon Sep 17 00:00:00 2001 From: Yedaya Katsman Date: Sun, 21 Sep 2025 16:10:15 +0300 Subject: [PATCH 07/12] test: Remove empty strings from completion results --- test/t/conftest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/t/conftest.py b/test/t/conftest.py index bf5a1cde3a7..3143f6a048a 100644 --- a/test/t/conftest.py +++ b/test/t/conftest.py @@ -784,7 +784,9 @@ def startswith(self, prefix: str) -> bool: return self.output.startswith(prefix) def _items(self) -> List[str]: - return sorted([x.strip() for x in self.output.strip().splitlines()]) + return sorted( + [x.strip() for x in self.output.strip().splitlines() if x] + ) def __eq__(self, expected: object) -> bool: """ From c494f7757bce9ab915f4d430390e1be98904bce7 Mon Sep 17 00:00:00 2001 From: Yedaya Katsman Date: Tue, 7 Oct 2025 22:21:04 +0300 Subject: [PATCH 08/12] test(tar): skip test_25 for non-gnu tar --- test/t/test_tar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/t/test_tar.py b/test/t/test_tar.py index 73db7c30905..8d03da296f0 100644 --- a/test/t/test_tar.py +++ b/test/t/test_tar.py @@ -129,7 +129,7 @@ def test_24(self, completion): # Test compression detection of gnu style options @pytest.mark.complete("tar --extract --xz --file ", cwd="tar") - def test_25(self, completion): + def test_25(self, completion, gnu_tar): assert completion == "archive.tar.xz dir/ dir2/".split() # TODO: "tar tf escape.tar a/b" From 0a99ce01a15fb50523bd33e745487a214125f843 Mon Sep 17 00:00:00 2001 From: Yedaya Katsman Date: Wed, 8 Oct 2025 00:20:25 +0300 Subject: [PATCH 09/12] test(unit_load): Delete files we create in fixture On macOS we need sudo to delete them, maybe because they were created by a different prcoess? --- test/t/unit/test_unit_load.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/t/unit/test_unit_load.py b/test/t/unit/test_unit_load.py index aacea13a6c8..6091415aff7 100644 --- a/test/t/unit/test_unit_load.py +++ b/test/t/unit/test_unit_load.py @@ -1,4 +1,5 @@ import os +import sys import pytest @@ -44,7 +45,11 @@ def fixture_dir(self, bash, tmp_path_factory): cmd1.symlink_to("../prefix1/bin/cmd1") cmd2.symlink_to("../prefix1/sbin/cmd2") - return str(tmpdir) + yield str(tmpdir) + if sys.platform == "darwin": + assert_bash_exec(bash, "sudo rm -rf %s/*" % tmpdir) + else: + assert_bash_exec(bash, "rm -rf %s/*" % tmpdir) def test_userdir_1(self, bash, fixture_dir): with bash_env_saved(bash) as bash_env: From 5d89a8cb7a66a43d1b146ef9cb82b9c820c92e32 Mon Sep 17 00:00:00 2001 From: Yedaya Katsman Date: Sat, 18 Oct 2025 21:43:45 +0300 Subject: [PATCH 10/12] Revert "test: Sort completion results items" This reverts commit 8074741e7a7830a295f0c1ddbfd4115d3a0f7f3d. --- test/t/conftest.py | 6 ++---- test/t/unit/test_unit_dequote.py | 7 +++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/test/t/conftest.py b/test/t/conftest.py index 3143f6a048a..5fa73820bcf 100644 --- a/test/t/conftest.py +++ b/test/t/conftest.py @@ -784,9 +784,7 @@ def startswith(self, prefix: str) -> bool: return self.output.startswith(prefix) def _items(self) -> List[str]: - return sorted( - [x.strip() for x in self.output.strip().splitlines() if x] - ) + return [x.strip() for x in self.output.strip().splitlines() if x] def __eq__(self, expected: object) -> bool: """ @@ -801,7 +799,7 @@ def __eq__(self, expected: object) -> bool: return False else: expiter = expected - return self._items() == sorted(expiter) + return self._items() == expiter def __contains__(self, item: str) -> bool: return item in self._items() diff --git a/test/t/unit/test_unit_dequote.py b/test/t/unit/test_unit_dequote.py index a8a311ec361..102c3470c80 100644 --- a/test/t/unit/test_unit_dequote.py +++ b/test/t/unit/test_unit_dequote.py @@ -1,5 +1,3 @@ -import re - import pytest from conftest import assert_bash_exec, bash_env_saved @@ -39,9 +37,10 @@ def test_5_brace(self, bash, functions): assert output.strip() == "" def test_6_glob(self, bash, functions): + LC_out = assert_bash_exec(bash, "env | grep LC_", want_output=True) + print(f"LC_ vars:\n\n{LC_out}\n") output = assert_bash_exec(bash, "__tester 'a?b'", want_output=True) - items = sorted(re.findall(r"<[^>]*>", output)) - assert "".join(items) == "" + assert output.strip() == "" def test_7_quote_1(self, bash, functions): output = assert_bash_exec( From a2793cfa74047ffd3cff06e4d311b0ee8f936e66 Mon Sep 17 00:00:00 2001 From: Yedaya Katsman Date: Sun, 30 Nov 2025 21:38:10 +0200 Subject: [PATCH 11/12] test sorting with LC_COLLATE --- test/macos-script.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/macos-script.sh b/test/macos-script.sh index d40142f66b4..959d182d8fe 100755 --- a/test/macos-script.sh +++ b/test/macos-script.sh @@ -15,6 +15,11 @@ python3 -m pip install -r test/requirements.txt export bashcomp_bash=bash env +LC_ALL=C sort <<<$'python-dev\npython3-dev' +LC_COLLATE=C sort <<<$'python-dev\npython3-dev' +LC_ALL=en_US.UTF-8 sort <<<$'python-dev\npython3-dev' +LC_COLLATE=en_US.UTF-8 sort <<<$'python-dev\npython3-dev' + autoreconf -i ./configure From 088cc5be0b99ff9e0265738c24a666c550db446c Mon Sep 17 00:00:00 2001 From: Yedaya Katsman Date: Thu, 1 Jan 2026 18:17:12 +0200 Subject: [PATCH 12/12] Revert "test(unit_load): Delete files we create in fixture" This reverts commit 0a99ce01a15fb50523bd33e745487a214125f843. --- test/t/unit/test_unit_load.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/t/unit/test_unit_load.py b/test/t/unit/test_unit_load.py index 6091415aff7..aacea13a6c8 100644 --- a/test/t/unit/test_unit_load.py +++ b/test/t/unit/test_unit_load.py @@ -1,5 +1,4 @@ import os -import sys import pytest @@ -45,11 +44,7 @@ def fixture_dir(self, bash, tmp_path_factory): cmd1.symlink_to("../prefix1/bin/cmd1") cmd2.symlink_to("../prefix1/sbin/cmd2") - yield str(tmpdir) - if sys.platform == "darwin": - assert_bash_exec(bash, "sudo rm -rf %s/*" % tmpdir) - else: - assert_bash_exec(bash, "rm -rf %s/*" % tmpdir) + return str(tmpdir) def test_userdir_1(self, bash, fixture_dir): with bash_env_saved(bash) as bash_env: