Tests pass!

This commit is contained in:
Yehuda Katz
2019-07-23 15:22:11 -07:00
parent 01223091ec
commit 5a8e041a48
61 changed files with 1111 additions and 402 deletions

View File

@ -7,9 +7,9 @@ use std::io::Read;
#[macro_export]
macro_rules! nu {
($out:ident, $cwd:expr, $commands:expr) => {
pub use std::error::Error;
pub use std::io::prelude::*;
pub use std::process::{Command, Stdio};
pub use std::error::Error;
let commands = &*format!(
"
@ -93,10 +93,11 @@ pub fn setup_playground_for(topic: &str) -> (String, String) {
}
pub fn file_contents(full_path: &str) -> String {
let mut file = std::fs::File::open(full_path).expect("can not open file");
let mut contents = String::new();
file.read_to_string(&mut contents).expect("can not read file");
contents
let mut file = std::fs::File::open(full_path).expect("can not open file");
let mut contents = String::new();
file.read_to_string(&mut contents)
.expect("can not read file");
contents
}
pub fn create_file_at(full_path: &str) {
@ -112,7 +113,14 @@ pub fn delete_directory_at(full_path: &str) {
}
pub fn create_directory_at(full_path: &str) {
std::fs::create_dir(PathBuf::from(full_path)).expect("can not create directory");
let path = PathBuf::from(full_path);
println!("{:?} - is_dir: {:?}", path, path.is_dir());
if !path.is_dir() {
std::fs::create_dir_all(PathBuf::from(full_path))
.expect(&format!("can not create directory {:?}", full_path));
}
}
pub fn executable_path() -> PathBuf {