diff --git a/src/parser.rs b/src/parser.rs index 6600ba0..939b12c 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -509,7 +509,6 @@ impl<'a> Parser<'a> { mod test { use super::*; use crate::testing::parse_success; - use brev; macro_rules! summary_test { ($name:ident, $input:expr, $expected:expr $(,)*) => { @@ -1127,7 +1126,7 @@ f y=(`echo hello` + x) +z=("foo" + "bar"):"#, let mut justfiles = vec![]; let mut current = None; - for line in brev::slurp("README.adoc").lines() { + for line in fs::read_to_string("README.adoc").unwrap().lines() { if let Some(mut justfile) = current { if line == "```" { justfiles.push(justfile); diff --git a/src/run.rs b/src/run.rs index 1fd66d5..132e772 100644 --- a/src/run.rs +++ b/src/run.rs @@ -22,18 +22,6 @@ fn edit>(path: P) -> ! { } } -trait Slurp { - fn slurp(&mut self) -> Result; -} - -impl Slurp for fs::File { - fn slurp(&mut self) -> io::Result { - let mut destination = String::new(); - self.read_to_string(&mut destination)?; - Ok(destination) - } -} - pub fn run() { #[cfg(windows)] enable_ansi_support().ok(); @@ -274,9 +262,7 @@ pub fn run() { edit(justfile); } - text = fs::File::open(justfile) - .unwrap_or_else(|error| die!("Error opening justfile: {}", error)) - .slurp() + text = fs::read_to_string(justfile) .unwrap_or_else(|error| die!("Error reading justfile: {}", error)); if let Err(error) = env::set_current_dir(&directory) { @@ -323,10 +309,8 @@ pub fn run() { edit(name); } - text = fs::File::open(name) - .unwrap_or_else(|error| die!("Error opening justfile: {}", error)) - .slurp() - .unwrap_or_else(|error| die!("Error reading justfile: {}", error)); + text = + fs::read_to_string(name).unwrap_or_else(|error| die!("Error reading justfile: {}", error)); } let justfile = Parser::parse(&text).unwrap_or_else(|error| { diff --git a/tests/integration.rs b/tests/integration.rs index 395858d..33b8db3 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -56,11 +56,11 @@ fn integration_test( let mut justfile_path = tmp.path().to_path_buf(); justfile_path.push("justfile"); - brev::dump(justfile_path, justfile); + fs::write(justfile_path, justfile).unwrap(); let mut dotenv_path = tmp.path().to_path_buf(); dotenv_path.push(".env"); - brev::dump(dotenv_path, "DOTENV_KEY=dotenv-value"); + fs::write(dotenv_path, "DOTENV_KEY=dotenv-value").unwrap(); let mut child = Command::new(&executable_path("just")) .current_dir(tmp.path()) diff --git a/tests/interrupts.rs b/tests/interrupts.rs index 06050fe..835b609 100644 --- a/tests/interrupts.rs +++ b/tests/interrupts.rs @@ -2,6 +2,7 @@ mod unix { use executable_path::executable_path; use std::{ + fs, process::Command, time::{Duration, Instant}, }; @@ -23,7 +24,7 @@ mod unix { let mut justfile_path = tmp.path().to_path_buf(); justfile_path.push("justfile"); - brev::dump(justfile_path, justfile); + fs::write(justfile_path, justfile).unwrap(); let start = Instant::now(); diff --git a/tests/invocation_directory.rs b/tests/invocation_directory.rs index 5e3e7b3..22a2b5c 100644 --- a/tests/invocation_directory.rs +++ b/tests/invocation_directory.rs @@ -1,7 +1,5 @@ use executable_path::executable_path; -use std::path::Path; -use std::process; -use std::str; +use std::{fs, path::Path, process, str}; use tempdir::TempDir; #[cfg(unix)] @@ -34,14 +32,15 @@ fn test_invocation_directory() { let mut justfile_path = tmp.path().to_path_buf(); justfile_path.push("justfile"); - brev::dump( + fs::write( justfile_path, "default:\n @cd {{invocation_directory()}}\n @echo {{invocation_directory()}}", - ); + ) + .unwrap(); let mut subdir = tmp.path().to_path_buf(); subdir.push("subdir"); - brev::mkdir(&subdir); + fs::create_dir(&subdir).unwrap(); let output = process::Command::new(&executable_path("just")) .current_dir(&subdir) diff --git a/tests/search.rs b/tests/search.rs index 8ecca04..bbb05a4 100644 --- a/tests/search.rs +++ b/tests/search.rs @@ -26,7 +26,7 @@ fn test_justfile_search() { .expect("test justfile search: failed to create temporary directory"); let mut path = tmp.path().to_path_buf(); path.push("justfile"); - brev::dump(&path, "default:\n\techo ok"); + fs::write(&path, "default:\n\techo ok").unwrap(); path.pop(); path.push("a"); @@ -47,7 +47,7 @@ fn test_capitalized_justfile_search() { .expect("test justfile search: failed to create temporary directory"); let mut path = tmp.path().to_path_buf(); path.push("Justfile"); - brev::dump(&path, "default:\n\techo ok"); + fs::write(&path, "default:\n\techo ok").unwrap(); path.pop(); path.push("a"); @@ -68,16 +68,16 @@ fn test_capitalization_priority() { .expect("test justfile search: failed to create temporary directory"); let mut path = tmp.path().to_path_buf(); path.push("justfile"); - brev::dump(&path, "default:\n\techo ok"); + fs::write(&path, "default:\n\techo ok").unwrap(); path.pop(); path.push("Justfile"); - brev::dump(&path, "default:\n\techo fail"); + fs::write(&path, "default:\n\techo fail").unwrap(); path.pop(); // if we see "default\n\techo fail" in `justfile` then we're running // in a case insensitive filesystem, so just bail path.push("justfile"); - if brev::slurp(&path) == "default:\n\techo fail" { + if fs::read_to_string(&path).unwrap() == "default:\n\techo fail" { return; } path.pop(); @@ -100,14 +100,14 @@ fn test_upwards_path_argument() { .expect("test justfile search: failed to create temporary directory"); let mut path = tmp.path().to_path_buf(); path.push("justfile"); - brev::dump(&path, "default:\n\techo ok"); + fs::write(&path, "default:\n\techo ok").unwrap(); path.pop(); path.push("a"); fs::create_dir(&path).expect("test justfile search: failed to create intermediary directory"); path.push("justfile"); - brev::dump(&path, "default:\n\techo bad"); + fs::write(&path, "default:\n\techo bad").unwrap(); path.pop(); search_test(&path, &["../"]); @@ -120,14 +120,14 @@ fn test_downwards_path_argument() { .expect("test justfile search: failed to create temporary directory"); let mut path = tmp.path().to_path_buf(); path.push("justfile"); - brev::dump(&path, "default:\n\techo bad"); + fs::write(&path, "default:\n\techo bad").unwrap(); path.pop(); path.push("a"); fs::create_dir(&path).expect("test justfile search: failed to create intermediary directory"); path.push("justfile"); - brev::dump(&path, "default:\n\techo ok"); + fs::write(&path, "default:\n\techo ok").unwrap(); path.pop(); path.pop();