diff options
Diffstat (limited to 'subplotlib/src/steplibrary/runcmd.rs')
-rw-r--r-- | subplotlib/src/steplibrary/runcmd.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/subplotlib/src/steplibrary/runcmd.rs b/subplotlib/src/steplibrary/runcmd.rs index b90f8b7..6692441 100644 --- a/subplotlib/src/steplibrary/runcmd.rs +++ b/subplotlib/src/steplibrary/runcmd.rs @@ -56,7 +56,9 @@ static DEFAULT_PATHS: &[&str] = &[ ]; // This us used internally to force CWD for running commands -const USE_CWD: &str = "\0USE_CWD"; +lazy_static! { + static ref USE_CWD: PathBuf = PathBuf::from("\0USE_CWD"); +} impl ContextElement for Runcmd { fn scenario_starts(&mut self) -> StepResult { @@ -229,7 +231,7 @@ pub fn run(context: &ScenarioContext, argv0: &str, args: &str) { #[step] #[context(Datadir)] #[context(Runcmd)] -pub fn run_in(context: &ScenarioContext, dirname: &str, argv0: &str, args: &str) { +pub fn run_in(context: &ScenarioContext, dirname: &Path, argv0: &str, args: &str) { try_to_run_in::call(context, dirname, argv0, args)?; exit_code_is::call(context, 0)?; } @@ -244,7 +246,7 @@ pub fn run_in(context: &ScenarioContext, dirname: &str, argv0: &str, args: &str) #[context(Datadir)] #[context(Runcmd)] pub fn try_to_run(context: &ScenarioContext, argv0: &str, args: &str) { - try_to_run_in::call(context, USE_CWD, argv0, args)?; + try_to_run_in::call(context, &USE_CWD, argv0, args)?; } /// Run the given command in the given subpath of the data directory @@ -256,7 +258,7 @@ pub fn try_to_run(context: &ScenarioContext, argv0: &str, args: &str) { #[step] #[context(Datadir)] #[context(Runcmd)] -pub fn try_to_run_in(context: &ScenarioContext, dirname: &str, argv0: &str, args: &str) { +pub fn try_to_run_in(context: &ScenarioContext, dirname: &Path, argv0: &str, args: &str) { // This is the core of runcmd and is how we handle things let argv0: PathBuf = if argv0.starts_with('.') { context.with( @@ -270,7 +272,7 @@ pub fn try_to_run_in(context: &ScenarioContext, dirname: &str, argv0: &str, args |datadir: &Datadir| Ok(datadir.base_path().to_path_buf()), false, )?; - if dirname != USE_CWD { + if dirname != USE_CWD.as_path() { datadir = datadir.join(dirname); } let mut proc = Command::new(&argv0); |