Description
One of the most annoying parts of compiler refactorings is suddenly discovering that after a refactoring change some code in unit tests stops building.
Compiler unit tests are mostly old, many of them are not really "unit" and need to be migrated to regular ui testing or removed, but that's not the point of this issue.
The point of this issue is that after changing such test you have to restart the bootstrapping process from the crate that unit test belongs to (e.g. touched libsyntax
-> rebuild everything).
How to fight this problem?
Exclude unit tests from the normal build!
Files included from under cfg(FALSE)
are not considered crate dependencies from build system point of view (not included into dep files).
So, unit test modules included in the next way
#[cfg(test)]
mod tests;
won't cause rebuilds after changing code in them, they will be rebuilt only as a part of unit test run (so they won't participate in bootstrap).
Steps:
- Standardize on the test module naming (currently
mod test
- 31 instances,mod tests
- 183 instances, excludingsrc/tools
andsrc/test
subdirectories). - Outline test modules into separate files
mod tests { ... }
->#[cfg(test)] mod tests;
. - Running unit tests for
my_crate
:./x.py test --stage 0 src/my_crate
.