-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Migrate tests of cargo-init to snapbox
#10620
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
Conversation
Some redundant tests are merged or deleted. - `gitignore_appended_not_replaced` -> `git_ignore_exists_no_conflicting_entries` - `gitignore_added_newline_in_existing` -> `git_ignore_exists_no_conflicting_entries` - `gitignore_no_newline_in_new` -> `simple_git` - `terminating_newline_in_existing_git_ignore` -> `git_ignore_exists_no_conflicting_entries` - `terminating_newline_in_new_git_ignore` -> `simple_git` - `terminating_newline_in_new_mercurial_ignore` -> `simple_hg` - `terminating_newline_in_existing_mercurial_ignore` -> `simple_hg_ignore_exists` - `mercurial_added_newline_in_existing` -> `simple_hg_ignore_exists` - `mercurial_no_newline_in_new` -> `simple_hg` - `cargo_lock_gitignored_if_lib1` -> `simple_git` - `cargo_lock_gitignored_if_lib2` -> `inferred_lib_with_git` - `cargo_lock_not_gitignored_if_bin2` -> `inferred_bin_with_git` - `cargo_lock_not_gitignored_if_bin1` -> `explicit_bin_with_git`
|
r? @ehuss (rust-highfive has picked a reviewer for you, use r? to override) |
tests/snapshots/init/ignores_failure_to_format_source.in/rustfmt.toml
Outdated
Show resolved
Hide resolved
snapbox/trycmd won't copy ".keep" if present. - <https://docs.rs/trycmd/0.13.4/trycmd/#in> - <https://docs.rs/trycmd/0.13.4/trycmd/#out>
|
Overall, I'm feeling very wary of making changes like this. I'm finding that this adds over 500 lines of code, and nearly 200 files, and adds quite a bit a complexity for not a substantial amount of benefit. Can we take a step back and evaluate what the strategy here is? I don't think we should be bulk updating tests unless there is in balance a benefit. The If the primary concern is being able to update the output of a test, would an alternative be to just have a tool to update the strings within the test file automatically? |
I think I might have misunderstood where people stood previously. I had thought we had intended to switch our testing over to snapbox. Also, what are you finding is complex with this? For me, the benefits are
What maturing would you like to see? it looks like this was chosen because this isn't hitting an area of missing features in snapbox. While I had intended to wait until those missing features are handled (unordered, structured data), I think an exercise like this is useful to see how well it works and to collect feedback, to iterate.
The trade offs I see
In-code snapshot updating can get complicated I know the xflags arg parser does it and is relatively simple but that is more limited to when you have a singleton. insta provides the more complicated cases today. it makes different trade offs for its external snapshots, using a single managed file in a custom format that has the downsides to an external snapshot but not the upsides of working with real files. I'd be willing to brainstorm solutions and evaluate trade offs for what we want moving forward. |
|
@bors r+ Once this is merged, plan to make improvements
And document when to use filesystem snapshots vs in-code: #10628 |
|
📌 Commit 20c0c58 has been approved by |
|
☀️ Test successful - checks-actions |
Update cargo 7 commits in f63f23ff1f1a12ede8585bbd1bbf0c536e50293d..a44758ac805600edbb6ba51e7e6fb81a6077c0cd 2022-04-28 03:15:50 +0000 to 2022-05-04 02:29:34 +0000 - Add support for `-Zbuild-std` to `cargo fetch` (rust-lang/cargo#10129) - Migrate tests of `cargo-init` to snapbox (rust-lang/cargo#10620) - dedupe toml_edit crate, followup rust-lang/cargo#10603 (rust-lang/cargo#10619) - Update GitHub Actions actions/checkout@v2 to v3 (rust-lang/cargo#10618) - Integrate snapbox in with cargo-test-support (rust-lang/cargo#10581) - Fix zsh completion (rust-lang/cargo#10613) - Update documentation for workspace inheritance (rust-lang/cargo#10611)
What does this PR try to resolve?
An attempt of migrating tests of
cargo-initto snapbox.How should we test and review this PR?
To review this PR, you may compare the old and the new version one by one. Files not listed in
<test-name>.outare not asserted, so please help me make sure we don't miss any essential file to check.Some redundant tests are covered by other tests or renamed.
Expand to see the list of merged/renamed tests.
gitignore_appended_not_replaced-> merged intogit_ignore_exists_no_conflicting_entriesgitignore_added_newline_in_existing-> merged intogit_ignore_exists_no_conflicting_entriesgitignore_no_newline_in_new-> merged intosimple_gitterminating_newline_in_existing_git_ignore-> merged intosimple_git_ignore_existsterminating_newline_in_new_git_ignore-> merged intosimple_gitterminating_newline_in_new_mercurial_ignore-> merged intosimple_hgterminating_newline_in_existing_mercurial_ignore-> merged intosimple_hg_ignore_existsmercurial_added_newline_in_existing-> merged intosimple_hg_ignore_existsmercurial_no_newline_in_new-> merged intosimple_hgcargo_lock_gitignored_if_lib1-> merged intosimple_gitcargo_lock_gitignored_if_lib2-> renamed toinferred_lib_with_gitcargo_lock_not_gitignored_if_bin2-> renamed toinferred_bin_with_gitcargo_lock_not_gitignored_if_bin1-> renamed toexplicit_bin_with_gitAdditional information
I won't say the process of the migration was pleasant, but overall it results to a higher coverage of output file changes. Here are steps I performed to migrate a test case:
<test-name>.in.snapboxwill do it for you.SNAPSHOTS=overwrite cargo test --test testsuite <your-test-filter>to assert and generate snapshots.Something observations when dealing with the migration: