mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-24 14:45:56 +00:00
Replace rojo-test with regular tests folder again (#323)
* Replace rojo-test with regular tests folder again * Bump MSRV to 1.43.1
This commit is contained in:
committed by
GitHub
parent
ca5b8ab309
commit
5ccd02939b
54
tests/rojo_test/io_util.rs
Normal file
54
tests/rojo_test/io_util.rs
Normal file
@@ -0,0 +1,54 @@
|
||||
use std::{
|
||||
fs, io,
|
||||
path::{Path, PathBuf},
|
||||
process::Child,
|
||||
};
|
||||
|
||||
use walkdir::WalkDir;
|
||||
|
||||
pub static ROJO_PATH: &str = env!("CARGO_BIN_EXE_rojo");
|
||||
pub static BUILD_TESTS_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/rojo-test/build-tests");
|
||||
pub static SERVE_TESTS_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/rojo-test/serve-tests");
|
||||
|
||||
pub fn get_working_dir_path() -> PathBuf {
|
||||
let mut manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
assert!(
|
||||
manifest_dir.pop(),
|
||||
"Manifest directory did not have a parent"
|
||||
);
|
||||
manifest_dir
|
||||
}
|
||||
|
||||
/// Recursively walk a directory and copy each item to the equivalent location
|
||||
/// in another directory. Equivalent to `cp -r src/* dst`
|
||||
pub fn copy_recursive(from: &Path, to: &Path) -> io::Result<()> {
|
||||
for entry in WalkDir::new(from) {
|
||||
let entry = entry?;
|
||||
let path = entry.path();
|
||||
let new_path = to.join(path.strip_prefix(from).unwrap());
|
||||
|
||||
let file_type = entry.file_type();
|
||||
|
||||
if file_type.is_dir() {
|
||||
match fs::create_dir(new_path) {
|
||||
Ok(_) => {}
|
||||
Err(err) => match err.kind() {
|
||||
io::ErrorKind::AlreadyExists => {}
|
||||
_ => panic!(err),
|
||||
},
|
||||
}
|
||||
} else {
|
||||
fs::copy(path, new_path)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub struct KillOnDrop(pub Child);
|
||||
|
||||
impl Drop for KillOnDrop {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.0.kill();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user