An experimental test library for bash. Alternatively, a testing ground for me to push the limits of convoluted bash scripting.
bin
contains thebang
entrypointexamples
contain code demonstrating the usage of banglib
contains the modules that comprise bang's core functionalityexports
contains modules defining functions that will be exposed to test code
privatebin
contains internal entrypoints that are used to isolate test executions
There are two kinds of files containing bash code: executables and modules.
-
Executables are entrypoints that are intended to be called directly.
- Executables must never be sourced.
- Executables must contain as little code as possible. They should only perform some basic setup and then call out to a module function.
- Executables names must not include an extension. (e.g. it's
bang
, notbang.sh
)
-
Modules define the code that does the work.
- Modules must never be called directly.
- Modules must never have side effects until they are invoked.
- Module filenames must end with
.sh
.
- Each module's name should be one short word (e.g.
assert
,err
). - To prevent collisions, all global names must be namedspaced.
- Module-scope variables must be all-caps and prefixed with
_BANG_
followed by an underscore-delimited list of module names.- Thus, if we want to declare a variable
VAR
in a module file atlib/foo/bar.sh
, the actual variable name should be_BANG_FOO_BAR_VAR
.
- Thus, if we want to declare a variable
- Function names must be prefixed with
bang::
followed by a list of module names delimited by::
.- Thus, if we want to declare a function
func
inlib/foo/bar.sh
, our function must be namedbang::foo::bar::func
.
- Thus, if we want to declare a function
- Module-scope variables must be all-caps and prefixed with