Skip to content

Commit 779f544

Browse files
committed
go-script-bash v1.5.0
1 parent 9319b70 commit 779f544

File tree

4 files changed

+23
-122
lines changed

4 files changed

+23
-122
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ page][go-rel]. The archives for the current release are:
261261

262262
[go-rel]: https://github.com/mbland/go-script-bash/releases
263263

264-
- https://github.com/mbland/go-script-bash/archive/v1.4.0.tar.gz
265-
- https://github.com/mbland/go-script-bash/archive/v1.4.0.zip
264+
- https://github.com/mbland/go-script-bash/archive/v1.5.0.tar.gz
265+
- https://github.com/mbland/go-script-bash/archive/v1.5.0.zip
266266

267267
You can also add this repository to your project as a [Git submodule][git-sub]:
268268

RELEASE.md

Lines changed: 19 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# go-script-bash v1.4.0
1+
# go-script-bash v1.5.0
22

3-
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.
4+
5+
[cws]: https://github.com/mbland/certbot-webroot-setup
46

57
## The `./go` script: a unified development environment interface
68

@@ -25,135 +27,34 @@ This software is made available as [Open Source software][oss-def] under the [IS
2527

2628
## What's new in this release
2729

28-
All of the issues and pull requests for this release are visible in the [v1.4.0 milestone][].
29-
30-
[v1.4.0 milestone]: https://github.com/mbland/go-script-bash/milestone/2?closed=1
31-
32-
### Bats test suite performance improvement
33-
34-
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!)
41-
42-
[win-fork]: https://rufflewind.com/2014-08-23/windows-bash-slow
43-
44-
For more details, see the following artifacts:
45-
46-
* [mbland/go-script-bash#79: Consider refactoring Bats to avoid pipelines, subshells #79](https://github.com/mbland/go-script-bash/issues/79)
47-
* [mbland/go-script-bash#156: Extract `lib/bats/function` from `lib/bats/assertions`](https://github.com/mbland/go-script-bash/issues/156)
48-
* [The `lib/bats/helper-function` library](https://github.com/mbland/go-script-bash/tree/v1.4.0/lib/bats/helper-function)
49-
* [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.
57-
58-
[kcov]: https://github.com/SimonKagstrom/kcov
59-
[coveralls]: https://coveralls.io/
60-
[lib/bats-main]: https://github.com/mbland/go-script-bash/tree/v1.4.0/lib/bats-main
61-
[go-test]: https://github.com/mbland/go-script-bash/tree/v1.4.0/scripts/test
62-
63-
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].
64-
65-
[mbland/bats opt]: https://github.com/mbland/bats/releases/tag/optimized-20170317
66-
67-
### Testing library enhancements
68-
69-
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.
75-
76-
[lib/testing/stubbing]: https://github.com/mbland/go-script-bash/tree/v1.4.0/lib/testing/stubbing
77-
[#118]: https://github.com/mbland/go-script-bash/issues/118
78-
[#121]: https://github.com/mbland/go-script-bash/issues/121
79-
[lib/testing/environment]: https://github.com/mbland/go-script-bash/tree/v1.4.0/lib/testing/environment
80-
[lib/bats/helpers]: https://github.com/mbland/go-script-bash/tree/v1.4.0/lib/bats/helpers
81-
[lib/bats/helper-function]: https://github.com/mbland/go-script-bash/tree/v1.4.0/lib/bats/helper-function
82-
83-
### `go-template` bootstrap script
84-
85-
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.
88-
89-
[go-howto]: https://github.com/mbland/go-script-bash/tree/v1.4.0/README.md#how-to-use-this-framework
90-
[go-template]: https://github.com/mbland/go-script-bash/tree/v1.4.0/go-template
91-
92-
### `_GO_STANDALONE` mode
93-
94-
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
97-
information.
98-
99-
[standalone mode]: https://github.com/mbland/go-script-bash/tree/v1.4.0/README.md#standalone-mode
100-
101-
### 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][].
12231

123-
### npm-like plugin semantics
32+
[v1.5.0 milestone]: https://github.com/mbland/go-script-bash/milestone/3?closed=1
12433

125-
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.
34+
### `lib/prompt` module
12635

127-
[#120]: https://github.com/mbland/go-script-bash/issues/120
128-
[n_m]: https://docs.npmjs.com/files/folders#cycles-conflicts-and-folder-parsimony
36+
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.
12937

130-
A forthcoming release will add documentation and tooling to make it easier to work with plugins.
38+
### `lib/existence` module
13139

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.
13341

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.
42+
### `@go.trim` added to `lib/strings`
13543

136-
[#141]: https://github.com/mbland/go-script-bash/pull/141
44+
`@go.trim` trims leading and trailing whitespace from strings, and supports the parsing of user input data in functions from the `lib/prompt` module.
13745

138-
### Various bug fixes
46+
### Bug fixes
13947

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][]).
14349

144-
[#124]: https://github.com/mbland/go-script-bash/pull/124
145-
[@jeffkole]: https://github.com/jeffkole
146-
[#123]: https://github.com/mbland/go-script-bash/pull/123
147-
[#146]: https://github.com/mbland/go-script-bash/pull/146
148-
[#149]: https://github.com/mbland/go-script-bash/pull/149
149-
[lib/bats/helpers]: https://github.com/mbland/go-script-bash/tree/v1.4.0/lib/bats/helpers
150-
[#168]: https://github.com/mbland/go-script-bash/pull/168
50+
[#171]: https://github.com/mbland/go-script-bash/pull/171
51+
[#172]: https://github.com/mbland/go-script-bash/issues/172
15152

152-
## Changes since v1.3.0
53+
## Changes since v1.4.0
15354

15455
You can see the details of every change by issuing one or more of the following commands after cloning: https://github.com/mbland/go-script-bash
15556

15657
<pre>
157-
$ ./go changes v1.3.0 v1.4.0
158-
$ gitk v1.3.0..HEAD
58+
$ ./go changes v1.4.0 v1.5.0
59+
$ gitk v1.4.0..HEAD
15960
</pre>

go-core.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fi
4040
# This and other variables are exported, so that command scripts written in
4141
# languages other than Bash (and hence run in new processes) can access them.
4242
# See `./go vars` and `./go help vars`.
43-
declare -r -x _GO_CORE_VERSION='v1.4.0'
43+
declare -r -x _GO_CORE_VERSION='v1.5.0'
4444

4545
# The URL of the framework's original source repository
4646
declare -r -x _GO_CORE_URL='https://github.com/mbland/go-script-bash'

go-template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export _GO_STANDALONE=
3535
declare GO_SCRIPTS_DIR="${GO_SCRIPTS_DIR:-scripts}"
3636

3737
# The `GO_SCRIPT_BASH_REPO_URL` tag or branch you wish to use
38-
declare GO_SCRIPT_BASH_VERSION="${GO_SCRIPT_BASH_VERSION:-v1.4.0}"
38+
declare GO_SCRIPT_BASH_VERSION="${GO_SCRIPT_BASH_VERSION:-v1.5.0}"
3939

4040
# The go-script-bash installation directory within your project
4141
declare GO_SCRIPT_BASH_CORE_DIR="${GO_SCRIPT_BASH_CORE_DIR:-${0%/*}/$GO_SCRIPTS_DIR/go-script-bash}"

0 commit comments

Comments
 (0)