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

Replace println! calls with snapshot tests #158

Merged
merged 5 commits into from
Dec 12, 2023

Conversation

spenserblack
Copy link
Collaborator

As discussed in #156, this converts the visual tests into things that can be asserted with cargo test. These can still be visually reviewed with cat path/to/snapshot. This also registers the detected language for *.snap files as plain text -- currently, GitHub will detect them as Jest snapshot files and apply a JavaScript-like syntax highlighting otherwise. This also installs cargo-insta when a contributor creates a new codespace.

The one println! in a test that I didn't address is here

println!("first: {}\nsecond: {}", expected, output);

Since that didn't look like part of the test, but just a snippet to help debug. I was tempted to switch it to a dbg! call, but dbg! prints the Debug formatting instead of the display formatting.

@spenserblack spenserblack marked this pull request as ready for review December 12, 2023 14:41
Copy link
Collaborator

@kurtlawrence kurtlawrence left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the hard work!

Cna merge in once the CI passes

@spenserblack
Copy link
Collaborator Author

Oh, interesting. The CI environment didn't detect truecolor support by default, causing the snapshot tests to fail. I updated the env key in the test workflow to force true color. Perhaps there should be some sort of togglable value, even if it's internal, so that this can be forced inside tests instead of leaving it up to the environment.

@kurtlawrence kurtlawrence merged commit d4da0f4 into colored-rs:master Dec 12, 2023
14 checks passed
@spenserblack spenserblack deleted the chore/156/snapshot-tests branch December 18, 2023 20:54
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.

2 participants