Set a SEQUOIA_HOME directory for the subplot tests.

This commit is contained in:
Justus Winter 2024-10-21 12:38:19 +02:00
parent bcb5c39aca
commit 68cac26f21
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386

View File

@ -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.