tests/inst: Update to published sh-inline crate
authorColin Walters <walters@verbum.org>
Wed, 26 Aug 2020 17:00:19 +0000 (17:00 +0000)
committerColin Walters <walters@verbum.org>
Wed, 26 Aug 2020 17:00:19 +0000 (17:00 +0000)
And I made a few more API tweaks, such as supporting `Path`
objects directly and also not needing e.g. `commit = commit`, see

- https://github.com/cgwalters/rust-sh-inline/commit/cfa7c71126f23545a7d4782cad650eab60e74204
- https://github.com/cgwalters/rust-sh-inline/commit/679bce4cc7ce65641e0c9bd33654510575583de8

tests/inst/Cargo.toml
tests/inst/src/destructive.rs
tests/inst/src/repobin.rs
tests/inst/src/test.rs
tests/inst/src/treegen.rs

index b361accc8075f0c3126931acdbc44f01d46d0e78..31b43b4e7070d52301d96c66b1e2d42ca105abe5 100644 (file)
@@ -14,8 +14,7 @@ structopt = "0.3"
 serde = "1.0.111"
 serde_derive = "1.0.111"
 serde_json = "1.0"
-# To be published on crates.io soon
-sh-inline = { git = "https://github.com/cgwalters/rust-sh-inline" }
+sh-inline = "0.1.0"
 anyhow = "1.0"
 tempfile = "3.1.0"
 glib = "0.10"
index d1ebe35d4c82d7814a44e782203e806457dd6720..d6977bffc9f69c5237614eedf1ded3a6cd02b27c 100644 (file)
 //! AUTOPKGTEST_REBOOT_MARK.
 
 use anyhow::{Context, Result};
-use sh_inline::bash;
 use rand::seq::SliceRandom;
 use rand::Rng;
 use serde::{Deserialize, Serialize};
+use sh_inline::bash;
 use std::collections::BTreeMap;
 use std::io::Write;
 use std::path::Path;
