Skip to content

Conversation

@mbland
Copy link
Owner

@mbland mbland commented Jan 14, 2017

During the course of extracting and testing tests/log/helpers.bash into lib/testing/log, I started updating @go.strip_formatting_codes such that it will expand all codes the original string before stripping them.

After that, I thought it would be nice to do away with the requirement that the caller declare predetermined __go_* variables before using these functions, and switch to implementations that rely on printf -v such that the caller can pass in the name of the variable it will use to store the result. Hence I imported the lib/validation module to validate the result variable name for each function.

Then I learned after observing test failures under Bash 3.2.57(1)-release that Bash versions before 4.1 can't use printf -v to assign to subscripted array variables. I developed the new @go.array_printf function as a portable workaround, which relies on @go.split from lib/strings under the hood.

Now handles both expanded and unexpanded formatting codes.
Allowing the user to specify the name of the output variable makes for a
better interface.
Makes it easier to add to programs under test without requiring that
they source `lib/bats/helpers`.
Turns out Bash versions earlier than 4.1 can't use `printf -v` to print
to a subscripted array variable.
Seems more natural to pass the items as positional parameters.
@mbland mbland added this to the v1.3.0 milestone Jan 14, 2017
@mbland mbland self-assigned this Jan 14, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 94.705% when pulling 5d2158f on format-module into d25e5d3 on master.

@mbland mbland merged commit d15a052 into master Jan 14, 2017
@mbland mbland deleted the format-module branch January 14, 2017 23:07
mbland added a commit that referenced this pull request Jan 15, 2017
Meant to say ASCII Unit Separator in #107, not Record Separator.
mbland added a commit that referenced this pull request Jan 15, 2017
After #107, in which I decided to use the ASCII Unit Separator ($'\x1f')
to delimit array elements for `@go.array_printf` because doing so with
NUL ($'\0') wasn't working, it seemed a good idea to switch the
`_GO_CMD_NAME` and `_GO_CMD_ARGV` export mechanism to use the Unit
Separator as well.
mbland added a commit that referenced this pull request Jan 15, 2017
The updates to `lib/format` from #107 make this function much shorter.
Also, the logic to check the file descriptors was sort of confused and
not really doing anything, at least not anything helpful, since the
decision to print or strip formatting codes is now made per log level
file descriptor in `@go.log`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants