You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This release contains some major improvements, including an O(5.3-18x) Bats test performance improvement, the new `lib/bats-main` and other testing library updates, the `go-template` bootstrap script, `_GO_STANDALONE` mode, improved `_GO_USE_MODULES` semantics, the new `get` and `new` commands, npm-like plugin semantics, and more.
3
+
This is a minor update to add the `lib/prompt` and `lib/existence` modules that import functionality from the first draft of the [mbland/certbot-webroot-setup][cws] project.
Insight into how Bats captures stack trace information led to several rounds of performance optimizations to remove subshells and other child processes that resulted in a massive improvement. All the times below were measured on a MacBook Pro with a 2.9GHz Intel Core i5 CPU and 8GB 1867MHz DDR3 RAM.
35
-
36
-
The first round of improvements, to the go-script-bash framework itself, took the existing test suite running under Bash 3.2.57(1)-release from macOS 10.12 from O(7-8m) down to O(3m). As part of this process, the `set "$BATS_ASSERTION_DISABLE_SHELL_OPTIONS"` and `return_from_bats_assertion` mechanisms previously from `lib/bats/assertions` have been generalized as `set "$DISABLE_BATS_SHELL_OPTIONS` and `restore_bats_shell_options` in the new `lib/bats/helper-function` module.
37
-
38
-
After the first round of optimizations to the Bats framework itself, this time came down to O(1m25s). After the second round of Bats optimizations, the time came down to O(1m19s), for a total approximate speedup between 5.3x and 6x.
39
-
40
-
On Windows, the improvement is even more dramatic, given [forking new processes on Windows is apparently over 50x more expensive than on UNIX][win-fork]. Running under VMWare Fusion (versions 8.5.3 to 8.5.5), the same go-script-bash test suite went from O(50m-60m) down to O(20+m) after the go-script-bash optimizations, down to O(3m40s-6m20s) after the first round of Bats optimizations, and down to O(3m21s-5m25s) after the second round of Bats optimizations, for a total approximate speedup between 9x and 18x. (Possibly more, but I don't want to spend the time getting the old numbers for an exact calculation!)
*[The `optimized-20170205` tag comment from mbland/bats](https://github.com/mbland/bats/releases/tag/optimized-20170205)
50
-
*[The `optimized-20170317` tag comment from mbland/bats](https://github.com/mbland/bats/releases/tag/optimized-20170317)
51
-
*[sstephenson/bats#210: Fix macOS/Bash 3.2 breakage; eliminate subshells from exec-test, preprocess](https://github.com/sstephenson/bats/pull/210)
52
-
*[mbland's comment on sstephenson/bats#150: Call for Maintainers](https://github.com/sstephenson/bats/issues/150#issuecomment-280382449)
53
-
54
-
### `lib/bats-main` test script library
55
-
56
-
To make it easier to write `./go test` commands with the same interface as that of the core library's `./go test` command—including test coverage reports via [kcov][] and [Coveralls][]—the `lib/bats-main` library has been extracted from the core library's `./go test` script. It contains many user-overrideable variables, but basic usage is straightforward. See the header comments from [lib/bats-main][] and the implementation of [`./go test`][] for details.
Also, Bats is no longer integrated into the repository as a submodule. Instead, `@go.bats_main` calls `@go.bats_clone` to create a shallow clone of a Bats repository, configured via the `_GO_BATS_DIR`, `_GO_BATS_URL`, and `_GO_BATS_VERSION` variables. (`@go.bats_clone` uses the new `@go get` command, described below, to create the clone.) By default, these variables are configured to clone [the optimized Bats from `mbland/bats`][mbland/bats opt].
In addition to the test/Bats optimizations and the new `lib/bats-main` library, other new test library features include:
70
-
71
-
* A completely new [lib/testing/stubbing][] library that uses the new `_GO_INJECT_SCRIPT_PATH` and `_GO_INJECT_MODULE_PATH` mechanism to stub core library scripts and modules, rather than the much riskier former implementation. ([#118][], [#121][]) See the sections below on "Improved command script search and `_GO_USE_MODULES` semantics" and "npm-like plugin semantics", as well as `./go help commands` and `./go modules -h` for further details.
72
-
* The `@go.test_compgen` helper function from [lib/testing/environment][] makes it easier to generate expected tab completion results, and fails loudly to prevent test setup errors.
73
-
*`stub_program_in_path` from [lib/bats/helpers][] now works for testing in-process functions (as opposed to running scripts), and `restore_program_in_path` has been added to help with cleanup and to guard against errors when stubbed program names are mistyped.
74
-
* See the previous section on test suite optimization for information about the new [lib/bats/helper-function][] library, which contains a mechanism for making Bats test helper functions run as quickly as possible and for pinpointing assertion failures. It works by temporarily disabling function tracing and `DEBUG` traps set by Bats to collect and display stack trace information.
The new `go-template` file provides the boilerplate for a standard project `./go` script. Basically, copying this script into your project and running it is all you need to do to get started using the go-script-bash framework right away, as it will take care of cloning the `go-script-bash` framework into your project without the need to add it as a Git submodule. It contains several configuration variables, and any other project or application logic may be added to it as needed.
86
-
87
-
See the ["How to use this framework" section of the README][go-howto] and the comments from [go-template][] for details.
The `_GO_STANDALONE` variable, when set, enables "Standalone" mode, whereby a `./go` script acts as an arbitrary application program rather than a project management script. In fact, a standalone application program can have its own project management `./go` script in the same repository.
95
-
96
-
See the ["Standalone mode" section of the README][standalone mode] for more
### Improved command script search and `_GO_USE_MODULES` semantics
102
-
103
-
The command script search and `. "$_GO_USE_MODULES"` library module importation mechanism now implement the following precedence rules:
104
-
105
-
*`_GO_INJECT_SEARCH_PATH` and `_GO_INJECT_MODULE_PATH` for stubs injected during testing
106
-
*`_GO_CORE_DIR/libexec` and `_GO_CORE_DIR/lib` for core library command scripts
107
-
and modules
108
-
*`_GO_SCRIPTS_DIR` and `_GO_SCRIPTS_DIR/lib` for command scripts and project-internal modules
109
-
*`_GO_ROOTDIR/lib` for publicly-exported modules (if the project is a go-script-bash plugin)
110
-
*`_GO_SCRIPTS_DIR/plugins/*/{bin,lib}` for command scripts and library modules from installed plugins
111
-
* Parent plugin dirs up to `_GO_PLUGINS_DIR/*/{bin,lib}` for plugin command scripts and library modules
112
-
113
-
This reflects a more natural, predictable search order, and the `. "$_GO_USE_MODULES"` mechanism now pinpoints potential module import collisions with a verbose warning message. See `./go help commands` and `./go modules -h` for more details.
114
-
115
-
### New commands: `get` and `new`
116
-
117
-
The `./go get file` command makes it easy to fetch a single file over the network using `curl`, `wget`, or FreeBSD's `fetch`, and `./go get git-repo` creates a shallow clone of a Git repository (notably used by the `lib/bats-main` and `lib/kcov-ubuntu` libraries).
118
-
119
-
The `./go new` command makes it easy to create a new command script (`--command`), internal library module (`--internal`), public library module (`--public`), or Bats test file (`--test`), with minimal boilerplate. It can also create any other arbitrary file via the `--type` option, so that users can reuse the command to generate their own boilerplate files and benefit from the same safety checks, error reporting, and automatic `EDITOR` opening.
120
-
121
-
See `./go help get` and `./go help new` for more information.
30
+
All of the issues and pull requests for this release are visible in the [v1.5.0 milestone][].
The pull requests associated with [#120][] implement a new plugin protocol very similar to [the `node_modules` search mechanism implemented by npm][n_m]. The new `@go.search_plugins` function from `go-core.bash` implements this algorithm, and is used by `. "$_GO_USE_MODULES"` and the logic that builds the command script search paths. See `./go help plugins` and the comments for `@go.search_plugins` for more details.
The new `lib/prompt` module contains several new user input prompt functions. Also, `@go.select_option` has been moved from `go-core.bash` to the `lib/prompt` module. The new `./go demo-core prompt` command demonstrates most of the new user prompt behavior.
129
37
130
-
A forthcoming release will add documentation and tooling to make it easier to work with plugins.
38
+
### `lib/existence` module
131
39
132
-
### `@go.select_option`and demo
40
+
The new `lib/existence` module contains convenience functions for checking whether a file or command exists and is accessible on the system, and provides standard error reporting if not.
133
41
134
-
The`@go.select_option` function added to `go-core.bash` in [#141][] makes it easy to write interactive prompts for the user to select an item from a list of options. Run `./go demo-core select-option` to see it in action.
`@go.trim` trims leading and trailing whitespace from strings, and supports the parsing of user input data in functions from the `lib/prompt` module.
137
45
138
-
### Various bug fixes
46
+
### Bug fixes
139
47
140
-
* Tab completion no longer changes the current directory ([#124][]; thanks to [@jeffkole][] for reporting in [#123][]).
141
-
*`@go.printf` no longer adds a newline unconditionally, and no longer harbors a latent infinite loop bug ([#146][], [#149][]).
142
-
*`stub_program_in_path` from [lib/bats/helpers][] now avoids calling the program it's trying to stub by generating the stub _before_ setting `PATH` and calling `hash` ([#168][]).
48
+
Just one this time: `./go new --test` now outputs `load environment` correctly for top-level tests within `_GO_TEST_DIR` ([#171][], [#172][]).
0 commit comments