Page History
...
- Use
"export FOOBAR=val"
instead of "FOOBAR=val; export FOOBAR
" for clarity and simplicity - Use
[[ expr ]]
instead of[ expr ]
, especially since the[[
test understands regular expression matching with the "=~" operator. The easiest way to use it is by putting the RE in a variable and expanding the RE after the operator without quotes. - Use
$((...))
for arithmetic expressions instead ofexpr
- Use "check || action", otherwise if "check && error" is called at the very end of a function or other return it will cause the test to be reported as a failure ("check" will be false, and "error" is not called in that case. Example: [[ "$MDS1_VERSION" -ge $(version_code 2.12.3) ]] || skip "Need MDS version at least 2.12.3"
Test Framework
- Variables
- Names of variables local to current script which are not exported to the environment should be declared with
"local
" and use lowercase letters - Names of global variables or variables that exported to the environment should be uppercase letters
- Names of variables local to current script which are not exported to the environment should be declared with
- Functions
Each functions must have a section describing what it does and explain the list of parameters
No Format # One- or two-line description of this function's purpose # # usage: function_name [--option argument] {required_argument} ... # option: meaning of "option" and its argument # required_argument: meaning of "required_argument" # # expected output and/or return value(s)
- Tests and Libraries
- To avoid clustering a single
test-framework.sh
file, there should be a<test-lib>.sh
file for each test that contains specific functions and variables for that test. - Any functions, variables that global to all tests should be put in
test-framework.sh
- A test file only need to source
test-framework.sh
and necessary<test-lib>.sh
file
- To avoid clustering a single
- Test script layout
Overview
Content Tools