From afc6fccc9c846f3bf1609b4a540850dfb77724a9 Mon Sep 17 00:00:00 2001 From: Anda Elena Sucitu <120498561+Anda275@users.noreply.github.com> Date: Tue, 9 Jan 2024 17:36:09 +0000 Subject: [PATCH 1/2] TODO: determine if this is necessary or not, since this breaks `rm` on macOS --- src/terminal.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/terminal.rs b/src/terminal.rs index 9a653647e6bc2..8f7ab5c31be22 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -38,6 +38,9 @@ pub(crate) fn acquire_terminal(interactive: bool) { // TODO: determine if this is necessary or not, since this breaks `rm` on macOS // signal(Signal::SIGCHLD, SigHandler::SigIgn).expect("signal ignore"); + #[cfg(not(target_os = "macos"))] + signal(Signal::SIGCHLD, SigHandler::SigIgn).expect("signal ignore"); + signal_hook::low_level::register(signal_hook::consts::SIGTERM, || { // Safety: can only call async-signal-safe functions here // restore_terminal, signal, and raise are all async-signal-safe From 583c2352147f1ca179ce1e81443b5c33ee76c739 Mon Sep 17 00:00:00 2001 From: Anda Elena Sucitu <120498561+Anda275@users.noreply.github.com> Date: Thu, 11 Jan 2024 20:48:36 +0000 Subject: [PATCH 2/2] TODO: consider adding custom plugin path for tests to not interfere with user local environment --- crates/nu-test-support/src/macros.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/nu-test-support/src/macros.rs b/crates/nu-test-support/src/macros.rs index d0957355f1c89..37ba0064a7c0c 100644 --- a/crates/nu-test-support/src/macros.rs +++ b/crates/nu-test-support/src/macros.rs @@ -72,10 +72,10 @@ macro_rules! nu { // For all other options, we call `.into()` on the `$value` and hope for the best. ;) ( @options [ $($options:tt)* ] - $field:ident : $value:expr, + custom_plugin_path: $value:expr, $($rest:tt)* ) => { - nu!(@options [ $($options)* $field => $value.into() ; ] $($rest)*) + nu!(@options [ $($options)* custom_plugin_path => $value.into() ; ] $($rest)*) }; // When the `$field: $value,` pairs are all parsed, the next tokens are the `$path` and any @@ -223,6 +223,7 @@ use tempfile::tempdir; pub struct NuOpts { pub cwd: Option, pub locale: Option, + pub custom_plugin_path: Option, //for custom plugin path } pub fn nu_run_test(opts: NuOpts, commands: impl AsRef, with_std: bool) -> Outcome { @@ -282,7 +283,7 @@ pub fn nu_run_test(opts: NuOpts, commands: impl AsRef, with_std: bool) -> O Outcome::new(out, err.into_owned(), output.status) } -pub fn nu_with_plugin_run_test(cwd: impl AsRef, plugins: &[&str], command: &str) -> Outcome { +pub fn nu_with_plugin_run_test(cwd: impl AsRef, opts: NuOpts,plugins: &[&str], command: &str) -> Outcome { let test_bins = crate::fs::binaries(); let test_bins = nu_path::canonicalize_with(&test_bins, ".").unwrap_or_else(|e| { panic!( @@ -297,6 +298,7 @@ pub fn nu_with_plugin_run_test(cwd: impl AsRef, plugins: &[&str], command: std::fs::File::create(&temp_plugin_file).expect("couldn't create temporary plugin file"); crate::commands::ensure_plugins_built(); + use crate::fs::executable_path; let registrations: String = plugins .iter() @@ -309,6 +311,11 @@ pub fn nu_with_plugin_run_test(cwd: impl AsRef, plugins: &[&str], command: output }); let commands = format!("{registrations}{command}"); + //solving TODO + let mut command = Command::new(executable_path()); + if let Some(plugin_path) = opts.custom_plugin_path { + command.env("NU_PLUGIN_PATH", plugin_path); + } let target_cwd = crate::fs::in_directory(&cwd); // In plugin testing, we need to use installed nushell to drive