@@ -305,10 +305,7 @@ fn parse_and_validate_reboot_mark<M: AsRef<str>>(
 fn validate_pending_commit(pending_commit: &str, commitstates: &CommitStates) -> Result<()> {
     if pending_commit != commitstates.target {
         bash!("rpm-ostree status -v")?;
-        bash!(
-            "ostree show {pending_commit}",
-            pending_commit = pending_commit
-        )?;
+        bash!("ostree show {pending_commit}", pending_commit)?;
         anyhow::bail!(
             "Expected target commit={} but pending={} ({:?})",
             commitstates.target,
@@ -455,6 +452,7 @@ fn impl_transaction_test<M: AsRef<str>>(
         );
         // Reset the target ref to booted, and perform a cleanup
         // to ensure we're re-downloading objects each time
+        let testref = TESTREF;
         bash!(
             "
             systemctl stop rpm-ostreed
@@ -462,8 +460,8 @@ fn impl_transaction_test<M: AsRef<str>>(
             ostree reset testrepo:{testref} {booted_commit}
             rpm-ostree cleanup -pbrm
             ",
-            testref = TESTREF,
-            booted_commit = booted_commit
+            testref,
+            booted_commit,
         )
         .with_context(|| {
             format!(
@@ -569,7 +567,7 @@ fn transactionality() -> Result<()> {
         bash!(
             "ostree remote delete --if-exists testrepo
              ostree remote add --set=gpg-verify=false testrepo {url}",
-            url = url
+            url
         )?;
 
         if firstrun {
@@ -582,16 +580,18 @@ fn transactionality() -> Result<()> {
             generate_update(&commit)?;
             // Directly set the origin, so that we're not dependent on the pending deployment.
             // FIXME: make this saner
+            let origref = ORIGREF;
+            let testref = TESTREF;
             bash!(
                 "
                 ostree admin set-origin testrepo {url} {testref}
                 ostree refs --create testrepo:{testref} {commit}
                 ostree refs --create={origref} {commit}
                 ",
-                url = url,
-                origref = ORIGREF,
-                testref = TESTREF,
-                commit = commit
+                url,
+                origref,
+                testref,
+                commit
             )?;
             // We gather a single "cycle time" at start as a way of gauging how
             // long an upgrade should take, so we know when to interrupt.  This
index b034326a3f115c2fc61975bbf7b33601224cc7aa..2180e81fe6741395fa8266a3971c51040c826ce9 100644 (file)
@@ -5,7 +5,7 @@ use std::path::Path;
 
 use crate::test::*;
 use anyhow::{Context, Result};
-use sh_inline::{bash_command, bash};
+use sh_inline::{bash, bash_command};
 use with_procspawn_tempdir::with_procspawn_tempdir;
 
 #[itest]
@@ -45,9 +45,7 @@ fn test_mtime() -> Result<()> {
 "
     )?;
     let ts = Path::new("repo").metadata()?.modified().unwrap();
-    bash!(
-        r#"ostree --repo=repo commit -b test -s "bump mtime" --tree=dir=tmproot >/dev/null"#
-    )?;
+    bash!(r#"ostree --repo=repo commit -b test -s "bump mtime" --tree=dir=tmproot >/dev/null"#)?;
     assert_ne!(ts, Path::new("repo").metadata()?.modified().unwrap());
     Ok(())
 }
@@ -88,8 +86,8 @@ fn test_pull_basicauth() -> Result<()> {
         ostree --repo=repo remote add --set=gpg-verify=false origin-badauth {unauthuri}
         ostree --repo=repo remote add --set=gpg-verify=false origin-goodauth {authuri}
         "#,
-            osroot = osroot.to_str(),
-            serverrepo = serverrepo.to_str(),
+            osroot = osroot,
+            serverrepo = serverrepo,
             baseuri = baseuri.to_string(),
             unauthuri = unauthuri.to_string(),
             authuri = authuri.to_string()
index 6e3a63c0795fe69ccec04881d4065838ae230bd8..9d8e156c4782548afbede2b165c2967d6661be62 100644 (file)
@@ -237,8 +237,13 @@ mod tests {
     fn test_output() -> Result<()> {
         cmd_has_output(Command::new("true"), "")?;
         assert!(cmd_has_output(Command::new("true"), "foo").is_err());
-        cmd_has_output(sh_inline::bash_command!("echo foobarbaz; echo fooblahbaz").unwrap(), "blah")?;
-        assert!(cmd_has_output(sh_inline::bash_command!("echo foobarbaz").unwrap(), "blah").is_err());
+        cmd_has_output(
+            sh_inline::bash_command!("echo foobarbaz; echo fooblahbaz").unwrap(),
+            "blah",
+        )?;
+        assert!(
+            cmd_has_output(sh_inline::bash_command!("echo foobarbaz").unwrap(), "blah").is_err()
+        );
         Ok(())
     }
 
index d4c8bd71e49f31126b92f91ec273acd869867194..975db4723b2af77ae8f5948c728ba8edb0596421 100644 (file)
@@ -1,7 +1,7 @@
 use anyhow::{Context, Result};
-use sh_inline::bash;
 use openat_ext::{FileExt, OpenatDirExt};
 use rand::Rng;
+use sh_inline::bash;
 use std::fs::File;
 use std::io::prelude::*;
 use std::os::unix::fs::FileExt as UnixFileExt;
@@ -141,8 +141,8 @@ pub(crate) fn update_os_tree<P: AsRef<Path>>(
     assert!(mutated > 0);
     println!("Mutated ELF files: {}", mutated);
     bash!("ostree --repo={repo} commit --consume -b {ostref} --base={ostref} --tree=dir={tempdir} --owner-uid 0 --owner-gid 0 --selinux-policy-from-base --link-checkout-speedup --no-bindings --no-xattrs",
-        repo = repo_path.to_str().unwrap(),
+        repo = repo_path,
         ostref = ostref,
-        tempdir = tempdir.path().to_str().unwrap()).context("Failed to commit updated content")?;
+        tempdir = tempdir.path()).context("Failed to commit updated content")?;
     Ok(())
 }