• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zhiburt / expectrl / 8133416044

03 Mar 2024 10:18PM UTC coverage: 55.91% (-0.7%) from 56.575%
8133416044

Pull #68

github

web-flow
Merge e8846ebf2 into e8b43ff1b
Pull Request #68: [WIP] Move to trait based version `Expect`

219 of 377 new or added lines in 14 files covered. (58.09%)

155 existing lines in 6 files now uncovered.

1490 of 2665 relevant lines covered (55.91%)

3.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

2.94
/src/error.rs
1
use std::error;
2
use std::fmt;
3
use std::fmt::Display;
4
use std::io;
5

6
#[allow(variant_size_differences)]
7
/// An main error type used in [crate].
8
#[derive(Debug)]
9
pub enum Error {
10
    /// An Error in IO operation.
11
    IO(io::Error),
12
    /// An Error in command line parsing.
13
    CommandParsing,
14
    /// An Error in regex parsing.
15
    RegexParsing,
16
    /// An timeout was reached while waiting in expect call.
17
    ExpectTimeout,
18
    /// Unhandled EOF error.
19
    Eof,
20
    /// It maybe OS specific error or a general erorr.
21
    Other {
22
        /// The reason of the erorr.
23
        message: String,
24
        /// An underlying error message.
25
        err: String,
26
    },
27
}
28

29
impl Error {
30
    #[cfg(unix)]
31
    pub(crate) fn unknown(message: impl Into<String>, err: impl Into<String>) -> Error {
×
32
        Self::Other {
33
            message: message.into(),
×
34
            err: err.into(),
×
35
        }
36
    }
37
}
38

UNCOV
39
impl Display for Error {
×
40
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
×
41
        match self {
×
42
            Error::IO(err) => write!(f, "IO error {}", err),
×
43
            Error::CommandParsing => write!(f, "Can't parse a command string, please check it out"),
×
44
            Error::RegexParsing => write!(f, "Can't parse a regex expression"),
×
45
            Error::ExpectTimeout => write!(f, "Reached a timeout for expect type of command"),
×
46
            Error::Eof => write!(f, "EOF was reached; the read may successed later"),
×
47
            Error::Other { message, err } => write!(f, "Unexpected error; {}; {}", message, err),
×
48
        }
49
    }
50
}
51

52
impl error::Error for Error {}
53

54
impl From<io::Error> for Error {
55
    fn from(err: io::Error) -> Self {
1✔
56
        Self::IO(err)
1✔
57
    }
58
}
59

60
impl From<Error> for io::Error {
×
61
    fn from(err: Error) -> Self {
×
62
        io::Error::new(io::ErrorKind::Other, err.to_string())
×
63
    }
64
}
65

66
pub(crate) fn to_io_error<E: Display>(message: &'static str) -> impl FnOnce(E) -> io::Error {
8✔
67
    move |e: E| io::Error::new(io::ErrorKind::Other, format!("{}; {}", message, e))
8✔
68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc