The bash-completion package contains an automated test suite. Running the tests should help verifying that bash-completion works as expected. The tests are also very helpful in uncovering software regressions at an early stage.
The test suite is written in Python, using pytest and pexpect.
For the Python part, all of it is checked and formatted using Ruff.
Installing dependencies should be easy using your local package manager or
pip
. Python 3.6 or newer is required, and the rest of the Python package
dependencies are specified in the test/requirements.txt
file. If using pip
,
this file can be fed directly to it, e.g. like:
python3 -m pip install -r test/requirements.txt
On Debian/Ubuntu you can use apt-get
:
sudo apt-get install python3-pytest python3-pexpect
This should also install the necessary dependencies. Only Debian testing (buster) and Ubuntu 18.10 (cosmic) and later have an appropriate version of pytest in the repositories.
On Fedora and RHEL/CentOS (with EPEL) you can try yum
or dnf
:
sudo yum install python3-pytest python3-pexpect
This should also install the necessary dependencies. At time of writing, only Fedora 29 comes with recent enough pytest.
Tests are in the t/
subdirectory, with t/test_*.py
being completion
tests, and t/unit/test_unit_*.py
unit tests.
Tests are run by calling pytest
on the desired test directories or
individual files, for example in the project root directory:
pytest test/t
See test/docker/entrypoint.sh
for how and what we run and test in CI.
The test suite standard uses bash
as found in $PATH
. Export the
bashcomp_bash
environment variable with a path to another bash executable if
you want to test against something else.
You can run cd test && ./generate cmd
to add a test for the cmd
command. Additional arguments will be passed to the first generated test case.
This will add the test/t/test_cmd.py
file with a very basic test, and add it
to test/t/Makefile.am
. Add additional tests to the generated file.