bash-it/test
Alex Thiessen 9f3889c284
test: Make `rsync` optional
For bulk copying, `rsync` is used in test code, which is rather fast and
capable of saving needless write operations. The downside is that tests
fail when the tool is missing, which is the case with most minimal Linux
setups (e.g. containers or even Gnome installations of Debian).

Provide an alternative way for sufficiently fast copying by means of
`find -exec cp`. Measured total test time penalty is less than 0.5%.
Downside of needless write operations remains in case of fallback.
2020-05-11 02:30:10 +02:00
..
bash_it test: Make `rsync` optional 2020-05-11 02:30:10 +02:00
completion Refactored test setup code 2020-04-21 08:25:40 +02:00
fixtures/bash_it Test cases for loading from global directory 2017-09-17 21:05:59 +02:00
install Refactored test setup code 2020-04-21 08:25:40 +02:00
lib Fix search plugin tests 2020-05-02 14:19:15 +02:00
plugins Refactored test setup code 2020-04-21 08:25:40 +02:00
themes Merge pull request #1395 from zhao-li/toggle-able_commit_count 2019-09-02 08:45:19 +02:00
README.md Updated test readme 2020-04-22 11:19:18 +02:00
run Updated GNU parallel detection 2020-04-21 08:25:40 +02:00
test_helper.bash test: Make `rsync` optional 2020-05-11 02:30:10 +02:00

README.md

Testing with Bats

Overview

The Bash-it unit tests leverage the Bats unit test framework for Bash. There is no need to install Bats explicitly, the test run script will automatically download and install Bats and its dependencies.

When making changes to Bash-it, the tests are automatically executed in a test build environment on Travis CI.

Test Execution

To execute the unit tests, please run the run script:

# If you are in the `test` directory:
./run

# If you are in the root `.bash_it` directory:
test/run

The run script will automatically install if it is not already present, and will then run all tests found under the test directory, including subdirectories.

To run only a subset of the tests, you can provide the name of the test subdirectory that you want to run, e.g. like this for the tests in the test/themes directory:

# If you are in the root `.bash_it` directory:
test/run test/themes

By default, the tests run in single-threaded mode. If you want to speed up the test execution, you can install the GNU parallel tool, which is supported by Bats. When using parallel, the test/run script will use a number of threads in parallel, depending on the available CPU cores of your system. This can speed up test execution significantly.

Writing Tests

When adding or modifying tests, please stick to the format and conventions of the existing test cases. The test_helper.bash script provides a couple of reusable helper functions that you should use when writing a test case, for example for setting up an isolated test environment.