-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #924 from scop/feat/load-completion-improvements
feat: load completion improvements
- Loading branch information
Showing
16 changed files
with
175 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
test/fixtures/__load_completion/prefix1/share/bash-completion/completions/cmd1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
echo 'cmd1: sourced from prefix1' | ||
complete -C true "$1" |
1 change: 1 addition & 0 deletions
1
test/fixtures/__load_completion/prefix1/share/bash-completion/completions/cmd2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
echo 'cmd2: sourced from prefix1' | ||
complete -C true "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
echo 'cmd1: sourced from userdir1' | ||
complete -C true "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
echo 'cmd2: sourced from userdir2' | ||
complete -C true "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import pytest | ||
|
||
from conftest import assert_bash_exec | ||
|
||
|
||
@pytest.mark.bashcomp( | ||
cmd=None, cwd="shared", ignore_env=r"^\+declare -f __tester$" | ||
) | ||
class TestUnitAbsPath: | ||
@pytest.fixture | ||
def functions(self, bash): | ||
assert_bash_exec( | ||
bash, | ||
( | ||
"__tester() { " | ||
"local ret; " | ||
'_comp_abspath "$1"; ' | ||
'printf %s "$ret"; ' | ||
"}" | ||
), | ||
) | ||
|
||
def test_non_pollution(self, bash): | ||
"""Test environment non-pollution, detected at teardown.""" | ||
assert_bash_exec( | ||
bash, | ||
"foo() { local ret=; _comp_abspath bar; }; foo; unset -f foo", | ||
want_output=None, | ||
) | ||
|
||
def test_absolute(self, bash, functions): | ||
output = assert_bash_exec( | ||
bash, | ||
"__tester /foo/bar", | ||
want_output=True, | ||
want_newline=False, | ||
) | ||
assert output.strip() == "/foo/bar" | ||
|
||
def test_relative(self, bash, functions): | ||
output = assert_bash_exec( | ||
bash, | ||
"__tester foo/bar", | ||
want_output=True, | ||
want_newline=False, | ||
) | ||
assert output.strip().endswith("/shared/foo/bar") | ||
|
||
def test_cwd(self, bash, functions): | ||
output = assert_bash_exec( | ||
bash, | ||
"__tester ./foo/./bar", | ||
want_output=True, | ||
want_newline=False, | ||
) | ||
assert output.strip().endswith("/shared/foo/bar") | ||
|
||
def test_parent(self, bash, functions): | ||
output = assert_bash_exec( | ||
bash, | ||
"__tester ../shared/foo/bar", | ||
want_output=True, | ||
want_newline=False, | ||
) | ||
assert output.strip().endswith( | ||
"/shared/foo/bar" | ||
) and not output.strip().endswith("../shared/foo/bar") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters