summaryrefslogtreecommitdiff
path: root/tests/subplots/common/runcmd_test.rs
blob: d3a7ca5a094f7d7baa4258d1c9490b02f63bbf17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::path::Path;
use subplotlib::steplibrary::files::{self, Datadir};
use subplotlib::steplibrary::runcmd::Runcmd;

#[cfg(unix)]
use std::os::unix::fs::PermissionsExt;

#[step]
#[context(Datadir)]
fn create_script_from_embedded(
    context: &ScenarioContext,
    filename: &Path,
    embedded: SubplotDataFile,
) {
    files::create_from_embedded_with_other_name::call(context, filename, embedded)?;
    let filename = context.with(|dd: &Datadir| dd.canonicalise_filename(filename), false)?;
    let mut perms = std::fs::symlink_metadata(&filename)?.permissions();
    #[cfg(unix)]
    perms.set_mode(perms.mode() | 0o111);
    std::fs::set_permissions(&filename, perms)?;
}

#[step]
fn prepend_to_path(context: &mut Runcmd, dirname: &Path) {
    context.prepend_to_path(dirname);
}