3 #![allow(unused_must_use)]
4 #![allow(unused_imports)]
5 // This test can't be a unit test in std,
6 // because it needs TempDir, which is in extra
8 // ignore-cross-compile
11 use std::ffi::CString;
12 use std::fs::{self, File};
13 use std::path::PathBuf;
15 fn rename_directory() {
16 let tmpdir = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap());
17 let old_path = tmpdir.join("foo/bar/baz");
18 fs::create_dir_all(&old_path).unwrap();
19 let test_file = &old_path.join("temp.txt");
21 File::create(test_file).unwrap();
23 let new_path = tmpdir.join("quux/blat");
24 fs::create_dir_all(&new_path).unwrap();
25 fs::rename(&old_path, &new_path.join("newdir"));
26 assert!(new_path.join("newdir").is_dir());
27 assert!(new_path.join("newdir/temp.txt").exists());
30 pub fn main() { rename_directory() }