Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,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@v4
with:
persist-credentials: false
- run: env PYTESTFLAGS="--verbose -p no:cacheprovider --color=yes" test/macos-script.sh
12 changes: 8 additions & 4 deletions completions/rsync
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,15 @@ _comp_cmd_rsync()
# meaning before v3.2.0) contain the following unusual line in
# --help:
# "(-h) --help show this help (-h is --help only if used alone)"
_comp_compgen -Rv tmp help - <<<"$("$1" --help 2>&1 | command sed -e 's/^([^)]*)//')"
if _comp_compgen -Rv tmp help - <<<"$("$1" --help 2>&1 | command sed -e 's/^([^)]*)//')"; then

_comp_compgen -- -W '"${tmp[@]}"
--daemon --old-d{,irs}
--no-{blocking-io,detach,whole-file,inc-recursive,i-r}' -X '--no-OPTION'
_comp_compgen -- -W '"${tmp[@]}"
--daemon --old-d{,irs}
--no-{blocking-io,detach,whole-file,inc-recursive,i-r}' -X '--no-OPTION'
# We didn't find any options using _comp_compgen_help, try _usage for BSD style usage
else
_comp_compgen_usage
fi
[[ ${COMPREPLY-} == *= ]] || compopt +o nospace
;;
*:*)
Expand Down
24 changes: 24 additions & 0 deletions test/macos-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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 venv venv
#shellcheck disable=SC1091
source venv/bin/activate
python3 -m pip install -r test/requirements.txt

export bashcomp_bash=bash
env

autoreconf -i
./configure
make -j

make distcheck \
PYTESTFLAGS="${PYTESTFLAGS---verbose -p no:cacheprovider --numprocesses=auto --dist=loadfile}"
6 changes: 4 additions & 2 deletions test/t/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,9 @@ 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() if x]
)

def __eq__(self, expected: object) -> bool:
"""
Expand All @@ -791,7 +793,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()
Expand Down
3 changes: 2 additions & 1 deletion test/t/test_rsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def test_3(self, completion):

@pytest.mark.complete("rsync --", require_cmd=True)
def test_4(self, completion):
assert "--help" in completion
assert "--compress" in completion
assert "--timeout=" in completion

@pytest.mark.parametrize(
"ver1,ver2,result",
Expand Down
2 changes: 1 addition & 1 deletion test/t/test_tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 1 addition & 6 deletions test/t/test_vipw.py
Original file line number Diff line number Diff line change
@@ -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
16 changes: 15 additions & 1 deletion test/t/unit/test_unit_compgen_filedir.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,21 @@ def test_26(self, bash, functions, funcname):
completion = assert_complete(
bash, r'%s "a\$b/' % funcname, cwd="_filedir"
)
assert completion == 'h"'
try:
assert completion == 'h"'
except AssertionError:
bash_version = assert_bash_exec(
bash,
r'printf "%s.%s\n" "${BASH_VERSINFO[0]}" "${BASH_VERSINFO[1]}"',
want_output=True,
).strip()
# This is workaround for https://github.com/scop/bash-completion/issues/1435, see
# https://lists.gnu.org/archive/html/bug-bash/2025-09/msg00332.html
# Once this is fixed, the version check should be minimized further
if bash_version == "5.3":
assert completion.endswith('h" ')
else:
raise

@pytest.mark.xfail(reason="TODO: non-ASCII issues with test suite?")
@pytest.mark.parametrize("funcname", "f f2".split())
Expand Down
5 changes: 4 additions & 1 deletion test/t/unit/test_unit_dequote.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

import pytest

from conftest import assert_bash_exec, bash_env_saved
Expand Down Expand Up @@ -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() == "<a b><a$b><a&b><a'b>"
items = sorted(re.findall(r"<[^>]*>", output))
assert "".join(items) == "<a b><a$b><a&b><a'b>"

def test_7_quote_1(self, bash, functions):
output = assert_bash_exec(
Expand Down
6 changes: 5 additions & 1 deletion test/t/unit/test_unit_load.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys

import pytest

Expand Down Expand Up @@ -33,7 +34,10 @@ def fixture_dir(self, request, bash):
assert_bash_exec(
bash, "ln -sf ../prefix1/sbin/cmd2 %s/bin/cmd2" % tmpdir
)
return str(tmpdir)
yield str(tmpdir)
if sys.platform == "darwin":
assert_bash_exec(bash, "sudo rm -rf %s/*" % tmpdir)
assert_bash_exec(bash, "rm -rf %s/*" % tmpdir)

def test_userdir_1(self, bash, fixture_dir):
with bash_env_saved(bash) as bash_env:
Expand Down
Loading