summaryrefslogtreecommitdiff
path: root/src/summain.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-01-05 08:39:37 +0000
committerLars Wirzenius <liw@liw.fi>2022-01-05 08:39:37 +0000
commit5fbd5a2ee98badc71867d2e7fce4d1429189267a (patch)
treee16886fb2e0e443d6bb02b99375c66d8f40cd96b /src/summain.rs
parent945b7cb605691889cef4d81e421816e55243c95b (diff)
parentf368595170ccfe9689b7ce2da9e26454d9bd4edb (diff)
downloadobnam-benchmark-5fbd5a2ee98badc71867d2e7fce4d1429189267a.tar.gz
Merge branch 'summain-try2' into 'main'
test: be quiet unless test.py fails See merge request obnam/obnam-benchmark!5
Diffstat (limited to 'src/summain.rs')
-rw-r--r--src/summain.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/summain.rs b/src/summain.rs
new file mode 100644
index 0000000..ce9cf0f
--- /dev/null
+++ b/src/summain.rs
@@ -0,0 +1,25 @@
+use std::path::Path;
+use std::process::Command;
+
+#[derive(Debug, thiserror::Error)]
+pub enum SummainError {
+ #[error("failed to run summain: {0}")]
+ Run(std::io::Error),
+}
+
+pub fn summain(root: &Path) -> Result<String, SummainError> {
+ let output = Command::new("summain")
+ .arg(".")
+ .current_dir(root)
+ .output()
+ .map_err(SummainError::Run)?;
+ if output.status.code() != Some(0) {
+ eprintln!("{}", String::from_utf8_lossy(&output.stdout));
+ eprintln!("{}", String::from_utf8_lossy(&output.stderr));
+ std::process::exit(1);
+ }
+
+ Ok(String::from_utf8_lossy(&output.stdout)
+ .to_owned()
+ .to_string())
+}