Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testdox format #359

Merged
merged 3 commits into from
Aug 27, 2023
Merged

Add testdox format #359

merged 3 commits into from
Aug 27, 2023

Conversation

bitfield
Copy link
Contributor

This format shows test names as full sentences, which is useful both for autogenerating documentation ("dox"), and for encouraging programmers to write their test names as sentences describing the behaviour of the unit under test.

The specific method of formatting test names as sentences is that used by https://github.com/bitfield/gotestdox.

Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome, thank you for building gotestdox and adding this format!

I pushed a commit to use the same icons we use in other formats. There's a --format-hivis option to change the icons to more colorful ones. In a future version we might look at making those the default.

Left a couple suggestions/comments for small changes, but overall this looks great and I would like to add this format.

cmd/main.go Outdated Show resolved Hide resolved
testjson/format.go Outdated Show resolved Hide resolved
}
fmt.Fprintln(buf)
return buf.Flush()
case event.Action.IsTerminal():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this to IsTerminal so that skipped tests show up in the output as well. Does that sound ok to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, it makes sense to show skipped tests in a test runner, but a documentation generator takes the opposite view. Since these tests are skipped, they don't by definition assert anything about the behaviour of the code under test.

if !event.Action.IsTerminal() {
return nil
}
if opts.HideEmptyPackages && len(results[event.Package]) == 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added opts.HideEmptyPackages here to match the behaviour of other formats. Print the empty package by default, but --format-hide-empty-pkg can be set to hide these (for projects that have lots of empty packages).

@bitfield
Copy link
Contributor Author

I pushed a commit to use the same icons we use in other formats. There's a --format-hivis option to change the icons to more colorful ones. In a future version we might look at making those the default.

