1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
BW02: <feature> requires at least BATS_VERSION=<version>. Use `bats_require_minimum_version <version>` to fix this message.
===========================================================================================================================
Using a feature that is only available starting with a certain version can be a problem when your tests also run on older versions of Bats.
In most cases, running this code in older versions will generate an error due to a missing command.
However, in cases like `run`'s where old version simply take all parameters as command to execute, the failure can be silent.
How to fix BW02
---------------
When you encounter this warning, you can simply guard your code with `bats_require_minimum_version <version>` as the message says.
For example, consider the following code:
.. code-block:: bash
@test test {
bats_require_minimum_version 1.5.0
# pre 1.5.0 the flag --separate-stderr would be interpreted as command to run
run --separate-stderr some-command
[ $output = "blablabla" ]
}
The call to `bats_require_minimum_version` can be put anywhere before the warning generating command, even in `setup`, `setup_file`, or even outside any function.
This can be used to give fine control over the version dependencies:
.. code-block:: bash
@test test {
bats_require_minimum_version 1.5.0
# pre 1.5.0 the flag --separate-stderr would be interpreted as command to run
run --separate-stderr some-command
[ $output = "blablabla" ]
}
@test test2 {
run some-other-command # no problem executing on earlier version
}
If the above code is executed on a system with a `BATS_VERSION` pre 1.5.0, the first test will fail on `bats_require_minimum_version 1.5.0`.
Instances:
----------
- run's non command parameters like `--keep-empty-lines` are only available since 1.5.0
|