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

Allow dead_code in tests #43

Merged
merged 1 commit into from
Feb 27, 2024
Merged

Allow dead_code in tests #43

merged 1 commit into from
Feb 27, 2024

Conversation

Grinkers
Copy link
Collaborator

Just less noise.

@Grinkers Grinkers marked this pull request as ready for review February 23, 2024 19:04
Copy link
Collaborator

@naomijub naomijub left a comment

Choose a reason for hiding this comment

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

I'm OK with the change but my suggestion is to create a tests/lib.rs and add a single #![allow(dead_code)] there

@Grinkers
Copy link
Collaborator Author

Grinkers commented Feb 23, 2024

I'm OK with the change but my suggestion is to create a tests/lib.rs and add a single #![allow(dead_code)] there

I believe tests/ is a special case. Each mod inside ends up being compiled as a completely separate crate, so this doesn't work. I actually ran into this issue with edn-rs trying to add a helper function for all mods https://github.com/edn-rs/edn-rs/blob/3965bc3221d79b883a7059d7ce72c4c5c2eee366/tests/deserialize.rs#L10. The workarounds involve directly importing rust files, which is just way more ugly than a couple repeated snippets.

Reference: https://stackoverflow.com/questions/44539729/what-is-an-idiomatic-way-to-have-shared-utility-functions-for-integration-tests

It's further weird with the crate trybuild being used, which ends up in a completely separate compile process for each file.
https://github.com/edn-rs/edn-derive/blob/main/tests/progress.rs

@Grinkers
Copy link
Collaborator Author

Edited my above link. Also found what I was originally thinking

https://doc.rust-lang.org/book/ch11-03-test-organization.html#the-tests-directory

Each file in the tests directory is a separate crate

@Grinkers
Copy link
Collaborator Author

I was able to clean up edn-rs's lib.rs. I don't think it's really any more clean, but better for long-term usage. I don't think this would work with attributes here, especially with trybuild. It's really quite weird how tests/ gets treated so differently.

naomijub/edn-rs@7efaab5

@Grinkers
Copy link
Collaborator Author

@naomijub @evaporei
merging unless either of you have any other ideas. Adding a lib.rs is a no-op and I don't think trybuild can inject attributes. Each test is actually its own binary.

@Grinkers Grinkers closed this Feb 26, 2024
@Grinkers Grinkers deleted the clippy branch February 26, 2024 18:49
@Grinkers Grinkers restored the clippy branch February 26, 2024 19:02
@Grinkers Grinkers reopened this Feb 26, 2024
@Grinkers Grinkers merged commit 089a54a into evaporei:main Feb 27, 2024
8 checks passed
@Grinkers Grinkers deleted the clippy branch February 27, 2024 23:04
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.

3 participants