housni/sheldon

For tests, functions should indicate which version of Bash they work with

Opened this issue · 0 comments

During testing, we need test against various versions of Bash (#18).

Some of Sheldons functions will work on older versions of Bash.
For the tests, we should be able to specify which function can be tested against a particular Bash version so that we can even test on older versions of Bash to show users what functions can be used in which version of Bash.

I'm thinking of something along the lines of a comment at the top of a function like:

.
.
.
## @returns Strings in $2 with the glue string, $1.
## @compatibility 3.2+
################################################################################
Sheldon.Util.String.join() {
  local trim
  .
  .
  .

When running tests:

  1. Docker container, which runs the test, should have an env var indicating Bash version
  2. Parse file and match pattern: ^Sheldon.<camel cap dir name>.<camel cap basename>.+\(\)\s\{$
  3. Read lines above until @compatibility [0-9](\.[0-9]{2}[\+<>=]{2})$ is found
  4. If matched version is equal to or greater than Docker's Bash version, run the test. Else skip while notifying user of incompatibility.