rust-lang / rustwide

Execute your code on the Rust ecosystem.
Apache License 2.0
180 stars 41 forks source link

Add option to purge BuildDirectory on drop #28

Closed jyn514 closed 4 years ago

jyn514 commented 4 years ago

I tried adding an integration test, but I couldn't get the path because build_dir() and all related methods are private. This doesn't really seem like a unit test, but I can add it if you like.

Also, it seems like rustwide runs cargo clean without arguments during tests? I'd really rather it didn't do that, if I use a shared CARGO_TARGET_DIR it means I have to rebuild rustwide (and all other crates) from scratch for every test. Instead it could call cargo clean -p <package>.

use failure::Error;

const WORKSPACE_NAME: &str = "test-drop";

#[test]
fn test_build_dir_drop() -> Result<(), Error> {
    let workspace = crate::utils::init_named_workspace(WORKSPACE_NAME)?;
    let mut build_dir = workspace.build_dir("drop-dir");
    build_dir.purge_on_drop(true);
    let path = build_dir.build_dir();
    drop(build_dir);
    assert!(!path.exists());
    Ok(())
}
jyn514 commented 4 years ago

Addresses https://github.com/rust-lang/docs.rs/issues/820; docs.rs will need a follow-up PR updating rustwide and using the new API.

pietroalbini commented 4 years ago

We decided not to do this.