|
1 | 1 | //! Command execution for Pop CLI |
2 | 2 |
|
3 | | -#[cfg(feature = "pop-e2e")] |
4 | | -use std::ffi::OsString; |
5 | 3 | #[cfg(feature = "pop-e2e")] |
6 | 4 | use std::path::PathBuf; |
7 | 5 | use std::process::Command; |
@@ -43,49 +41,31 @@ impl CommandOutput { |
43 | 41 | /// Real implementation of Pop CLI command executor. |
44 | 42 | /// |
45 | 43 | /// When the `pop-e2e` feature is enabled, the executor supports optional |
46 | | -/// working directory and environment overrides for test isolation. |
| 44 | +/// working directory override for test isolation. |
47 | 45 | #[derive(Debug, Clone, Default)] |
48 | 46 | pub struct PopExecutor { |
49 | | - /// Override working directory for command execution (pop-e2e only). |
50 | 47 | #[cfg(feature = "pop-e2e")] |
51 | 48 | cwd: Option<PathBuf>, |
52 | | - /// Environment variable overrides (pop-e2e only). |
53 | | - #[cfg(feature = "pop-e2e")] |
54 | | - env: Vec<(OsString, OsString)>, |
55 | 49 | } |
56 | 50 |
|
57 | 51 | impl PopExecutor { |
58 | 52 | pub fn new() -> Self { |
59 | 53 | Self::default() |
60 | 54 | } |
61 | 55 |
|
62 | | - /// Create an executor with working directory and environment overrides. |
63 | | - /// |
64 | | - /// This is only available in `pop-e2e` builds for test isolation. |
| 56 | + /// Create an executor with a working directory override. |
65 | 57 | #[cfg(feature = "pop-e2e")] |
66 | | - pub fn with_overrides( |
67 | | - cwd: Option<PathBuf>, |
68 | | - env: impl IntoIterator<Item = (impl Into<OsString>, impl Into<OsString>)>, |
69 | | - ) -> Self { |
70 | | - Self { |
71 | | - cwd, |
72 | | - env: env.into_iter().map(|(k, v)| (k.into(), v.into())).collect(), |
73 | | - } |
| 58 | + pub fn with_cwd(cwd: PathBuf) -> Self { |
| 59 | + Self { cwd: Some(cwd) } |
74 | 60 | } |
75 | 61 |
|
76 | 62 | fn execute_raw(&self, args: &[&str]) -> PopMcpResult<CommandOutput> { |
77 | 63 | let mut cmd = Command::new("pop"); |
78 | 64 | cmd.args(args); |
79 | 65 |
|
80 | | - // Apply overrides when pop-e2e feature is enabled |
81 | 66 | #[cfg(feature = "pop-e2e")] |
82 | | - { |
83 | | - if let Some(ref cwd) = self.cwd { |
84 | | - cmd.current_dir(cwd); |
85 | | - } |
86 | | - if !self.env.is_empty() { |
87 | | - cmd.envs(self.env.iter().map(|(k, v)| (k, v))); |
88 | | - } |
| 67 | + if let Some(ref cwd) = self.cwd { |
| 68 | + cmd.current_dir(cwd); |
89 | 69 | } |
90 | 70 |
|
91 | 71 | let output = cmd.output().map_err(|e| { |
|
0 commit comments