summaryrefslogtreecommitdiffstats
path: root/sq/subplot
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-08-02 15:53:57 +0300
committerLars Wirzenius <liw@sequoia-pgp.org>2021-10-27 16:31:43 +0300
commit8757edc9f4a8db88d6dd9579c0f423683f547d36 (patch)
tree26d6fa75bf7bbd9e6650dcdc2ae74c16559a089b /sq/subplot
parent463b8702ab672e1f528968f46f81b8cfdf2005c8 (diff)
sq: add scaffolding for an integration/acceptance test suite
Add support for an integration and acceptance test suite using the Subplot tool (https://subplot.liw.fi/). There are the initial, very simple test scenarios, to get us started. The goal is to introduce the scaffolding for integration tests, so that further tests can be added with ease later. The tests are documented and defined in sq-subplot.md. In build.rs, we call Subplot to generate test code from the markdown file. The tests are run via "cargo test", as usual. Subplot can also generate a typeset test document from sq-subplot.md, but we don't do that here.
Diffstat (limited to 'sq/subplot')
-rw-r--r--sq/subplot/sq-subplot.rs34
-rw-r--r--sq/subplot/sq-subplot.yaml4
2 files changed, 38 insertions, 0 deletions
diff --git a/sq/subplot/sq-subplot.rs b/sq/subplot/sq-subplot.rs
new file mode 100644
index 00000000..dba22e9e
--- /dev/null
+++ b/sq/subplot/sq-subplot.rs
@@ -0,0 +1,34 @@
+// Rust support for running sq-subplot.md scenarios.
+
+use subplotlib::steplibrary::runcmd::Runcmd;
+
+use std::path::Path;
+
+#[step]
+#[context(Runcmd)]
+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.
+ if let Some(bindir) = std::env::var_os("SQ_DIR") {
+ println!("Found SQ_DIR environment variable, using that");
+ context.with_mut(
+ |rc: &mut Runcmd| {
+ rc.prepend_to_path(bindir);
+ Ok(())
+ },
+ false,
+ )?;
+ } else {
+ let target_exe = env!("CARGO_BIN_EXE_sq");
+ let target_path = Path::new(target_exe);
+ let target_path = target_path.parent().ok_or("No parent?")?;
+
+ context.with_mut(
+ |context: &mut Runcmd| {
+ context.prepend_to_path(target_path);
+ Ok(())
+ },
+ false,
+ )?;
+ }
+}
diff --git a/sq/subplot/sq-subplot.yaml b/sq/subplot/sq-subplot.yaml
new file mode 100644
index 00000000..084d7e2e
--- /dev/null
+++ b/sq/subplot/sq-subplot.yaml
@@ -0,0 +1,4 @@
+- given: "an installed sq"
+ impl:
+ rust:
+ function: install_sq