Skip to content

Commit

Permalink
Merge pull request #267 from dnephin/update-readme
Browse files Browse the repository at this point in the history
Update Readme
  • Loading branch information
dnephin authored Aug 6, 2022
2 parents 071f4a1 + c54abf9 commit de44b55
Show file tree
Hide file tree
Showing 23 changed files with 90 additions and 157 deletions.
28 changes: 23 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ workflows:
echo 'export PATH="$PATH:/c/Program Files/Go/bin"' > $BASH_ENV
- run: go version

- go/lint:
golangci-lint-version: 1.48.0

- lint
- build
- run

Expand Down Expand Up @@ -107,13 +105,13 @@ jobs:
steps:
run:
name: build binaries
command: bin/goreleaser --rm-dist --snapshot
command: bin/goreleaser --rm-dist --snapshot --config .project/goreleaser.yml
- when:
condition: << parameters.publish >>
steps:
run:
name: build and publish binaries
command: bin/goreleaser --rm-dist --skip-validate
command: bin/goreleaser --rm-dist --skip-validate --config .project/goreleaser.yml
- store_artifacts:
path: ./dist
destination: dist
Expand All @@ -130,6 +128,26 @@ jobs:
go build -o dist/gotestsum .
- run: dist/gotestsum

lint:
executor:
name: go/golang
tag: 1.19-alpine
steps:
- checkout
- run: go mod download
- run:
name: Install golangci-lint
command: |
mkdir -p /go/bin
download=https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh
wget -O- -q "$download" | sh -s -- -b /go/bin/ v1.48.0
- run:
name: Lint
command: |
golangci-lint run -v --concurrency 2 --config .project/golangci-lint.yml
update-windows-golden:
executor: windows
steps:
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/sync-main.yaml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
vendor/
.dobi/
dist/
junit.xml
.plsdo/
75 changes: 0 additions & 75 deletions .plsdo.sh

This file was deleted.

9 changes: 0 additions & 9 deletions .pre-commit-hooks.yaml

This file was deleted.

4 changes: 1 addition & 3 deletions Dockerfile → .project/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

ARG GOLANG_VERSION
FROM golang:${GOLANG_VERSION:-1.14-alpine} as golang
FROM golang:${GOLANG_VERSION:-1.18-alpine} as golang
RUN apk add -U curl git bash
ENV CGO_ENABLED=0 \
PS1="# " \
Expand All @@ -11,13 +11,11 @@ USER ${UID}:${UID}


FROM golang as tools
RUN go get github.com/dnephin/[email protected]
RUN wget -O- -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s && \
mv bin/golangci-lint /go/bin


FROM golang as dev
COPY --from=tools /go/bin/filewatcher /usr/bin/filewatcher
COPY --from=tools /go/bin/golangci-lint /usr/bin/golangci-lint


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 17 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,30 @@

`gotestsum` runs tests using `go test -json`, prints formatted test output, and a summary of the test run.
It is designed to work well for both local development, and for automation like CI.
`gotest.tools/gotestsum/testjson` ([godoc](https://pkg.go.dev/gotest.tools/gotestsum/testjson)) is a library
that can be used to read [`test2json`](https://golang.org/cmd/test2json/) output.

See the [documentation](#documentation) for more details.

## Install

Download a binary from [releases](https://github.com/gotestyourself/gotestsum/releases), or build from
source with `go install gotest.tools/gotestsum@latest`. With `go` version before 1.17, use `go get gotest.tools/gotestsum`.

## Demo
A demonstration of three `--format` options.

![Demo](https://i.ibb.co/XZfhmXq/demo.gif)
<br /><sup>[Source](https://github.com/gotestyourself/gotestsum/tree/readme-demo/scripts)</sup>

## Documentation

### Index
## Documentation

**Core features**
- [Output Format](#output-format) from compact to verbose, with color highlighting.
- [Summary](#summary) of the test run.
- [Add `go test` flags](#custom-go-test-command), or
[run a compiled test binary](#executing-a-compiled-test-binary).

**Automation and CI**
- [JUnit XML file](#junit-xml-output) for integration with CI systems.
- [JSON file](#json-file-output) to capture the `test2json` output in a file.
- [Re-run failed tests](#re-running-failed-tests) to save time when dealing with flaky test suites.
**CI and Automation**
- [`--junitfile`](#junit-xml-output) - write a JUnit XML file for integration with CI systems.
- [`--jsonfile`](#json-file-output) - write the `test2json` output in a file.
- [`--rerun-fails`](#re-running-failed-tests) - run failed tests again to save time when dealing with flaky test suites.

**Local Development**
- [Post run commands](#post-run-command) may be used for desktop notification.
- [Run tests when a file is saved](#run-tests-when-a-file-is-saved).
- [Find or skip slow tests](#finding-and-skipping-slow-tests) using `gotestsum tool slowest`.
- [`--watch`](#run-tests-when-a-file-is-saved) - when a file is saved, run the tests for the package that includes the file.
- [`--post-run-command`](#post-run-command) - run a command after the tests, can be used for desktop notification.
- [`gotestsum tool slowest`](#finding-and-skipping-slow-tests) - find the slowest tests, also update slow tests to be skipepd with `-short`.


### Output Format

Expand All @@ -55,6 +44,13 @@ Commonly used formats (see `--help` for a full list):
Have an idea for a new format?
Please [share it on github](https://github.com/gotestyourself/gotestsum/issues/new)!

#### Demo

A demonstration of three `--format` options.

![Demo](https://user-images.githubusercontent.com/442180/182284939-e08a0aa5-4504-4e30-9e88-207ef47f4537.gif)
<br /><sup>[Source](https://github.com/gotestyourself/gotestsum/tree/readme-demo/scripts)</sup>

### Summary

Following the formatted output is a summary of the test run. The summary includes:
Expand Down Expand Up @@ -297,7 +293,7 @@ output. `./binary.test` is the path to the compiled test binary. The `-test.v`
must be included so that `go tool test2json` receives all the output.

To execute a test binary without installing Go, see
[running without go](./docs/running-without-go.md).
[running without go](./.project/docs/running-without-go.md).


### Finding and skipping slow tests
Expand Down
2 changes: 1 addition & 1 deletion cmd/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"path/filepath"

"gotest.tools/gotestsum/internal/junitxml"
"gotest.tools/gotestsum/log"
"gotest.tools/gotestsum/internal/log"
"gotest.tools/gotestsum/testjson"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

"github.com/dnephin/pflag"
"github.com/fatih/color"
"gotest.tools/gotestsum/log"
"gotest.tools/gotestsum/internal/log"
"gotest.tools/gotestsum/testjson"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/tool/slowest/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"

"golang.org/x/tools/go/packages"
"gotest.tools/gotestsum/log"
"gotest.tools/gotestsum/internal/log"
"gotest.tools/gotestsum/testjson"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/tool/slowest/slowest.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/dnephin/pflag"
"gotest.tools/gotestsum/internal/aggregate"
"gotest.tools/gotestsum/log"
"gotest.tools/gotestsum/internal/log"
"gotest.tools/gotestsum/testjson"
)

Expand Down
54 changes: 39 additions & 15 deletions do
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail

source .plsdo.sh
declare -A help

binary() {
mkdir -p dist
Expand All @@ -13,22 +14,11 @@ binary-static() {
}

update-golden() {
#_update-golden
if ldd ./dist/gotestsum > /dev/null 2>&1; then
binary-static
fi
GOLANG_VERSION=1.13-alpine ./do shell ./do _update-golden
GOLANG_VERSION=1.14.6-alpine ./do shell ./do _update-golden
}

_update-golden() {
PATH="$PWD/dist:$PATH" gotestsum -- \
./cmd ./testjson ./internal/junitxml ./cmd/tool/slowest \
-test.update-golden
gotestsum -- ./... -update
}

lint() {
golangci-lint run -v
golangci-lint run -v --config .project/golangci-lint.yml
}

go-mod-tidy() {
Expand Down Expand Up @@ -57,7 +47,7 @@ shell() {
_docker-build-dev() {
set -e
local idfile=".plsdo/docker-build-dev-image-id-${GOLANG_VERSION-default}"
local dockerfile=Dockerfile
local dockerfile=.project/Dockerfile
local tag=gotest.tools/gotestsum/builder
if [ -f "$idfile" ] && [ "$dockerfile" -ot "$idfile" ]; then
cat "$idfile"
Expand All @@ -83,4 +73,38 @@ godoc() {
command godoc -http=:6060
}

help[list]="Print the list of tasks"
list() {
declare -F | awk '{print $3}' | grep -v '^_'
}

_plsdo_help() {
local topic="${1-}"
# print help for the topic
if [ -n "$topic" ]; then
if ! command -v "$topic" > /dev/null ; then
>&2 echo "No such task: $topic"
return 1
fi

printf "\nUsage:\n %s %s\n\n%s\n" "$0" "$topic" "${help[$topic]-}"
return 0
fi

# print list of tasks and their help line.
[ -n "${banner-}" ] && echo "$banner" && echo
for i in $(list); do
printf "%-12s\t%s\n" "$i" "${help[$i]-}" | head -1
done
}

_plsdo_run() {
case "${1-}" in
""|help)
_plsdo_help "${2-}" ;;
*)
"$@" ;;
esac
}

_plsdo_run "$@"
Binary file removed docs/demo.gif
Binary file not shown.
2 changes: 1 addition & 1 deletion internal/filewatcher/term_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"os"

"golang.org/x/sys/unix"
"gotest.tools/gotestsum/log"
"gotest.tools/gotestsum/internal/log"
)

type terminal struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/filewatcher/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"time"

"github.com/fsnotify/fsnotify"
"gotest.tools/gotestsum/log"
"gotest.tools/gotestsum/internal/log"
)

const maxDepth = 7
Expand Down
Loading

0 comments on commit de44b55

Please sign in to comment.