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

CLI: Limit colors in TAP reporter to test names #1801

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

Krinkle
Copy link
Member

@Krinkle Krinkle commented Sep 29, 2024

Don't apply colors to the "ok 1" and "not ok 1" prefix. This has the benefit of making the test names easier to visually extract for developers.

It also increases compatibility with the popular tap-parser package which doesn't parse TAP lines correctly otherwise, since blocks like "not ok" must start on a new line, and with the color code in front, they are technically either a continuation of the previous block, or an ignored "Anything" line between two blocks.

This hasn't been a problem in practice, since, if you pipe output from QUnit or TapReporter to a different process that uses tap-parser, colors are naturally disabled. But, if you get the console output from a browser process, the colors will be applied. I caught this while working on QTap (https://github.com/qunitjs/qtap).

https://github.com/tapjs/tapjs/tree/ccfea67fec/src/parser

https://testanything.org/tap-version-13-specification.html

Before After
Pass
Skip
Failure

@Krinkle Krinkle force-pushed the tap-compliant-colors branch from 0f78270 to 823f7b1 Compare September 29, 2024 18:26
@Krinkle Krinkle requested a review from mgol September 29, 2024 18:31
@Krinkle Krinkle added this to the 3.0 release milestone Sep 29, 2024
Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

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

One question / suggestion, LGTM overall. The arguments seem sensible and I have no problems with the visual changes.

src/core/reporters/TapReporter.js Outdated Show resolved Hide resolved
Don't apply colors to the "ok 1" and "not ok 1" prefix. This has
the benefit of making the test names easier to visually extract
for developers.

It also increases compatibility with the popular `tap-parser`
package which doesn't parse TAP lines correctly otherwise, since
blocks like "not ok" must start on a new line, and with the color
code in front, they are technically either a continuation of the
previous block, or an ignored "Anything" line between two blocks.

https://github.com/tapjs/tapjs/tree/ccfea67fec/src/parser

https://testanything.org/tap-version-13-specification.html
@Krinkle Krinkle force-pushed the tap-compliant-colors branch from 823f7b1 to a005a0b Compare October 9, 2024 16:07
@Krinkle Krinkle merged commit a006064 into qunitjs:main Oct 10, 2024
10 checks passed
@Krinkle Krinkle deleted the tap-compliant-colors branch October 10, 2024 00:09
Krinkle added a commit that referenced this pull request Dec 4, 2024
Cherry-picked from a006064 (3.0.0-dev).

> Fixes compatibility with the popular `tap-parser`
> package which doesn't parse TAP lines correctly otherwise, since
> blocks like "not ok" must start on a new line, and with the color
> code in front, they are technically either a continuation of the
> previous block, or an ignored "Anything" line between two blocks.
>
> https://github.com/tapjs/tapjs/tree/ccfea67fec/src/parser
>
> https://testanything.org/tap-version-13-specification.html
>
> Ref #1801.

Includes a partial cherry-pick of 5812597 to clarify the local
name of the onRunEnd argument as `runEnd` instead of `runSuite`.
@Krinkle Krinkle modified the milestones: 3.0 release, 2.x release Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants