Skip to content

Comments

remove handwritten bash/zsh shell completions, fixes #9178#9356

Merged
ThomasWaldmann merged 4 commits intoborgbackup:masterfrom
mr-raj12:remove-handwritten-shell-completions
Feb 17, 2026
Merged

remove handwritten bash/zsh shell completions, fixes #9178#9356
ThomasWaldmann merged 4 commits intoborgbackup:masterfrom
mr-raj12:remove-handwritten-shell-completions

Conversation

@mr-raj12
Copy link
Contributor

Description

Remove the handwritten bash and zsh shell completion scripts now that auto-generated completions via borg completion bash/zsh (powered by shtab, #9172) are tested and working.

Fish completions are kept - shtab does not yet support fish.

Fixes #9178

Changes

File Change
scripts/shell_completions/bash/borg Deleted (223 lines) - replaced by borg completion bash
scripts/shell_completions/zsh/_borg Deleted (1586 lines) - replaced by borg completion zsh
src/borg/testsuite/archiver/completion_cmd_test.py Expanded from 2 to 29 tests covering auto-generated completions
src/borg/testsuite/shell_completions_test.py Removed bash/zsh file tests, kept fish
docs/changes.rst Added changelog entry

Test coverage (29 tests)

  • All 10 dynamic helper functions (bash + zsh)
  • Bash/zsh syntax validation via bash -n / zsh -n
  • All 34 subcommands present in output
  • 13 common options, 13 subcommand-specific option sets
  • Preamble static choices: sort keys, files-cache-mode, compression specs, chunker params, relative time, file sizes
  • Preamble infrastructure: COMP_WORDBREAKS fix, borg repo-list usage, compadd, registration
  • Output sanity checks (minimum size/lines)

Checklist

  • Code formatted with black
  • Changelog entry added (docs/changes.rst)
  • Tests added for new/changed functionality
  • Commit references the fixed issue

@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.44%. Comparing base (7189954) to head (ce5b4ab).
⚠️ Report is 24 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9356      +/-   ##
==========================================
+ Coverage   76.03%   76.44%   +0.40%     
==========================================
  Files          85       85              
  Lines       14744    14800      +56     
  Branches     2194     2213      +19     
==========================================
+ Hits        11211    11314     +103     
+ Misses       2856     2808      -48     
- Partials      677      678       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mr-raj12 mr-raj12 force-pushed the remove-handwritten-shell-completions branch from 9ebf1a9 to 895a048 Compare February 16, 2026 16:16
Copy link
Member

@ThomasWaldmann ThomasWaldmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR.

the problem with these tests is that many of them do not really test if the completions are working, but just check "SEARCHTERM in SCRIPT".

also, that list with all commands and options will get out of sync with the code pretty soon.

so i'ld suggest to remove all the not that meaningful and hard to maintain tests. guess the script size test and the "does the shell load it" are short and meaningful.

tests that test the borg-special features (like archive id completion) would be good.

we could also check how much tests the shtab project has, so we do not test what they already have tested.

the idea with the ticket you addressed was that users actually test and use the completions and make sure they actually work good enough, but these tests can't do that.

Remove the handwritten bash and zsh shell completion scripts now that
auto-generated completions via borg completion bash/zsh (powered by
shtab, borgbackup#9172) are tested and working. Fish completions are kept as
shtab does not yet support fish.

Replace string-matching tests with focused behavior tests: script size
sanity, shell syntax validation (bash -n / zsh -n), and tests that
invoke the custom preamble functions in bash (sortby key dedup,
filescachemode mutual exclusivity, archive name and aid: prefix
completion against a real repository).
@mr-raj12 mr-raj12 force-pushed the remove-handwritten-shell-completions branch from 4c07faa to 09d2dba Compare February 16, 2026 20:26
- remove redundant f.flush() calls
- use pytest.mark.skipif decorators instead of inline pytest.skip()
- add _zsh_available() to complement _bash_available()
- extract _check_shell_syntax() helper to reduce duplication
Copy link
Member

@ThomasWaldmann ThomasWaldmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, much more meaningful tests now.

Replace separate _bash_available() and _zsh_available() with a single
lru_cache-decorated cmd_available() function, per review feedback.
The archive name/aid completion tests invoke borg via bash, which
exceeds 30s on Haiku OS VMs. Increase timeout to 120s.
@ThomasWaldmann ThomasWaldmann merged commit 1c0bf36 into borgbackup:master Feb 17, 2026
19 checks passed
@ThomasWaldmann
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

remove handwritten shell completions

2 participants