Skip to content

transpile: switch insta::glob!s to separate tests#1642

Merged
kkysen merged 4 commits intomasterfrom
kkysen/transpile-tests-separate-snapshot-tests
Mar 6, 2026
Merged

transpile: switch insta::glob!s to separate tests#1642
kkysen merged 4 commits intomasterfrom
kkysen/transpile-tests-separate-snapshot-tests

Conversation

@kkysen
Copy link
Contributor

@kkysen kkysen commented Mar 6, 2026

This replaces insta::glob! usage in c2rust-transpile/tests/snapshots.rs with separate, dedicated #[test] fns.

This is what we do for c2rust-refactor/tests/snapshots.rs, too. Now we can easily run an individual test, run all of the tests in parallel much faster, and not stop at the first error if one fails. This is really useful as I upgrade to edition 2024 (PR soon).

The *-specific directories are kept, although we don't need them anymore. We also delete the dummy files, as there's no more issue with insta::glob! using a different prefix when there's only one matching file in a directory.

Also, the c_decls_snapshots were using absolute paths in their debug expressions, so the snapshot would be different on different machines. As I switched to #[test] fns, this uses relative paths by default and thus is automatically fixed as well.

@kkysen kkysen force-pushed the kkysen/transpile-tests-separate-snapshot-tests branch from f86aec4 to d1ae9eb Compare March 6, 2026 08:32
kkysen added 3 commits March 6, 2026 00:35
Instead of using `insta::glob!`, we have explicit `#[test] fn`s for each test.
This is what we do for `c2rust-refactor/tests/snapshots.rs`, too.
Now we can easily run an individual test,
run all of the tests in parallel much faster,
and not stop at the first error if one fails.

The `*-specific` directories are kept, although we don't need them anymore.
We also delete the `dummy` files, as there's no more issue with `insta::glob!`
using a different prefix when there's only one matching file in a directory.
@kkysen kkysen force-pushed the kkysen/transpile-tests-separate-snapshot-tests branch from d1ae9eb to 02b9ca2 Compare March 6, 2026 08:36
Since there's only a single `c_decls_snapshots`,
I didn't add any extra code like `TranspileTest` for the transpile snapshots.

Also, previously, the code wasn't accounting for needing a `dummy`
and used the absolute path in the debug expression, which changes.
Now both are fixed and a relative path is used.
@kkysen kkysen force-pushed the kkysen/transpile-tests-separate-snapshot-tests branch from 02b9ca2 to b3ab33d Compare March 6, 2026 22:56
@kkysen kkysen merged commit 510729a into master Mar 6, 2026
11 checks passed
@kkysen kkysen deleted the kkysen/transpile-tests-separate-snapshot-tests branch March 6, 2026 23:52
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