Skip to content

Commit

Permalink
Add example of running with cpuprofile enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Jun 5, 2021
1 parent fb92894 commit 87cb6b0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,25 @@ stdout and stderr output:
stderr, not the `test2json` stdout). Any stderr produced by tests is not
considered an error (it will be in the `test2json` stdout).

**Example: run tests with profiling enabled**

Using a `profile.sh` script like this:

```sh
#!/usr/bin/env bash
set -eu

for pkg in $(go list "$@"); do
dir="$(go list -f '{{ .Dir }}' $pkg)"
go test -json -cpuprofile="$dir/cpu.profile" "$pkg"
done
```

You can run:
```
gotestsum --raw-command ./profile.sh ./...
```

**Example: using `TEST_DIRECTORY`**
```
TEST_DIRECTORY=./io/http gotestsum
Expand Down

0 comments on commit 87cb6b0

Please sign in to comment.