diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-12-10 09:05:11 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-12-10 09:07:10 +0200 |
commit | 07fb523edb88ed258243869ab474ee7a24e1e4de (patch) | |
tree | 0cac21072c9c7ab6096000f5d85db1455caa26ae | |
parent | d7ede939445fc73b782424c9e73fdadfcf4d4360 (diff) | |
download | pandoc-filter-diagram-07fb523edb88ed258243869ab474ee7a24e1e4de.tar.gz |
test: add implementation, running of Subplot scenarios
Sponsored-by: author
-rw-r--r-- | build.rs | 7 | ||||
-rw-r--r-- | subplot/subplot.rs | 30 | ||||
-rw-r--r-- | subplot/subplot.yaml | 4 | ||||
-rw-r--r-- | tests/subplot.rs | 1 |
4 files changed, 42 insertions, 0 deletions
diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..fac2fff --- /dev/null +++ b/build.rs @@ -0,0 +1,7 @@ +use std::path::Path; + +fn main() { + println!("{:#?}", std::env::vars()); + subplot_build::codegen(Path::new("pandoc-filter-diagram.md")) + .expect("failed to generate code with 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 diff --git a/tests/subplot.rs b/tests/subplot.rs new file mode 100644 index 0000000..465b459 --- /dev/null +++ b/tests/subplot.rs @@ -0,0 +1 @@ +include!(concat!(env!("OUT_DIR"), "/pandoc-filter-diagram.rs")); |