diff --git a/Cargo.lock b/Cargo.lock index a2c2d00a79..64d3b09d43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1711,16 +1711,6 @@ dependencies = [ "serde", ] -[[package]] -name = "hamcrest2" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f837c62de05dc9cc71ff6486cd85de8856a330395ae338a04bfcefe5e91075" -dependencies = [ - "num 0.2.1", - "regex", -] - [[package]] name = "hash32" version = "0.3.1" @@ -2813,7 +2803,7 @@ dependencies = [ "nu-engine", "nu-parser", "nu-protocol", - "num 0.4.1", + "num", "polars", "polars-arrow", "polars-io", @@ -3171,7 +3161,6 @@ dependencies = [ name = "nu-test-support" version = "0.91.1" dependencies = [ - "hamcrest2", "nu-glob", "nu-path", "nu-utils", @@ -3262,42 +3251,17 @@ dependencies = [ "nu-protocol", ] -[[package]] -name = "num" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36" -dependencies = [ - "num-bigint 0.2.6", - "num-complex 0.2.4", - "num-integer", - "num-iter", - "num-rational 0.2.4", - "num-traits", -] - [[package]] name = "num" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" dependencies = [ - "num-bigint 0.4.4", - "num-complex 0.4.4", + "num-bigint", + "num-complex", "num-integer", "num-iter", - "num-rational 0.4.1", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" -dependencies = [ - "autocfg", - "num-integer", + "num-rational", "num-traits", ] @@ -3312,16 +3276,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-complex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" -dependencies = [ - "autocfg", - "num-traits", -] - [[package]] name = "num-complex" version = "0.4.4" @@ -3362,18 +3316,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-rational" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" -dependencies = [ - "autocfg", - "num-bigint 0.2.6", - "num-integer", - "num-traits", -] - [[package]] name = "num-rational" version = "0.4.1" @@ -3381,7 +3323,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", - "num-bigint 0.4.4", + "num-bigint", "num-integer", "num-traits", ] diff --git a/crates/nu-test-support/Cargo.toml b/crates/nu-test-support/Cargo.toml index c65e7acc26..126f03ddc0 100644 --- a/crates/nu-test-support/Cargo.toml +++ b/crates/nu-test-support/Cargo.toml @@ -19,4 +19,3 @@ nu-utils = { path = "../nu-utils", version = "0.91.1" } num-format = "0.4" which = { workspace = true } tempfile = { workspace = true } -hamcrest2 = "0.3" diff --git a/crates/nu-test-support/src/playground.rs b/crates/nu-test-support/src/playground.rs index caeb4f26cf..375f192983 100644 --- a/crates/nu-test-support/src/playground.rs +++ b/crates/nu-test-support/src/playground.rs @@ -1,5 +1,4 @@ mod director; -pub mod matchers; pub mod nu_process; mod play; @@ -7,6 +6,5 @@ mod play; mod tests; pub use director::Director; -pub use matchers::says; pub use nu_process::{Executable, NuProcess, NuResult, Outcome}; pub use play::{Dirs, EnvironmentVariable, Playground}; diff --git a/crates/nu-test-support/src/playground/director.rs b/crates/nu-test-support/src/playground/director.rs index d70b00316a..3d04155c25 100644 --- a/crates/nu-test-support/src/playground/director.rs +++ b/crates/nu-test-support/src/playground/director.rs @@ -60,15 +60,14 @@ impl Director { process.cwd(working_directory); } - process.arg("--skip-plugins"); process.arg("--no-history"); if let Some(config_file) = self.config.as_ref() { process.args(&[ - "--config-file", + "--config", config_file.to_str().expect("failed to convert."), ]); } - process.arg("--perf"); + process.args(&["--log-level", "info"]); director.executable = Some(process); director diff --git a/crates/nu-test-support/src/playground/matchers.rs b/crates/nu-test-support/src/playground/matchers.rs deleted file mode 100644 index 1f8dad1bec..0000000000 --- a/crates/nu-test-support/src/playground/matchers.rs +++ /dev/null @@ -1,102 +0,0 @@ -use hamcrest2::core::{MatchResult, Matcher}; -use std::fmt; -use std::str; - -use super::nu_process::Outcome; -use super::{Director, Executable}; - -#[derive(Clone)] -pub struct Play { - stdout_expectation: Option, -} - -impl fmt::Display for Play { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "play") - } -} - -impl fmt::Debug for Play { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "play") - } -} - -pub fn says() -> Play { - Play { - stdout_expectation: None, - } -} - -trait CheckerMatchers { - fn output(&self, actual: &Outcome) -> MatchResult; - fn std(&self, actual: &[u8], expected: Option<&str>, description: &str) -> MatchResult; - fn stdout(&self, actual: &Outcome) -> MatchResult; -} - -impl CheckerMatchers for Play { - fn output(&self, actual: &Outcome) -> MatchResult { - self.stdout(actual) - } - - fn stdout(&self, actual: &Outcome) -> MatchResult { - self.std(&actual.out, self.stdout_expectation.as_deref(), "stdout") - } - - fn std(&self, actual: &[u8], expected: Option<&str>, description: &str) -> MatchResult { - let out = match expected { - Some(out) => out, - None => return Ok(()), - }; - let actual = - str::from_utf8(actual).map_err(|_| format!("{description} was not utf8 encoded"))?; - - if actual != out { - return Err(format!( - "not equal:\n actual: {actual}\n expected: {out}\n\n" - )); - } - - Ok(()) - } -} - -impl Matcher for Play { - fn matches(&self, output: Outcome) -> MatchResult { - self.output(&output) - } -} - -impl Matcher for Play { - fn matches(&self, mut director: Director) -> MatchResult { - self.matches(&mut director) - } -} - -impl<'a> Matcher<&'a mut Director> for Play { - fn matches(&self, director: &'a mut Director) -> MatchResult { - if director.executable().is_none() { - return Err(format!("no such process {director}")); - } - - let res = director.execute(); - - match res { - Ok(out) => self.output(&out), - Err(err) => { - if let Some(out) = &err.output { - return self.output(out); - } - - Err(format!("could not exec process {director}: {err:?}")) - } - } - } -} - -impl Play { - pub fn stdout(mut self, expected: &str) -> Self { - self.stdout_expectation = Some(expected.to_string()); - self - } -} diff --git a/crates/nu-test-support/src/playground/play.rs b/crates/nu-test-support/src/playground/play.rs index d81899c5fc..6e229e0c8f 100644 --- a/crates/nu-test-support/src/playground/play.rs +++ b/crates/nu-test-support/src/playground/play.rs @@ -25,7 +25,7 @@ pub struct Playground<'a> { root: TempDir, tests: String, cwd: PathBuf, - config: PathBuf, + config: Option, environment_vars: Vec, dirs: &'a Dirs, } @@ -42,10 +42,6 @@ impl Dirs { self.fixtures.join("formats") } - pub fn config_fixtures(&self) -> PathBuf { - self.fixtures.join("playground/config") - } - pub fn root(&self) -> &Path { self.root.as_path() } @@ -97,7 +93,7 @@ impl<'a> Playground<'a> { root, tests: topic.to_string(), cwd: nuplay_dir, - config: fixtures.join("playground/config/default.toml"), + config: None, environment_vars: Vec::default(), dirs: &Dirs::default(), }; @@ -135,7 +131,7 @@ impl<'a> Playground<'a> { } pub fn with_config(&mut self, source_file: impl AsRef) -> &mut Self { - self.config = source_file.as_ref().to_path_buf(); + self.config = Some(source_file.as_ref().to_path_buf()); self } @@ -145,14 +141,16 @@ impl<'a> Playground<'a> { self } - pub fn get_config(&self) -> &str { - self.config.to_str().expect("could not convert path.") + pub fn get_config(&self) -> Option<&str> { + self.config + .as_ref() + .map(|cfg| cfg.to_str().expect("could not convert path.")) } pub fn build(&mut self) -> Director { Director { cwd: Some(self.dirs.test().into()), - config: Some(self.config.clone().into()), + config: self.config.clone().map(|cfg| cfg.into()), environment_vars: self.environment_vars.clone(), ..Default::default() } diff --git a/tests/fixtures/playground/config/default.toml b/tests/fixtures/playground/config/default.toml deleted file mode 100644 index 5939aacd41..0000000000 --- a/tests/fixtures/playground/config/default.toml +++ /dev/null @@ -1,3 +0,0 @@ -skip_welcome_message = true -filesize_format = "auto" -rm_always_trash = false diff --git a/tests/fixtures/playground/config/startup.toml b/tests/fixtures/playground/config/startup.toml deleted file mode 100644 index c4b9e06785..0000000000 --- a/tests/fixtures/playground/config/startup.toml +++ /dev/null @@ -1,3 +0,0 @@ -skip_welcome_message = true - -startup = ["def hello-world [] { echo 'Nu World' }"]