Skip to content

Commit e4d6384

Browse files
committed
Don't normalize commands
Since commands are looked up in PATH, their `Path` is unreliable and cannot be treated as a normal directory. - Add an integration test - Cleanup afterwards
1 parent c569559 commit e4d6384

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

tests/buildtest/inside_docker.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ static CONTAINER_PREFIX: &str = "/outside";
1313
#[cfg(unix)]
1414
fn test_hello_world() {
1515
// regression test for https://github.com/rust-lang/rustwide/issues/30
16-
if !Path::new("docker").exists() {
16+
let already_present = Path::new("docker").exists();
17+
if !already_present {
1718
std::fs::create_dir("docker").unwrap();
1819
}
1920
execute("buildtest::test_hello_world").unwrap();
21+
if !already_present {
22+
std::fs::remove_dir("docker").unwrap();
23+
}
2024
}
2125

2226
fn execute(test: &str) -> Result<(), Error> {

tests/integration/build_dir.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use failure::Error;
2+
3+
const WORKSPACE_NAME: &str = "test-drop";
4+
5+
#[test]
6+
fn test_build_dir_drop() -> Result<(), Error> {
7+
let workspace = crate::utils::init_named_workspace(WORKSPACE_NAME)?;
8+
let mut build_dir = workspace.build_dir("drop-dir");
9+
build_dir.purge_on_drop(true);
10+
let path = build_dir.build_dir();
11+
drop(build_dir);
12+
assert!(!path.exists());
13+
Ok(())
14+
}

0 commit comments

Comments
 (0)