From 68cac26f212e1a82511b0cf3c2ba8f9de407f6c7 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Mon, 21 Oct 2024 12:38:19 +0200 Subject: [PATCH] Set a SEQUOIA_HOME directory for the subplot tests. --- subplot/sq-subplot.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/subplot/sq-subplot.rs b/subplot/sq-subplot.rs index c0cdca75..e6baf3e6 100644 --- a/subplot/sq-subplot.rs +++ b/subplot/sq-subplot.rs @@ -1,13 +1,15 @@ // Rust support for running sq-subplot.md scenarios. use subplotlib::file::SubplotDataFile; +use subplotlib::steplibrary::datadir::Datadir; use subplotlib::steplibrary::runcmd::Runcmd; use std::collections::HashMap; -use std::path::Path; +use std::path::{Path, PathBuf}; #[step] #[context(Runcmd)] +#[context(Datadir)] fn install_sq(context: &ScenarioContext) { // The SQ_DIR variable can be set to test an installed sq rather // than the one built from the source tree. @@ -33,6 +35,22 @@ fn install_sq(context: &ScenarioContext) { false, )?; } + + // Create a state directory and set SEQUOIA_HOME so that sq will + // use it. + let home = PathBuf::from(".sequoia-home"); + let mut absolute_home = Default::default(); + context.with_mut( + |datadir: &mut Datadir| { + datadir.create_dir_all(&home)?; + absolute_home = datadir.base_path().join(home); + Ok(()) + }, false)?; + context.with_mut( + |runcmd: &mut Runcmd| { + runcmd.setenv("SEQUOIA_HOME", absolute_home); + Ok(()) + }, false)?; } /// Remember values between steps.