I leave that up to you, of course. But you might be interested to know why gotestdox uses the emojis it does. One of my first users was a blind developer who uses a screen reader, and he reported that the ✘ emoji I was using is pronounced by the screen reader as something like "heavy ballot x", which is weird (gotestsum's is pronounced "heavy multiplication x", which is even weirder). Changing it to simply x made the output a lot more accessible for him.

@dnephin
Copy link
Member

dnephin commented Aug 26, 2023

Ah, I had not considered screen readers but that's a great point! I'd love to provide some better support. Maybe --format-audible or something like that could change the x to "failed test", etc? The pattern here for switching between the original icons and the new hivis icons seems like it would make it easy to switch to other options as well.

Thank you for explaining the design decisions in gotestdox!

bitfield and others added 2 commits August 27, 2023 17:32
This format shows test names as full sentences, which is useful both for
autogenerating documentation ("dox"), and for encouraging programmers to
write their test names as sentences describing the behaviour of the unit
under test.

The specific method of formatting test names as sentences is that used
by https://github.com/bitfield/gotestdox.
And only hide Fuzz test cases, always report the top level test
function.
@dnephin dnephin force-pushed the testdox branch 2 times, most recently from 0466efc to 18c1f57 Compare August 27, 2023 21:50
@dnephin dnephin merged commit 2098fe3 into gotestyourself:main Aug 27, 2023
1 check passed
@afbjorklund
Copy link
Contributor

afbjorklund commented Aug 30, 2023

I added --format-icons text, which outputs "PASS" for ✓, "SKIP" for ∅ and "FAIL" for ✖

#366 (comment)

oguzhand95 referenced this pull request in cerbos/cerbos-sdk-go Sep 28, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[github.com/cerbos/cerbos/api/genpb](https://togithub.com/cerbos/cerbos)
| require | digest | `0d63f1e` -> `341baa4` |
|
[github.com/grpc-ecosystem/go-grpc-middleware/v2](https://togithub.com/grpc-ecosystem/go-grpc-middleware)
| require | patch | `v2.0.0` -> `v2.0.1` |
| [github.com/lestrrat-go/jwx/v2](https://togithub.com/lestrrat-go/jwx)
| require | patch | `v2.0.12` -> `v2.0.13` |
| [google.golang.org/grpc](https://togithub.com/grpc/grpc-go) | require
| patch | `v1.58.0` -> `v1.58.2` |
|
[gotest.tools/gotestsum](https://togithub.com/gotestyourself/gotestsum)
| require | minor | `v1.10.1` -> `v1.11.0` |

---

### Release Notes

<details>
<summary>grpc-ecosystem/go-grpc-middleware
(github.com/grpc-ecosystem/go-grpc-middleware/v2)</summary>

###
[`v2.0.1`](https://togithub.com/grpc-ecosystem/go-grpc-middleware/releases/tag/v2.0.1)

[Compare
Source](https://togithub.com/grpc-ecosystem/go-grpc-middleware/compare/v2.0.0...v2.0.1)

#### What's Changed

- Fix outdated 'make proto' command by
[@&#8203;takp](https://togithub.com/takp) in
[https://github.com/grpc-ecosystem/go-grpc-middleware/pull/623](https://togithub.com/grpc-ecosystem/go-grpc-middleware/pull/623)
- Fix linting errors by [@&#8203;takp](https://togithub.com/takp) in
[https://github.com/grpc-ecosystem/go-grpc-middleware/pull/624](https://togithub.com/grpc-ecosystem/go-grpc-middleware/pull/624)
- Logging: Add missing variadic operator for fields by
[@&#8203;olivierlemasle](https://togithub.com/olivierlemasle) in
[https://github.com/grpc-ecosystem/go-grpc-middleware/pull/629](https://togithub.com/grpc-ecosystem/go-grpc-middleware/pull/629)
- feat: Support extracting fields from CallMeta by
[@&#8203;fsaintjacques](https://togithub.com/fsaintjacques) in
[https://github.com/grpc-ecosystem/go-grpc-middleware/pull/628](https://togithub.com/grpc-ecosystem/go-grpc-middleware/pull/628)
- Fix "make test" and "make lint" by
[@&#8203;olivierlemasle](https://togithub.com/olivierlemasle) in
[https://github.com/grpc-ecosystem/go-grpc-middleware/pull/627](https://togithub.com/grpc-ecosystem/go-grpc-middleware/pull/627)
- Do not set timeout for stream initialization by
[@&#8203;DavyJohnes](https://togithub.com/DavyJohnes) in
[https://github.com/grpc-ecosystem/go-grpc-middleware/pull/645](https://togithub.com/grpc-ecosystem/go-grpc-middleware/pull/645)
- Add logging option to disable fields in log entry by
[@&#8203;coleenquadros](https://togithub.com/coleenquadros) in
[https://github.com/grpc-ecosystem/go-grpc-middleware/pull/631](https://togithub.com/grpc-ecosystem/go-grpc-middleware/pull/631)
- Update logging adapter docs by
[@&#8203;aboryslawski](https://togithub.com/aboryslawski) in
[https://github.com/grpc-ecosystem/go-grpc-middleware/pull/647](https://togithub.com/grpc-ecosystem/go-grpc-middleware/pull/647)

#### New Contributors

- [@&#8203;takp](https://togithub.com/takp) made their first
contribution in
[https://github.com/grpc-ecosystem/go-grpc-middleware/pull/623](https://togithub.com/grpc-ecosystem/go-grpc-middleware/pull/623)
- [@&#8203;olivierlemasle](https://togithub.com/olivierlemasle) made
their first contribution in
[https://github.com/grpc-ecosystem/go-grpc-middleware/pull/629](https://togithub.com/grpc-ecosystem/go-grpc-middleware/pull/629)
- [@&#8203;fsaintjacques](https://togithub.com/fsaintjacques) made their
first contribution in
[https://github.com/grpc-ecosystem/go-grpc-middleware/pull/628](https://togithub.com/grpc-ecosystem/go-grpc-middleware/pull/628)
- [@&#8203;DavyJohnes](https://togithub.com/DavyJohnes) made their first
contribution in
[https://github.com/grpc-ecosystem/go-grpc-middleware/pull/645](https://togithub.com/grpc-ecosystem/go-grpc-middleware/pull/645)
- [@&#8203;coleenquadros](https://togithub.com/coleenquadros) made their
first contribution in
[https://github.com/grpc-ecosystem/go-grpc-middleware/pull/631](https://togithub.com/grpc-ecosystem/go-grpc-middleware/pull/631)
- [@&#8203;aboryslawski](https://togithub.com/aboryslawski) made their
first contribution in
[https://github.com/grpc-ecosystem/go-grpc-middleware/pull/647](https://togithub.com/grpc-ecosystem/go-grpc-middleware/pull/647)

**Full Changelog**:
grpc-ecosystem/go-grpc-middleware@v2.0.0...v2.0.1

</details>

<details>
<summary>lestrrat-go/jwx (github.com/lestrrat-go/jwx/v2)</summary>

###
[`v2.0.13`](https://togithub.com/lestrrat-go/jwx/releases/tag/v2.0.13)

[Compare
Source](https://togithub.com/lestrrat-go/jwx/compare/v2.0.12...v2.0.13)

    v2.0.13 26 Sep 2023
    [New Features]
* [jwk] jwk.Equal has been added. Please note that this is equivalent to
comparing the keys' thumbprints, therefore it does NOT take in
consideration
      non-essential fields.

    [Miscellaneous]
      * Various documentation fixes and additions.

</details>

<details>
<summary>grpc/grpc-go (google.golang.org/grpc)</summary>

### [`v1.58.2`](https://togithub.com/grpc/grpc-go/releases/tag/v1.58.2):
Release 1.58.2

[Compare
Source](https://togithub.com/grpc/grpc-go/compare/v1.58.1...v1.58.2)

### Bug Fixes

-   balancer/weighted_round_robin: fix ticker leak on update

A new ticker is created every time there is an update of addresses or
configuration, but was not properly stopped. This change stops the
ticker when it is no longer needed.

### [`v1.58.1`](https://togithub.com/grpc/grpc-go/releases/tag/v1.58.1):
Release 1.58.1

[Compare
Source](https://togithub.com/grpc/grpc-go/compare/v1.58.0...v1.58.1)

##### Bug Fixes

- grpc: fix a bug that was decrementing active RPC count too early for
streaming RPCs; leading to channel moving to IDLE even though it had
open streams
- grpc: fix a bug where transports were not being closed upon channel
entering IDLE

</details>

<details>
<summary>gotestyourself/gotestsum (gotest.tools/gotestsum)</summary>

###
[`v1.11.0`](https://togithub.com/gotestyourself/gotestsum/releases/tag/v1.11.0)

[Compare
Source](https://togithub.com/gotestyourself/gotestsum/compare/v1.10.1...v1.11.0)

#### What's Changed

- handle multiple levels in subtest regex generation by
[@&#8203;brycekahle](https://togithub.com/brycekahle) in
[https://github.com/gotestyourself/gotestsum/pull/342](https://togithub.com/gotestyourself/gotestsum/pull/342)
- rerun-fails: prevent extra runs when a sub-test fails by
[@&#8203;brycekahle](https://togithub.com/brycekahle) in
[https://github.com/gotestyourself/gotestsum/pull/343](https://togithub.com/gotestyourself/gotestsum/pull/343)
- Add note about binary test result caching by
[@&#8203;nfi-hashicorp](https://togithub.com/nfi-hashicorp) in
[https://github.com/gotestyourself/gotestsum/pull/350](https://togithub.com/gotestyourself/gotestsum/pull/350)
- dots-v2: hide cursor during output by
[@&#8203;howardjohn](https://togithub.com/howardjohn) in
[https://github.com/gotestyourself/gotestsum/pull/354](https://togithub.com/gotestyourself/gotestsum/pull/354)
- Export elapsed time to the post-run environment by
[@&#8203;afbjorklund](https://togithub.com/afbjorklund) in
[https://github.com/gotestyourself/gotestsum/pull/360](https://togithub.com/gotestyourself/gotestsum/pull/360)
- Include test.timeout stack trace in the junit.xml by
[@&#8203;dnephin](https://togithub.com/dnephin) in
[https://github.com/gotestyourself/gotestsum/pull/357](https://togithub.com/gotestyourself/gotestsum/pull/357)
- Fix dots formats with stderr by
[@&#8203;dnephin](https://togithub.com/dnephin) in
[https://github.com/gotestyourself/gotestsum/pull/358](https://togithub.com/gotestyourself/gotestsum/pull/358)
- Rename TESTS_ELAPSED environment variable by
[@&#8203;afbjorklund](https://togithub.com/afbjorklund) in
[https://github.com/gotestyourself/gotestsum/pull/361](https://togithub.com/gotestyourself/gotestsum/pull/361)
- GitHub actions format by
[@&#8203;dnephin](https://togithub.com/dnephin) in
[https://github.com/gotestyourself/gotestsum/pull/315](https://togithub.com/gotestyourself/gotestsum/pull/315)
- Add the time unit to elapsed time duration by
[@&#8203;afbjorklund](https://togithub.com/afbjorklund) in
[https://github.com/gotestyourself/gotestsum/pull/363](https://togithub.com/gotestyourself/gotestsum/pull/363)
- Add testdox format by
[@&#8203;bitfield](https://togithub.com/bitfield) in
[https://github.com/gotestyourself/gotestsum/pull/359](https://togithub.com/gotestyourself/gotestsum/pull/359)
- Add post-run-command notify implementation for linux by
[@&#8203;afbjorklund](https://togithub.com/afbjorklund) in
[https://github.com/gotestyourself/gotestsum/pull/362](https://togithub.com/gotestyourself/gotestsum/pull/362)
- dotsv2: remove jitters entirely by
[@&#8203;howardjohn](https://togithub.com/howardjohn) in
[https://github.com/gotestyourself/gotestsum/pull/368](https://togithub.com/gotestyourself/gotestsum/pull/368)

#### New Contributors

- [@&#8203;brycekahle](https://togithub.com/brycekahle) made their first
contribution in
[https://github.com/gotestyourself/gotestsum/pull/342](https://togithub.com/gotestyourself/gotestsum/pull/342)
- [@&#8203;nfi-hashicorp](https://togithub.com/nfi-hashicorp) made their
first contribution in
[https://github.com/gotestyourself/gotestsum/pull/350](https://togithub.com/gotestyourself/gotestsum/pull/350)
- [@&#8203;howardjohn](https://togithub.com/howardjohn) made their first
contribution in
[https://github.com/gotestyourself/gotestsum/pull/354](https://togithub.com/gotestyourself/gotestsum/pull/354)
- [@&#8203;afbjorklund](https://togithub.com/afbjorklund) made their
first contribution in
[https://github.com/gotestyourself/gotestsum/pull/360](https://togithub.com/gotestyourself/gotestsum/pull/360)
- [@&#8203;bitfield](https://togithub.com/bitfield) made their first
contribution in
[https://github.com/gotestyourself/gotestsum/pull/359](https://togithub.com/gotestyourself/gotestsum/pull/359)

**Full Changelog**:
gotestyourself/gotestsum@v1.10.1...v1.11.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/cerbos/cerbos-sdk-go).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMDcuMiIsInVwZGF0ZWRJblZlciI6IjM2LjEwNy4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Oğuzhan Durgun <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants