ejectest — eject your Rust tests

Inline tests are convenient — until your files grow too large.

Manually ejecting means editing one file and creating another. That's busywork.

Point it at a whole tree and migrate every file in one command.

$ cargo install ejectest $ ejectest apply src/lib.rs $ ejectest apply src/ $ ejectest check src/ $ ejectest apply src/ --files-from hot.txt $ linecop --baseline=90 --format=paths | ejectest apply src/ --files-from -
lib.rs
pub fn add(a: i32, b: i32) -> i32 {
    a + b
}

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

    #[test]
    fn test_add() {
        assert_eq!(add(1, 2), 3);
    }
}
lib.rs
pub fn add(a: i32, b: i32) -> i32 {
    a + b
}

#[cfg(test)]
#[path = "lib_tests.rs"]
mod tests;
lib_tests.rs
use super::*;

#[test]
fn test_add() {
    assert_eq!(add(1, 2), 3);
}