-
Notifications
You must be signed in to change notification settings - Fork 954
refactor(test): add new APIs for easier snapshot testing #4334
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
base: master
Are you sure you want to change the base?
Conversation
8af6551
to
7ae21c9
Compare
7ae21c9
to
ea65a34
Compare
I really like this. Using a more principled testing framework makes a lot of sense rather than maintaining a bespoke solution. And it does seem to be a mostly drop-in replacement but allows for more exact matching (no need for It'd be great if we can figure out how to make the old APIs deprecated while still making CI pass but I think this is worth doing even if that proves challenging. I don't have a strong opinion on naming. Maybe "redactions" could be "replacements"? Because it replaces the matched string. |
b23b07f
to
5ae4ce8
Compare
@ChrisDenton Many thanks for the kind words! My plan is that we can merge this as-is first (with |
5ae4ce8
to
254f543
Compare
254f543
to
080f555
Compare
080f555
to
85ae90e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good direction!
@@ -1,3 +1,4 @@ | |||
#![allow(deprecated)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: move these below the module-level docstrings, please?
@@ -21,6 +21,7 @@ use rustup::test::{ | |||
use rustup::test::{RegistryGuard, RegistryValueId, USER_PATH}; | |||
use rustup::utils::{self, raw}; | |||
use rustup::{DUP_TOOLS, TOOLS, for_host}; | |||
use snapbox::str; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love this because I usually expect str
to be std::str
. Maybe alias this or just use snapbox::str!()
in callers?
Borrowing from Cargo's previous effort, this marks the beginning of a new testing DSL for better overall dev experience.
RA-powered inline snapshot updates seems to work without issues in VSCode with the given demo:
I have a more ambitious goal of removing dependency injections altogether, but we must start from somewhere, so here it is.
Concerns
this_host_triple
,tempdir
, ...)?this_host_triple
is a good inclusion at the start; and I've made it so that each test can add their own redactions.