From 07fb523edb88ed258243869ab474ee7a24e1e4de Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 10 Dec 2021 09:05:11 +0200 Subject: test: add implementation, running of Subplot scenarios Sponsored-by: author --- subplot/subplot.rs | 30 ++++++++++++++++++++++++++++++ subplot/subplot.yaml | 4 ++++ 2 files changed, 34 insertions(+) create mode 100644 subplot/subplot.rs create mode 100644 subplot/subplot.yaml (limited to 'subplot') diff --git a/subplot/subplot.rs b/subplot/subplot.rs new file mode 100644 index 0000000..1496154 --- /dev/null +++ b/subplot/subplot.rs @@ -0,0 +1,30 @@ +// Rust support for running Subplot scenarios for +// pandoc-filter-diagram. + +use subplotlib::steplibrary::runcmd::Runcmd; + +use std::env; +use std::path::Path; + +#[step] +#[context(Runcmd)] +fn install_rust_program(context: &ScenarioContext, name: &str) { + println!("install_rust_program 1"); + println!("install_rust_program: name={:?}", name); + let target_dir = Path::new(env!("CARGO_TARGET_DIR")); + let exe = target_dir.join("debug").join(name); + println!("install_rust_program: exe={:?} {}", exe, exe.exists()); + assert!(exe.exists()); + println!("install_rust_program 2"); + let path = Path::new(&exe).parent().ok_or("No parent?")?; + println!("install_rust_program 3"); + + context.with_mut( + |context: &mut Runcmd| { + context.prepend_to_path(path); + Ok(()) + }, + false, + )?; + println!("install_rust_program 999"); +} diff --git a/subplot/subplot.yaml b/subplot/subplot.yaml new file mode 100644 index 0000000..14f5856 --- /dev/null +++ b/subplot/subplot.yaml @@ -0,0 +1,4 @@ +- given: an installed Rust program {name} + impl: + rust: + function: install_rust_program -- cgit v1.2.1