Skip to content

Commit

Permalink
postfix: try to arrange a fake tty so we can tickle the usage message…
Browse files Browse the repository at this point in the history
… out
  • Loading branch information
scop committed May 17, 2020
1 parent 3829fe9 commit 7aea619
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 5 additions & 3 deletions completions/postfix
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ _postfix()
esac

if [[ $cur == -* ]]; then
# TODO: doesn't seem to work; the usage message doesn't get output
# if we try to grep it, it's only output on the console?
COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
COMPREPLY=($(
compgen -W \
'$(_bashcomp_try_faketty "$1" --help 2>&1 | _parse_usage -)' \
-- "$cur"
))
return
fi

Expand Down
16 changes: 13 additions & 3 deletions test/t/test_postfix.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import getpass

import pytest


Expand All @@ -6,7 +8,15 @@ class TestPostfix:
def test_1(self, completion):
assert completion

@pytest.mark.xfail # see TODO in completion
@pytest.mark.complete("postfix -", require_cmd=True)
def test_2(self, completion):
@pytest.mark.xfail(
getpass.getuser() != "root",
reason="Likely outputs usage only for root",
)
@pytest.mark.complete(
"postfix -",
require_cmd=True,
xfail="! type unbuffer &>/dev/null",
sleep_after_tab=2, # postfix is slow to output usage
)
def test_options(self, completion):
assert completion

0 comments on commit 7aea619

Please sign in to comment.