From 71194b54e4c742fa739624aeb65945ab477085af Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 17 May 2021 11:46:50 +0200 Subject: [PATCH] ditch anyhow crate in examples/tests mostly to shutup our current buildbot tests Signed-off-by: Wolfgang Bumiller --- Cargo.toml | 5 +---- examples/pxarcmd.rs | 16 ++++++++++++++-- tests/simple/fs.rs | 4 ++-- tests/simple/main.rs | 16 ++++++++++++++-- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c35ba0c..f586e5d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,6 @@ required-features = [ "async-example" ] [[example]] name = "pxarcmd" path = "examples/pxarcmd.rs" -required-features = [ "anyhow" ] [[example]] name = "mk-format-hashes" @@ -32,7 +31,7 @@ doc = false name = "simple" path = "tests/simple/main.rs" test = true -required-features = [ "anyhow", "test-harness" ] +required-features = [ "test-harness" ] [[test]] name = "compat" @@ -45,7 +44,6 @@ bitflags = "1.2.1" endian_trait = { version = "0.6", features = ["arrays"] } siphasher = "0.3" -anyhow = { version = "1.0", optional = true } tokio = { version = "1.0", optional = true, default-features = false } [target.'cfg(target_os = "linux")'.dependencies] @@ -59,7 +57,6 @@ tokio-fs = [ "tokio-io", "tokio/fs" ] full = [ "tokio-fs"] async-example = [ - "anyhow", "tokio-io", "tokio-fs", "tokio/rt-multi-thread", diff --git a/examples/pxarcmd.rs b/examples/pxarcmd.rs index 8585800..e0c779d 100644 --- a/examples/pxarcmd.rs +++ b/examples/pxarcmd.rs @@ -5,12 +5,24 @@ use std::os::linux::fs::MetadataExt; use std::os::unix::ffi::OsStrExt; use std::path::{Path, PathBuf}; -use anyhow::{bail, format_err, Error}; - use pxar::accessor::Accessor; use pxar::encoder::{Encoder, LinkOffset, SeqWrite}; use pxar::Metadata; +macro_rules! format_err { + ($($msg:tt)+) => { + std::io::Error::new(std::io::ErrorKind::Other, format!($($msg)+)) + }; +} + +macro_rules! bail { + ($($msg:tt)+) => {{ + return Err(format_err!($($msg)+).into()); + }}; +} + +type Error = Box; + fn main() -> Result<(), Error> { let mut args = std::env::args_os(); let _ = args.next(); diff --git a/tests/simple/fs.rs b/tests/simple/fs.rs index 7b1f595..9a89c4d 100644 --- a/tests/simple/fs.rs +++ b/tests/simple/fs.rs @@ -2,8 +2,6 @@ use std::collections::HashMap; use std::io::Read; use std::path::{Path, PathBuf}; -use anyhow::{bail, format_err, Error}; - use pxar::decoder::sync as decoder; use pxar::decoder::SeqRead; use pxar::encoder::sync as encoder; @@ -13,6 +11,8 @@ use pxar::format::{mode, Device}; use pxar::EntryKind as PxarEntryKind; use pxar::Metadata; +use crate::Error; + /// Hardlink information we use while encoding pxar archives. pub struct HardlinkInfo { link: LinkOffset, diff --git a/tests/simple/main.rs b/tests/simple/main.rs index f15a0f5..676322d 100644 --- a/tests/simple/main.rs +++ b/tests/simple/main.rs @@ -1,14 +1,26 @@ use std::io::Read; use std::path::Path; -use anyhow::{bail, Error}; - use pxar::accessor::sync as accessor; use pxar::decoder::sync as decoder; use pxar::encoder::sync as encoder; use pxar::encoder::SeqWrite; use pxar::EntryKind as PxarEntryKind; +macro_rules! format_err { + ($($msg:tt)+) => { + std::io::Error::new(std::io::ErrorKind::Other, format!($($msg)+)) + }; +} + +macro_rules! bail { + ($($msg:tt)+) => {{ + return Err(format_err!($($msg)+).into()); + }}; +} + +pub type Error = Box; + mod fs; fn encode_directory( -- 2.39.5