Skip to content

Macos ci #1339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,9 @@ jobs:
env:
GH_TOKEN: ${{github.token}}
if: steps.release.outputs.release_created

distcheck-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- run: env PYTESTFLAGS="--verbose -p no:cacheprovider --color=yes -k '(TestTar and test_25) or TestPs'" test/macos-script.sh
6 changes: 5 additions & 1 deletion completions/patch
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ _comp_cmd_patch()
[[ $was_split ]] && return

if [[ $cur == -* ]]; then
_comp_compgen_help
if [[ $OSTYPE == *@(darwin)* ]]; then
_comp_compgen_usage
else
_comp_compgen_help
fi
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
Expand Down
3 changes: 3 additions & 0 deletions completions/tar
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ _comp_cmd_tar__preparse_cmdline()
# Generate completions for -f/--file.
_comp_cmd_tar__file_option()
{
set -x
local ext="$1"

case "$tar_mode" in
Expand Down Expand Up @@ -510,6 +511,7 @@ _comp_cmd_tar__is_bsdtar()

_comp_cmd_tar__detect_ext()
{
set -x
local tars='@(@(tar|spkg)?(.@(Z|[bgx]z|bz2|lz?(ma|o)|zst))|t@([abglx]z|b?(z)2|zst)|cbt|gem|xbps)'
if _comp_cmd_tar__is_bsdtar; then
# https://github.com/libarchive/libarchive/wiki/LibarchiveFormats
Expand Down Expand Up @@ -787,6 +789,7 @@ _comp_cmd_tar__posix()

local ext

set -x
_comp_cmd_tar__detect_ext

_comp_cmd_tar__adjust_PREV_from_old_option
Expand Down
6 changes: 5 additions & 1 deletion completions/truncate
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ _comp_cmd_truncate()
[[ $was_split ]] && return

if [[ $cur == -* ]]; then
_comp_compgen_help
if [[ $OSTYPE == *@(darwin)* ]]; then
_comp_compgen_usage
else
_comp_compgen_help
fi
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
Expand Down
26 changes: 26 additions & 0 deletions test/macos-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/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

oldpwd=$(pwd)

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}"
4 changes: 3 additions & 1 deletion test/t/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,9 @@ def prepare_fixture_dir(
the tarball. This is to work better with case insensitive file systems.
"""
tempdir = Path(tempfile.mkdtemp(prefix="bash-completion-fixture-dir"))
request.addfinalizer(lambda: shutil.rmtree(str(tempdir)))
request.addfinalizer(
lambda: shutil.rmtree(str(tempdir), ignore_errors=True)
)

old_cwd = os.getcwd()
try:
Expand Down
26 changes: 14 additions & 12 deletions test/t/test_make.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
import os
import sys

import pytest

from conftest import assert_complete


class TestMake:
@pytest.fixture
def remove_extra_makefile(self, bash):
yield
# For some reason macos make doesn't actually create extra_makefile
if sys.platform != "darwin":
os.remove(f"{bash.cwd}/make/extra_makefile")

@pytest.mark.complete("make -f Ma", cwd="make")
def test_1(self, completion):
assert completion == "kefile"

@pytest.mark.complete("make .", cwd="make", require_cmd=True)
def test_2(self, bash, completion):
def test_2(self, bash, completion, remove_extra_makefile):
"""Hidden targets."""
assert completion == ".cache/ .test_passes".split()
os.remove(f"{bash.cwd}/make/extra_makefile")

@pytest.mark.complete("make .cache/", cwd="make", require_cmd=True)
def test_3(self, bash, completion):
def test_3(self, bash, completion, remove_extra_makefile):
assert completion == ".cache/1 .cache/2".split()
os.remove(f"{bash.cwd}/make/extra_makefile")

@pytest.mark.complete("make ", cwd="shared/empty_dir")
def test_4(self, completion):
Expand All @@ -30,24 +36,20 @@ def test_5(self, completion):
assert completion

@pytest.mark.complete("make ", cwd="make", require_cmd=True)
def test_6(self, bash, completion):
def test_6(self, bash, completion, remove_extra_makefile):
assert completion == "all clean extra_makefile install sample".split()
os.remove(f"{bash.cwd}/make/extra_makefile")

@pytest.mark.complete("make .cache/.", cwd="make", require_cmd=True)
def test_7(self, bash, completion):
def test_7(self, bash, completion, remove_extra_makefile):
assert completion == ".cache/.1 .cache/.2".split()
os.remove(f"{bash.cwd}/make/extra_makefile")

@pytest.mark.complete("make -C make ", require_cmd=True)
def test_8(self, bash, completion):
def test_8(self, bash, completion, remove_extra_makefile):
assert completion == "all clean extra_makefile install sample".split()
os.remove(f"{bash.cwd}/make/extra_makefile")

@pytest.mark.complete("make -nC make ", require_cmd=True)
def test_8n(self, bash, completion):
def test_8n(self, bash, completion, remove_extra_makefile):
assert completion == "all clean extra_makefile install sample".split()
os.remove(f"{bash.cwd}/make/extra_makefile")

@pytest.mark.complete("make -", require_cmd=True)
def test_9(self, completion):
Expand Down
6 changes: 5 additions & 1 deletion test/t/test_ps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest

from conftest import assert_bash_exec


def is_int(s):
try:
Expand Down Expand Up @@ -35,7 +37,9 @@ def test_4(self, completion):
assert not completion

@pytest.mark.complete("ps --pid ")
def test_5(self, completion):
def test_5(self, completion, bash):
ps_pid_output = assert_bash_exec(bash, "command ps ax -o pid=", want_output=True)
print("\n=====PS output=====\n", ps_pid_output, "\n======PS output end=====\n")
assert completion
assert all(map(is_int, completion))

Expand Down
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
27 changes: 21 additions & 6 deletions test/t/unit/test_unit_expand_glob.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import unicodedata

import pytest

from conftest import assert_bash_exec, bash_env_saved


def normalize(string):
# Applies "canonical decomposition", so might make errors look weird?
# The alternative is probably `NFC` which composes together some of
# the characters again.
# See https://docs.python.org/3/library/unicodedata.html#unicodedata.normalize
return unicodedata.normalize("NFD", string)


@pytest.mark.bashcomp(
cmd=None,
cwd="_filedir",
Expand All @@ -22,14 +32,15 @@ def functions(self, bash):

def test_match_all(self, bash, functions):
output = assert_bash_exec(bash, "__tester '*'", want_output=True)
assert (
output.strip()
== "<a b><a$b><a&b><a'b><ab><aé><brackets><dotdot><ext>"
assert normalize(output.strip()) == normalize(
"<a b><a$b><a&b><a'b><ab><aé><brackets><dotdot><ext>"
)

def test_match_pattern(self, bash, functions):
output = assert_bash_exec(bash, "__tester 'a*'", want_output=True)
assert output.strip() == "<a b><a$b><a&b><a'b><ab><aé>"
assert normalize(output.strip()) == normalize(
"<a b><a$b><a&b><a'b><ab><aé>"
)

def test_match_unmatched(self, bash, functions):
output = assert_bash_exec(
Expand All @@ -51,7 +62,9 @@ def test_protect_from_noglob(self, bash, functions):
with bash_env_saved(bash, functions) as bash_env:
bash_env.set("noglob", True)
output = assert_bash_exec(bash, "__tester 'a*'", want_output=True)
assert output.strip() == "<a b><a$b><a&b><a'b><ab><aé>"
assert normalize(output.strip()) == normalize(
"<a b><a$b><a&b><a'b><ab><aé>"
)

def test_protect_from_failglob(self, bash, functions):
with bash_env_saved(bash) as bash_env:
Expand Down Expand Up @@ -83,4 +96,6 @@ def test_protect_from_GLOBIGNORE(self, bash, functions):
bash_env.save_shopt("dotglob")
bash_env.write_variable("GLOBIGNORE", "*")
output = assert_bash_exec(bash, "__tester 'a*'", want_output=True)
assert output.strip() == "<a b><a$b><a&b><a'b><ab><aé>"
assert normalize(output.strip()) == normalize(
"<a b><a$b><a&b><a'b><ab><aé>"
)
Loading