Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/icyflame/gospec
A bash function that prettifies the output of `go test`
https://github.com/icyflame/gospec
bash golang golang-testing
Last synced: 3 days ago
JSON representation
A bash function that prettifies the output of `go test`
- Host: GitHub
- URL: https://github.com/icyflame/gospec
- Owner: icyflame
- License: mit
- Created: 2020-01-25T12:08:24.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-03T06:52:46.000Z (almost 5 years ago)
- Last Synced: 2024-10-31T16:49:36.559Z (about 2 months ago)
- Topics: bash, golang, golang-testing
- Language: Shell
- Homepage:
- Size: 14.6 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gospec
> A bash function that prettifies the output of `go test`
[![asciicast](https://asciinema.org/a/301631.svg)](https://asciinema.org/a/301631)
## Usage
```
$ gospec --help
gospecgospec prettifies the output of `go test`
Usage:
gospec [options] [package] [test-regex]Available options:
[ --no-color | -C ] => do not use colors when printing the summarized output
[ --no-output | -O ] => do not print output for failing tests
[ --summary | -S ] => print a list of passing and failing tests
[ --passthru | -P ] => Run the Go test command, don't change anything in the outputExamples:
# Run complete test suite and print failing test output + list of failing tests
gospec# Same as above: Don't use colors in the output
gospec -C# Run complete test suite and print only the list of failing tests
gospec -O# Run complete test suite and the list of passing and failing tests
gospec -O -S# Run tests matching Percent in the utils package
gospec ./utils Percent# Run all tests that match the given regex
gospec "/Base"# Pass through to the underlying go test command: Don't mangle `go test`'s output
gospec -P# Pass through to the underlying go test command: Run tests in this package that match the given
# regex
gospec -P ./package regexWebpage:
https://github.com/icyflame/gospec
```## Installation
**Note:** `gospec` requires [`jq`][1] as a pre-requisite.
`gospec` is a bash function. You can use it by placing the file in your path and
making it an executable. I recommend placing it in `$HOME/bin` and adding
`$HOME/bin` to your path. You can place it in any folder that is listed in your
`$PATH` variable.```sh
# Download the gospec bash function into a file in this directory
curl "https://raw.githubusercontent.com/icyflame/gospec/master/gospec" > "$HOME/bin/gospec"
chmod +x "$HOME/bin/gospec"# Restart your termianl or source your bashrc/zshrc and check that gospec can
# now be called
gospec --help
```## Why?
`go test` is a great tool. But it's output is hugely lacking: the default output
is a wall of white text; there's no colors, failed tests aren't even highlighted
or summarized and printed at the end.When you compare it to `rspec`'s default output, `go test` is blown out of the
water. Rspec's output in the any format is concise, colored appropriately and
prints the list of failing tests at the end.I have two requirements from any testing tool:
- **Run a subset of all tests quickly:** I use this when I am writing a new test
or editing code that will affect an existing test.
- **Ensure that the test suite is passing before `git push`:** I use this when I
am making changes that were requested in a review.Gospec is opinionated. It doesn't print passing tests unless you use the
`--summary` option. It prints the output of failing tests by default. The bash
function is fairly small and simple, so my assumption is that anyone who wants a
different set of defaults will simply edit the bash function.## Limitations
- Argument parsing in `gospec` is naive and works only if you pass them in the
pre-defined order: `gospec [-h|-P] -C -O -S [package] regex`. I intend to fix
this in a future release.## License
Code inside this repo is licensed under the MIT License.
Copyright (c) 2020 [Siddharth Kannan](https://icyflame.github.io)
[1]: https://stedolan.github.io/jq/manual/