mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-26 06:01:49 +00:00
test(cli): strengthen zsh completion regression coverage
This commit is contained in:
parent
8c4bec6155
commit
6d30b4a7e3
2 changed files with 27 additions and 9 deletions
|
|
@ -216,9 +216,9 @@ _hermes() {{
|
||||||
typeset -A opt_args
|
typeset -A opt_args
|
||||||
|
|
||||||
_arguments -C \\
|
_arguments -C \\
|
||||||
"(-h --help)"{{-h,--help}}"[Show help and exit]" \\
|
'(-)'{{-h,--help}}'[Show help and exit]' \\
|
||||||
"(-V --version)"{{-V,--version}}"[Show version and exit]" \\
|
'(-)'{{-V,--version}}'[Show version and exit]' \\
|
||||||
"(-p --profile)"{{-p,--profile}}"[Profile name]:profile:_hermes_profiles" \\
|
'(-)'{{-p,--profile}}'[Profile name]:profile:_hermes_profiles' \\
|
||||||
'1:command:->commands' \\
|
'1:command:->commands' \\
|
||||||
'*::arg:->args'
|
'*::arg:->args'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,14 +145,28 @@ class TestGenerateZsh:
|
||||||
assert 'compdef _hermes hermes' in out
|
assert 'compdef _hermes hermes' in out
|
||||||
assert '_hermes "$@"' not in out
|
assert '_hermes "$@"' not in out
|
||||||
|
|
||||||
def test_uses_valid_zsh_arguments_alias_syntax(self):
|
def test_preserves_valid_zsh_arguments_alias_syntax(self):
|
||||||
out = generate_zsh(_make_parser())
|
out = generate_zsh(_make_parser())
|
||||||
assert '"(-h --help)"{-h,--help}"[Show help and exit]"' in out
|
assert "'(-)'{-h,--help}'[Show help and exit]'" in out
|
||||||
assert '"(-V --version)"{-V,--version}"[Show version and exit]"' in out
|
assert "'(-)'{-V,--version}'[Show version and exit]'" in out
|
||||||
assert '"(-p --profile)"{-p,--profile}"[Profile name]:profile:_hermes_profiles"' in out
|
assert "'(-)'{-p,--profile}'[Profile name]:profile:_hermes_profiles'" in out
|
||||||
assert "'(-h --help){-h,--help}[Show help and exit]'" not in out
|
assert "'(-h --help){-h,--help}[Show help and exit]'" not in out
|
||||||
|
assert '"(-h --help)"{-h,--help}"[Show help and exit]"' not in out
|
||||||
|
|
||||||
def test_valid_zsh_syntax_when_sourced_after_compinit(self):
|
def test_valid_zsh_syntax(self):
|
||||||
|
if not shutil.which("zsh"):
|
||||||
|
pytest.skip("zsh not installed")
|
||||||
|
out = generate_zsh(_make_parser())
|
||||||
|
with tempfile.NamedTemporaryFile(mode="w", suffix=".zsh", delete=False) as f:
|
||||||
|
f.write(out)
|
||||||
|
path = f.name
|
||||||
|
try:
|
||||||
|
result = subprocess.run(["zsh", "-n", path], capture_output=True, text=True)
|
||||||
|
assert result.returncode == 0, result.stderr
|
||||||
|
finally:
|
||||||
|
os.unlink(path)
|
||||||
|
|
||||||
|
def test_zsh_eval_style_source_registers_after_compinit(self):
|
||||||
if not shutil.which("zsh"):
|
if not shutil.which("zsh"):
|
||||||
pytest.skip("zsh not installed")
|
pytest.skip("zsh not installed")
|
||||||
out = generate_zsh(_make_parser())
|
out = generate_zsh(_make_parser())
|
||||||
|
|
@ -161,7 +175,11 @@ class TestGenerateZsh:
|
||||||
path = f.name
|
path = f.name
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["zsh", "-fc", f"autoload -Uz compinit && compinit; source {path}"],
|
[
|
||||||
|
"zsh",
|
||||||
|
"-fc",
|
||||||
|
f"autoload -Uz compinit && compinit -D; source {path}; [[ ${{_comps[hermes]}} == _hermes ]]",
|
||||||
|
],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue