diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-08-26 15:04:24 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-26 15:04:24 -0400 |
commit | 657b6a882daf6196661ef512b06c14ef7741a22c (patch) | |
tree | b73cf79174b1969727c48f7d28788b6265cb6485 | |
parent | 27413afbff4662b5793af407c67df253044cec77 (diff) | |
parent | ef55c2c981ee543d852d05b36231d0d10bcefde8 (diff) | |
download | ostree-657b6a882daf6196661ef512b06c14ef7741a22c.tar.gz |
Merge pull request #2183 from cgwalters/sh-inline-crates
tests/inst: Update to published sh-inline crate
-rw-r--r-- | tests/inst/Cargo.toml | 3 | ||||
-rw-r--r-- | tests/inst/src/destructive.rs | 24 | ||||
-rw-r--r-- | tests/inst/src/repobin.rs | 10 | ||||
-rw-r--r-- | tests/inst/src/test.rs | 9 | ||||
-rw-r--r-- | tests/inst/src/treegen.rs | 6 |
5 files changed, 27 insertions, 25 deletions
diff --git a/tests/inst/Cargo.toml b/tests/inst/Cargo.toml index b361accc..31b43b4e 100644 --- a/tests/inst/Cargo.toml +++ b/tests/inst/Cargo.toml @@ -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" diff --git a/tests/inst/src/destructive.rs b/tests/inst/src/destructive.rs index d1ebe35d..d6977bff 100644 --- a/tests/inst/src/destructive.rs +++ b/tests/inst/src/destructive.rs @@ -20,10 +20,10 @@ //! 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 diff --git a/tests/inst/src/repobin.rs b/tests/inst/src/repobin.rs index b034326a..2180e81f 100644 --- a/tests/inst/src/repobin.rs +++ b/tests/inst/src/repobin.rs @@ -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() diff --git a/tests/inst/src/test.rs b/tests/inst/src/test.rs index 6e3a63c0..9d8e156c 100644 --- a/tests/inst/src/test.rs +++ b/tests/inst/src/test.rs @@ -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(()) } diff --git a/tests/inst/src/treegen.rs b/tests/inst/src/treegen.rs index d4c8bd71..975db472 100644 --- a/tests/inst/src/treegen.rs +++ b/tests/inst/src/treegen.rs @@ -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(()) } |