Skip to content

Commit 17a69d2

Browse files
committed
Add documentation improvements for v1.1.0 release
1 parent ecd2d81 commit 17a69d2

File tree

3 files changed

+65
-5
lines changed

3 files changed

+65
-5
lines changed

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,46 @@ your scripts directory. Run `./go help plugins` for more information.
342342

343343
You can import optional Bash library code from the core framework, third-party
344344
plugins, or your own project's scripts directory by sourcing the
345-
`$_GO_USE_MODULES` script. For example, to import the core logging utilities:
345+
`_GO_USE_MODULES` script. For example, to import the core logging utilities:
346346

347347
```bash
348-
. $_GO_USE_MODULES 'log'
348+
. "$_GO_USE_MODULES" 'log'
349349
```
350350

351351
Run `./go help modules` and `./go modules --help` for more information.
352352

353+
#### Logging
354+
355+
The core library `log` module provides functions for standard logging
356+
facilities. For example:
357+
358+
```bash
359+
@go.log INFO Hello, World!
360+
@go.log ERROR Goodbye, World!
361+
```
362+
363+
For more information, run `./go modules --help log`.
364+
365+
#### Bats test assertions and helpers
366+
367+
The assertions and helpers from the test suite have been extracted into the
368+
`lib/bats/assertions` and `lib/bats/helpers` libraries. While these are not
369+
modules you can import with `_GO_USE_MODULES`, they are completely independent
370+
of the rest of the core framework and you may source them in your own Bats
371+
tests. (Whether or not these will ever become a separate library remains an open
372+
question.)
373+
374+
Read the comments from each file for more information.
375+
376+
#### `kcov-ubuntu` module for test coverage on Linux
377+
378+
The `kcov-ubuntu` module provides the `run_kcov` function that will download and
379+
compile [kcov](https://github.com/SimonKagstrom/kcov), then run `kcov` with the
380+
original `./go` command line arguments to collect test coverage. Only available
381+
on Ubuntu Linux for now, hence the name. Run `./go modules --help kcov-ubuntu`
382+
for more information and see `scripts/test` for an example of how it may be
383+
used.
384+
353385
### Feedback and contributions
354386

355387
Feel free to [comment on or file a new GitHub

lib/bats/assertions

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,23 @@
2424
# fail "output should not match: '$pattern'"
2525
# fi
2626
#
27-
# Alternatively, write your own assertion functions starting with:
27+
# Alternatively, write your own assertion function with the following as the
28+
# first line:
2829
#
2930
# set +o functrace
3031
#
31-
# and then make sure every return path calls:
32+
# and then make sure every return path ends with the following (possibly
33+
# followed by a `return` statement, if not at the end of the function):
3234
#
3335
# return_from_bats_assertion "$return_status" "$BASH_SOURCE"
3436
#
3537
# You may wish to wrap `return_from_bats_assertion` in a local helper function
3638
# to avoid having to specify `$BASH_SOURCE` everywhere.
3739
#
40+
# Also note that if your assertion function calls other assertion functions, you
41+
# should call `set +o functrace` after every one of them. See the implementation
42+
# of `assert_lines_equal` for an example.
43+
#
3844
# The assertions borrow inspiration from rbenv/test/test_helper.bash.
3945

4046
# Unconditionally returns a failing status

lib/log

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,25 @@
2121
# @go.setup_project
2222
# Runs the project's 'setup' script and logs the result
2323
#
24-
# See the function comments for each of the above for further information.
24+
# The log level labels are formatted when output to a terminal, and formatting
25+
# can be forced when writing to a pipe or file by setting `_GO_LOG_FORMATTING`.
26+
#
27+
# `@go.log ERROR` will return an error code, so you may use it in conditional
28+
# statements. `@go.log FATAL` will exit the process.
29+
#
30+
# You can pass entire commands to the `@go.log_command` function, which will
31+
# provide log messages upon startup and completion. Upon error, it will log the
32+
# status and return an error code, so you may use it in conditional statements.
33+
# Wrapping blocks of `@go.log_command` invocations in
34+
# `@go.critical_section_begin` and `@go.critical_section_end` will cause any
35+
# errors to log `FATAL`. Setting `_GO_DRY_RUN` will log the commands without
36+
# executing them.
37+
#
38+
# The `@go.setup_project` function provides a convenient wrapper for running
39+
# first-time project setup scripts. It logs the start and finish of the setup
40+
# script, and provides helpful hints on running the `./go` script upon success.
41+
#
42+
# See the function and variable comments from this file for further information.
2543

2644
# Set this if you want to force terminal-formatted output from @go.log.
2745
#
@@ -229,6 +247,10 @@ declare __GO_CRITICAL_SECTION=0
229247
# the critical section flag will be shared between parent and child Bash
230248
# scripts.
231249
#
250+
# Globals:
251+
# _GO_DRY_RUN: Will log commands without running them
252+
# __GO_CRITICAL_SECTION: Will log FATAL on error
253+
#
232254
# Arguments:
233255
# $@: The command and its arguments to log and execute
234256
@go.log_command() {

0 commit comments

Comments
 (0)