What it does
Check for mod test {}s and instead encourage those being separate files.
Checking for mod test {} was to align with tests_outside_test_module. I could imagine there being other cases to key off of.
Advantage
Rebuild performance. If someone changes a "unit test", then only the test lib rebuilds and not the lib.
Drawbacks
For foo.rs files in projects that use foo/mod.rs, adding a separate test mod would require creating a directory when it wasn't needed otherwise. Except for when visibility is a concern, a parallel test_foo.rs file could be used, e.g. snapbox does this
Overall, this would increase the friction for writing tests.
Example
#[cfg(test)]
mod test {
}
Could be written as:
What it does
Check for
mod test {}s and instead encourage those being separate files.Checking for
mod test {}was to align with tests_outside_test_module. I could imagine there being other cases to key off of.Advantage
Rebuild performance. If someone changes a "unit test", then only the test lib rebuilds and not the lib.
Drawbacks
For
foo.rsfiles in projects that usefoo/mod.rs, adding a separate test mod would require creating a directory when it wasn't needed otherwise. Except for when visibility is a concern, a paralleltest_foo.rsfile could be used, e.g. snapbox does thisOverall, this would increase the friction for writing tests.
Example
Could be written as: