diff options
-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")); |