Skip to content
Snippets Groups Projects
Commit 6df0adf0 authored by Lucas Ramage's avatar Lucas Ramage :desktop: Committed by Leo
Browse files

main/bash-completion: upgrade to 2.10

parent 8ca0c585
No related branches found
No related tags found
No related merge requests found
From 5443c819622495fcdc759d5dd4e5c31633eab389 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
Date: Thu, 2 May 2019 16:57:25 +0300
Subject: [PATCH] _pnames: adapt for busybox ps, rewrite in pure bash
Closes https://github.com/scop/bash-completion/issues/318
---
bash_completion | 51 ++++++++++++++++++++++++++++++------------
test/t/test_killall.py | 4 ++++
2 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/bash_completion b/bash_completion
index 58987a7fc1..bf7d02c753 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1069,23 +1069,46 @@ _pnames()
} ||
_pnames()
{
+ local -a procs
if [[ "$1" == -s ]]; then
- COMPREPLY=( $(compgen -X '<defunct>' \
- -W '$(command ps axo comm | command sed -e 1d)' -- "$cur") )
+ procs=( $(command ps axo comm | command sed -e 1d) )
else
- # FIXME: completes "[kblockd/0]" to "0". Previously it was completed
- # to "kblockd" which isn't correct either. "kblockd/0" would be
- # arguably most correct, but killall from psmisc 22 treats arguments
- # containing "/" specially unless -r is given so that wouldn't quite
- # work either. Perhaps it'd be best to not complete these to anything
- # for now.
- COMPREPLY=( $(compgen -X '<defunct>' -W '$(command ps axo command= | command sed -e \
- "s/ .*//" -e \
- "s:.*/::" -e \
- "s/:$//" -e \
- "s/^[[(-]//" -e \
- "s/[])]$//" | sort -u)' -- "$cur") )
+ local line i=-1 OIFS=$IFS
+ IFS=$'\n'
+ local -a psout=( $(command ps axo command=) )
+ IFS=$OIFS
+ for line in "${psout[@]}"; do
+ if [[ $i -eq -1 ]]; then
+ # First line, see if it has COMMAND column header. For example
+ # the busybox ps does that, i.e. doesn't respect axo command=
+ if [[ $line =~ ^(.*[[:space:]])COMMAND([[:space:]]|$) ]]; then
+ # It does; store its index.
+ i=${#BASH_REMATCH[1]}
+ else
+ # Nope, fall through to "regular axo command=" parsing.
+ break
+ fi
+ else
+ #
+ line=${line:$i} # take command starting from found index
+ line=${line%% *} # trim arguments
+ procs+=( $line )
+ fi
+ done
+ if [[ $i -eq -1 ]]; then
+ # Regular axo command= parsing
+ for line in "${psout[@]}"; do
+ if [[ $line =~ ^[[(](.+)[])]$ ]]; then
+ procs+=( ${BASH_REMATCH[1]} )
+ else
+ line=${line%% *} # trim arguments
+ line=${line##@(*/|-)} # trim leading path and -
+ procs+=( $line )
+ fi
+ done
+ fi
fi
+ COMPREPLY=( $(compgen -X "<defunct>" -W '${procs[@]}' -- "$cur" ) )
}
# This function completes on user IDs
diff --git a/test/t/test_killall.py b/test/t/test_killall.py
index 725a16e4d6..136eee7373 100644
--- a/test/t/test_killall.py
+++ b/test/t/test_killall.py
@@ -11,3 +11,7 @@ def test_1(self, completion):
@pytest.mark.complete("killall --signal ")
def test_2(self, completion):
assert all(x in completion for x in "INT KILL TERM".split())
+
+ @pytest.mark.complete("killall ")
+ def test_3(self, completion):
+ assert "command=" not in completion
From 70afc1ed3697c3171a004b7db2f19220117d2862 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
Date: Tue, 30 Apr 2019 18:04:13 +0300
Subject: [PATCH] test_getconf: skip if -a doesn't output any POSIX_V*
Refs https://github.com/scop/bash-completion/issues/312
---
test/t/test_getconf.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/test/t/test_getconf.py b/test/t/test_getconf.py
index 6f9192d251..96713dbe4c 100644
--- a/test/t/test_getconf.py
+++ b/test/t/test_getconf.py
@@ -14,7 +14,9 @@ def test_2(self, completion):
def test_3(self, completion):
assert completion
- @pytest.mark.complete("getconf -v ")
+ @pytest.mark.complete(
+ "getconf -v ", skipif="! getconf -a 2>&1 | command grep -q ^POSIX_V"
+ )
def test_4(self, completion):
assert completion
From 2cdac1b9f24df62a1fa80c1824ee8524c9b02393 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
Date: Wed, 1 May 2019 13:42:52 +0300
Subject: [PATCH] test_iconv: skip option completion if --help fails
Such as on Alpine Linux (musl libc).
Refs https://github.com/scop/bash-completion/issues/312
---
test/t/test_iconv.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/t/test_iconv.py b/test/t/test_iconv.py
index dc5f8961a6..2edc439b08 100644
--- a/test/t/test_iconv.py
+++ b/test/t/test_iconv.py
@@ -2,7 +2,7 @@
class TestIconv:
- @pytest.mark.complete("iconv -")
+ @pytest.mark.complete("iconv -", skipif="! iconv --help &>/dev/null")
def test_1(self, completion):
assert completion
From 1e3d3b4d40e3f6c150b9d31965f8b007ef823fc7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
Date: Tue, 30 Apr 2019 17:47:18 +0300
Subject: [PATCH] test: generalize check whether we're being run in a container
Refs https://github.com/scop/bash-completion/issues/312
---
test/t/conftest.py | 26 ++++++++++++++++++++++++--
test/t/test_ifdown.py | 4 ++--
test/t/test_ifup.py | 4 ++--
test/t/test_make.py | 4 ++--
test/t/test_man.py | 4 ++--
test/t/unit/test_unit_ip_addresses.py | 4 ++--
6 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/test/t/conftest.py b/test/t/conftest.py
index f3c28e30c3..f65856288e 100644
--- a/test/t/conftest.py
+++ b/test/t/conftest.py
@@ -2,6 +2,7 @@
import os
import re
import shlex
+import subprocess
from typing import Iterable, List, Optional, Tuple, Union
import pexpect
@@ -442,8 +443,29 @@ def completion(request, bash: pexpect.spawn) -> CompletionResult:
return assert_complete(bash, marker.args[0], **marker.kwargs)
-def in_docker() -> bool:
- return os.path.exists("/.dockerenv")
+def in_container() -> bool:
+ try:
+ container = subprocess.check_output(
+ "virt-what || systemd-detect-virt --container",
+ stderr=subprocess.DEVNULL,
+ shell=True,
+ ).strip()
+ except subprocess.CalledProcessError:
+ container = None
+ if container and container != b"none":
+ return True
+ if os.path.exists("/.dockerenv"):
+ return True
+ try:
+ with open("/proc/1/environ", "rb") as f:
+ # LXC, others?
+ if any(
+ x.startswith(b"container=") for x in f.readline().split(b"\0")
+ ):
+ return True
+ except OSError:
+ pass
+ return False
class TestUnitBase:
diff --git a/test/t/test_ifdown.py b/test/t/test_ifdown.py
index 16447be5f3..e91e4bacd1 100644
--- a/test/t/test_ifdown.py
+++ b/test/t/test_ifdown.py
@@ -1,10 +1,10 @@
import pytest
-from conftest import in_docker
+from conftest import in_container
class TestIfdown:
- @pytest.mark.xfail(in_docker(), reason="Probably fails in docker")
+ @pytest.mark.xfail(in_container(), reason="Probably fails in a container")
@pytest.mark.complete("ifdown ")
def test_1(self, completion):
assert completion
diff --git a/test/t/test_ifup.py b/test/t/test_ifup.py
index 62d8eb4ac1..60391e478b 100644
--- a/test/t/test_ifup.py
+++ b/test/t/test_ifup.py
@@ -1,10 +1,10 @@
import pytest
-from conftest import in_docker
+from conftest import in_container
class TestIfup:
- @pytest.mark.xfail(in_docker(), reason="Probably fails in docker")
+ @pytest.mark.xfail(in_container(), reason="Probably fails in a container")
@pytest.mark.complete("ifup ")
def test_1(self, completion):
assert completion
diff --git a/test/t/test_make.py b/test/t/test_make.py
index 9c76f83c1d..ae468fa93e 100644
--- a/test/t/test_make.py
+++ b/test/t/test_make.py
@@ -2,7 +2,7 @@
import pytest
-from conftest import in_docker
+from conftest import in_container
class TestMake:
@@ -35,7 +35,7 @@ def test_6(self, bash, completion):
os.remove("%s/make/%s" % (bash.cwd, "extra_makefile"))
@pytest.mark.xfail(
- in_docker() and os.environ.get("DIST") == "centos6",
+ in_container() and os.environ.get("DIST") == "centos6",
reason="Fails for some unknown reason on CentOS 6, "
"even though the behavior appears to be correct",
)
diff --git a/test/t/test_man.py b/test/t/test_man.py
index 60021d9958..2da3087e55 100644
--- a/test/t/test_man.py
+++ b/test/t/test_man.py
@@ -2,7 +2,7 @@
import pytest
-from conftest import assert_bash_exec, in_docker
+from conftest import assert_bash_exec, in_container
@pytest.mark.bashcomp(ignore_env=r"^[+-]MANPATH=")
@@ -43,7 +43,7 @@ def test_3(self, completion):
assert completion == "man/quux.8"
@pytest.mark.xfail(
- in_docker() and os.environ.get("DIST") == "centos6",
+ in_container() and os.environ.get("DIST") == "centos6",
reason="TODO: Fails in CentOS for some reason, unknown "
"how to trigger same behavior as tests show (is "
"different and correct when tried manually, but here "
diff --git a/test/t/unit/test_unit_ip_addresses.py b/test/t/unit/test_unit_ip_addresses.py
index cd7a38abc1..8120c88216 100644
--- a/test/t/unit/test_unit_ip_addresses.py
+++ b/test/t/unit/test_unit_ip_addresses.py
@@ -1,6 +1,6 @@
import pytest
-from conftest import assert_bash_exec, in_docker
+from conftest import assert_bash_exec, in_container
@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+COMPREPLY=")
@@ -41,7 +41,7 @@ def test_3(self, functions, completion):
assert completion
assert all("." in x for x in completion)
- @pytest.mark.xfail(in_docker(), reason="Probably fails in docker")
+ @pytest.mark.xfail(in_container(), reason="Probably fails in a container")
@pytest.mark.complete("ia6 ")
def test_4(self, functions, completion):
"""_ip_addresses -6 should complete ipv6 addresses."""
From 90ede989622143dc93c9a05a18bc23767c4bff9c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Tue, 30 Apr 2019 09:59:19 +0200
Subject: [PATCH] test_arp: Skip if ARP tables are empty
Skip test_arp if 'arp' yields no output. This e.g. happens when
the host is not networking-enabled.
---
test/t/test_arp.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/test/t/test_arp.py b/test/t/test_arp.py
index 35963d754e..0dc117284e 100644
--- a/test/t/test_arp.py
+++ b/test/t/test_arp.py
@@ -1,11 +1,8 @@
import pytest
-from conftest import in_docker
-
class TestArp:
- @pytest.mark.xfail(in_docker(), reason="Probably fails in docker")
- @pytest.mark.complete("arp ")
+ @pytest.mark.complete("arp ", skipif='test -z "$(arp 2>/dev/null)"')
def test_1(self, completion):
assert completion
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Contributor: Kiyoshi Aman <kiyoshi.aman@gmail.com> # Contributor: Kiyoshi Aman <kiyoshi.aman@gmail.com>
# Maintainer: Lucas Ramage <ramage.lucas@openmailbox.org> # Maintainer: Lucas Ramage <ramage.lucas@openmailbox.org>
pkgname=bash-completion pkgname=bash-completion
pkgver=2.9 pkgver=2.10
pkgrel=0 pkgrel=0
pkgdesc="Command-line tab-completion for bash" pkgdesc="Command-line tab-completion for bash"
options="!check" # 7 Tests fail options="!check" # 7 Tests fail
...@@ -13,12 +13,7 @@ depends="bash" ...@@ -13,12 +13,7 @@ depends="bash"
makedepends="autoconf automake bc grep iputils musl-utils procps psmisc sed usbutils" makedepends="autoconf automake bc grep iputils musl-utils procps psmisc sed usbutils"
checkdepends="py3-pexpect py3-pytest" checkdepends="py3-pexpect py3-pytest"
subpackages="$pkgname-doc" subpackages="$pkgname-doc"
source="https://github.com/scop/${pkgname}/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.xz source="https://github.com/scop/bash-completion/releases/download/$pkgver/bash-completion-$pkgver.tar.xz"
01-generalized-containers.patch
02-skip-getconf-test.patch
03-skip-iconv-test.patch
04-fix-ifupdown.patch
05-fix-arp-test.patch"
builddir="$srcdir"/$pkgname-$pkgver builddir="$srcdir"/$pkgname-$pkgver
# Provided with util-linux and networkmanager: # Provided with util-linux and networkmanager:
...@@ -45,18 +40,14 @@ _conflicting=" ...@@ -45,18 +40,14 @@ _conflicting="
prepare() { prepare() {
cd "$builddir" cd "$builddir"
for i in $source; do default_prepare
case $i in
*.patch) msg $i; patch -p1 -i "$srcdir/$i" || return 1;;
esac
done
# ifup/down tests are still failing # ifup/down tests are still failing
rm $builddir/test/t/test_ifdown.py rm $builddir/test/t/test_ifdown.py
rm $builddir/test/t/test_ifup.py rm $builddir/test/t/test_ifup.py
sed -i '/test_ifdown.py \\/d' $builddir/test/t/Makefile.am || return 1; sed -i '/test_ifdown.py \\/d' $builddir/test/t/Makefile.am
sed -i '/test_ifup.py \\/d' $builddir/test/t/Makefile.am || return 1; sed -i '/test_ifup.py \\/d' $builddir/test/t/Makefile.am
autoreconf -fiv || return 1; autoreconf -fiv
} }
build() { build() {
...@@ -74,7 +65,7 @@ build() { ...@@ -74,7 +65,7 @@ build() {
check() { check() {
cd "$builddir" cd "$builddir"
mkdir ./bin mkdir ./bin
ln -sf "$(which pytest-3)" ./bin/pytest ln -sf "$(command -v pytest-3)" ./bin/pytest
export PATH="${PATH}:$PWD/bin" export PATH="${PATH}:$PWD/bin"
make check make check
} }
...@@ -93,9 +84,4 @@ package() { ...@@ -93,9 +84,4 @@ package() {
done done
} }
sha512sums="e864091196d670699bdb2af3fc40464788e79c932fa564afa7ba34a637aa1583db7dbceab0e7ba6718fac99e9fd2dfb03d1ee51d7cf279d925ad63f60401d7d5 bash-completion-2.9.tar.xz sha512sums="d434e0e48b25328e8c6b43ed64e58f56459186434754ee972795edd031ce1864038b53926b218fe06e5b3882682db4dec5101b3124362c0137101d3fa6d87cd7 bash-completion-2.10.tar.xz"
1f7466e7bbc2eea30e75e3dd10819289f1586c2ba9b2a2f5199e4e8af99ed4ec081638e8c8efc6aefd8a8336cb67527b4152c2cd89620b173dfed798268c686c 01-generalized-containers.patch
540cdc655911912475a48a191061f7a94a550d94ac750b601dc8a21e72ef469890b6416cee8fcb677cdb51b21b6f54742a0dc954b0cea5bc4d0b4adf8af86ec6 02-skip-getconf-test.patch
a8d145f8b38ed9422426696e2204167e6dacfb03dec09dc7c23e83c9a6295524a9f93be6ac10e0e4a5ca079965dfe542bca11aae392248c7e21c6855a4543d64 03-skip-iconv-test.patch
97de46d137b6f6b54891a13f8308928854e1bdc33e35808e1aa760514c9d3dbb87bcf2a08db72dc941e68bc3af7a106a81e7159e452823dc07f874d3b8e27b77 04-fix-ifupdown.patch
262f7b6c654d8be95930c6230b4b9d1add344ef1a60f0c6c81cf46bb104dab3814a96e0fb92e99449cbd086a53ec1169e1db21b45436007710952004895e7a3f 05-fix-arp-test.patch"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment