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

Remove extraneous mod statements from tests #975

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

caass
Copy link
Member

@caass caass commented Jun 6, 2024

Description

Integration tests are compiled into their own binaries, which are then
executed. As such, there's no need to wrap integration tests in modules:

// in `tests/some_test.rs`
use some::dependency;

#[cfg(test)]
mod some_integration_test {
  use super::*;

  // Some tests go here.
}

This is common practice in unit tests, which if not gated behind a
cfg flag are included in the final release binary. We were mistakenly
doing the same thing in integration tests, where it was unnecessary.

This PR just removes all those module declarations.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

bazel test //... passes

Checklist

  • Updated documentation if needed
  • Tests added/amended
  • bazel test //... passes locally
  • PR is contained in a single commit, using git amend see some docs

This change is Reviewable

Copy link
Member

@allada allada left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 34 of 34 files at r1, all commit messages.
Reviewable status: 1 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Cargo Dev / macos-13, Cargo Dev / ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), macos-13, pre-commit-checks, ubuntu-20.04 / stable, ubuntu-22.04, ubuntu-22.04 / stable, vale, windows-2022 / stable

Integration tests are compiled into their own binaries, which are then
executed. As such, there's no need to wrap integration tests in modules:

```rust
// in `tests/some_test.rs`
use some::dependency;

#[cfg(test)]
mod some_integration_test {
  use super::*;

  // Some tests go here.
}
```

This is common practice in unit tests, which if not gated behind a
`cfg` flag are included in the final release binary. We were mistakenly
doing the same thing in integration tests, where it was unnecessary.
@caass caass force-pushed the refactor-test-modules branch from a42abc3 to 60f5571 Compare June 6, 2024 20:50
@caass caass merged commit f59a1d7 into TraceMachina:main Jun 6, 2024
28 checks passed
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