diff options
author | Gabriel F. T. Gomes <gabriel@inconstante.net.br> | 2020-08-03 18:43:13 -0300 |
---|---|---|
committer | Gabriel F. T. Gomes <gabriel@inconstante.net.br> | 2020-08-03 18:43:13 -0300 |
commit | 95623d39d6029ba78ec96ad5ea08e9ac12629b91 (patch) | |
tree | ea0fe36eb5e6f40e0a1f765d44c4b0c0b2bfb089 /doc | |
parent | 019f3cc463db63abc6460f97deb488deec43840b (diff) | |
download | bash-completion-95623d39d6029ba78ec96ad5ea08e9ac12629b91.tar.gz |
New upstream version 2.11upstream/2.11upstream
Diffstat (limited to 'doc')
-rw-r--r-- | doc/styleguide.txt | 25 | ||||
-rw-r--r-- | doc/testing.txt | 61 |
2 files changed, 35 insertions, 51 deletions
diff --git a/doc/styleguide.txt b/doc/styleguide.txt index 31ad4469..2251e773 100644 --- a/doc/styleguide.txt +++ b/doc/styleguide.txt @@ -61,7 +61,7 @@ need that kind of processing (e.g. file and command names). The _filedir and _filedir_xspec helpers do this automatically whenever they return some completions. -[[ $COMPREPLY == *= ]] && compopt -o nospace +[[ ${COMPREPLY-} == *= ]] && compopt -o nospace ------------------------------------------------ The above is functionally a shorthand for: @@ -95,6 +95,29 @@ explicitly handled (non-completed) in the $prev handling block because --foo=bar options can often be written without the equals sign, and in that case the long option splitting does not occur. +Use arithmetic evaluation +------------------------- + +When dealing with numeric data, take advantage of arithmetic evaluation. +In essence, use (( ... )) whenever it can replace [[ ... ]] because the +syntax is more readable; no need for $-prefixes, numeric comparison etc +operators are more familiar and easier on the eye. + +Array subscript access +---------------------- + +Array subscripts are arithmetic expressions, take advantage of that. +E.g. write ${foo[bar]}, not ${foo[$bar]}, and similarly ${foo[bar+1]} +vs ${foo[((bar+1))]} or ${foo[$((bar+1))]}, ${foo[--i]} vs ${foo[((--i))]}. + +Loop variable names +------------------- + +Use i, j, k for loop-local indices; n and m for lengths; some other descriptive +name typically based on array name but in singular when looping over actual +values. If an index or value is to be accessed later on instead of being just +locally for looping, use a more descriptive and specific name for it. + ///////////////////////////////////////// case/esac vs if --------------- diff --git a/doc/testing.txt b/doc/testing.txt index c3a1f00a..3ec7c97f 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -7,14 +7,8 @@ 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 original, "legacy" bash-completion test suite is written on top of the -http://www.gnu.org/software/dejagnu/[DejaGnu] testing framework. DejaGnu is -written in http://expect.nist.gov[Expect], which in turn uses -http://tcl.sourceforge.net[Tcl] -- Tool command language. - -Most of the test framework has been ported over to use -https://pytest.org/[pytest] and https://pexpect.readthedocs.io/[pexpect]. -Eventually, all of it should be ported. +The test suite is written in Python, using https://pytest.org/[pytest] +and https://pexpect.readthedocs.io/[pexpect]. Coding Style Guide @@ -22,10 +16,7 @@ Coding Style Guide For the Python part, all of it is formatted using https://github.com/ambv/black[Black], and we also run -http://flake8.pycqa.org/[Flake8] on it. - -The legacy test suite tries to adhere to this -http://wiki.tcl.tk/708[Tcl Style Guide]. +https://flake8.pycqa.org/[Flake8] on it. Installing dependencies @@ -45,7 +36,7 @@ Debian/Ubuntu On Debian/Ubuntu you can use `apt-get`: ------------- -sudo apt-get install python3-pytest python3-pexpect dejagnu tcllib +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 @@ -56,7 +47,7 @@ Fedora/RHEL/CentOS On Fedora and RHEL/CentOS (with EPEL) you can try `yum` or `dnf`: ------------- -sudo yum install python3-pytest python3-pexpect dejagnu tcllib +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. @@ -66,49 +57,19 @@ Fedora 29 comes with recent enough pytest. Structure --------- -Pytest tests are in the `t/` subdirectory, with `t/test_\*.py` being -completion tests, and `t/unit/test_unit_\*.py` unit tests. - -Legacy tests are grouped into different areas, called _tool_ in DejaGnu: - -*completion*:: - Functional tests per completion. -*install*:: - Functional tests for installation and caching of the main bash-completion - package. -*unit*:: - Unit tests for bash-completion helper functions. +Tests are in the `t/` subdirectory, with `t/test_\*.py` being completion +tests, and `t/unit/test_unit_\*.py` unit tests. Running the tests ----------------- -Python based tests are run by calling `pytest` on the desired test directories -or individual files, for example in the project root directory: +Tests are run by calling `pytest` on the desired test directories or +individual files, for example in the project root directory: ----------------------- pytest test/t ----------------------- -Legacy tests are run by calling `runtest` command in the test directory: ------------------------ -runtest --outdir log --tool completion -runtest --outdir log --tool install -runtest --outdir log --tool unit ------------------------ -The commands above are already wrapped up in shell scripts within the `test` -directory: ------------------------ -./runCompletion -./runInstall -./runUnit ------------------------ -To run a particular test, specify file name of your test as an argument to -`runCompletion` script: ------------------------ -./runCompletion ssh.exp ------------------------ -That will run `test/completion/ssh.exp`. - See `test/docker/docker-script.sh` for how and what we run and test in CI. @@ -142,10 +103,10 @@ Naming conventions Test suite or testsuite ^^^^^^^^^^^^^^^^^^^^^^^ The primary Wikipedia page is called -http://en.wikipedia.org/wiki/Test_suite[test suite] and not testsuite, so +https://en.wikipedia.org/wiki/Test_suite[test suite] and not testsuite, so that's what this document sticks to. script/generate ^^^^^^^^^^^^^^^ The name and location of this code generation script come from Ruby on Rails' -http://en.wikibooks.org/wiki/Ruby_on_Rails/Tools/Generators[script/generate]. +https://en.wikibooks.org/wiki/Ruby_on_Rails/Tools/Generators[script/generate]. |