Fix new clippy warnings, remove windows tests for cli as it does not support windows yet

pull/39/head
Chip Senkbeil 3 years ago
parent dd5181d282
commit cf95181418
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -43,7 +43,7 @@ jobs:
include:
- { rust: stable, os: ubuntu-latest }
- { rust: stable, os: macos-latest }
- { rust: stable, os: windows-latest }
# - { rust: stable, os: windows-latest }
steps:
- uses: actions/checkout@v2
- name: Install Rust ${{ matrix.rust }}

@ -2092,6 +2092,10 @@ mod tests {
#[tokio::test]
async fn proc_run_should_send_back_stdout_periodically_when_available() {
let (conn_id, state, tx, mut rx) = setup(1);
println!(
"ECHO_ARGS_TO_STDOUT_SH: {:?}",
ECHO_ARGS_TO_STDOUT_SH.to_str()
);
// Run a program that echoes to stdout
let req = Request::new(

@ -30,7 +30,7 @@ impl CliSession {
);
let map_line = move |line: &str| match format {
Format::Json => serde_json::from_str(&line)
Format::Json => serde_json::from_str(line)
.map_err(|x| io::Error::new(io::ErrorKind::InvalidInput, x)),
Format::Shell => {
let data = RequestData::from_iter_safe(

@ -17,19 +17,19 @@ use tokio::{io, time::Duration};
pub enum Error {
#[display(fmt = "Process failed with exit code: {}", _0)]
BadProcessExit(#[error(not(source))] i32),
IoError(io::Error),
Io(io::Error),
#[display(fmt = "Non-interactive but no operation supplied")]
MissingOperation,
OperationFailed,
RemoteProcessError(RemoteProcessError),
TransportError(TransportError),
RemoteProcess(RemoteProcessError),
Transport(TransportError),
}
impl ExitCodeError for Error {
fn is_silent(&self) -> bool {
match self {
Self::BadProcessExit(_) | Self::OperationFailed => true,
Self::RemoteProcessError(x) => x.is_silent(),
Self::RemoteProcess(x) => x.is_silent(),
_ => false,
}
}
@ -37,11 +37,11 @@ impl ExitCodeError for Error {
fn to_exit_code(&self) -> ExitCode {
match self {
Self::BadProcessExit(x) => ExitCode::Custom(*x),
Self::IoError(x) => x.to_exit_code(),
Self::Io(x) => x.to_exit_code(),
Self::MissingOperation => ExitCode::Usage,
Self::OperationFailed => ExitCode::Software,
Self::RemoteProcessError(x) => x.to_exit_code(),
Self::TransportError(x) => x.to_exit_code(),
Self::RemoteProcess(x) => x.to_exit_code(),
Self::Transport(x) => x.to_exit_code(),
}
}
}

@ -18,18 +18,18 @@ pub enum Error {
#[display(fmt = "Missing data for session")]
MissingSessionData,
ForkError(#[error(not(source))] i32),
IoError(io::Error),
Utf8Error(FromUtf8Error),
Fork(#[error(not(source))] i32),
Io(io::Error),
Utf8(FromUtf8Error),
}
impl ExitCodeError for Error {
fn to_exit_code(&self) -> ExitCode {
match self {
Self::MissingSessionData => ExitCode::NoInput,
Self::ForkError(_) => ExitCode::OsErr,
Self::IoError(x) => x.to_exit_code(),
Self::Utf8Error(_) => ExitCode::DataErr,
Self::Fork(_) => ExitCode::OsErr,
Self::Io(x) => x.to_exit_code(),
Self::Utf8(_) => ExitCode::DataErr,
}
}
}
@ -90,7 +90,7 @@ pub fn run(cmd: LaunchSubcommand, opt: CommonOpt) -> Result<(), Error> {
})?
}
Ok(_) => {}
Err(x) => return Err(Error::ForkError(x)),
Err(x) => return Err(Error::Fork(x)),
}
}
#[cfg(unix)]

@ -11,19 +11,19 @@ use tokio::{io, task::JoinError};
#[derive(Debug, Display, Error, From)]
pub enum Error {
ConvertToIpAddrError(ConvertToIpAddrError),
ForkError,
IoError(io::Error),
JoinError(JoinError),
ConverToIpAddr(ConvertToIpAddrError),
Fork,
Io(io::Error),
Join(JoinError),
}
impl ExitCodeError for Error {
fn to_exit_code(&self) -> ExitCode {
match self {
Self::ConvertToIpAddrError(_) => ExitCode::NoHost,
Self::ForkError => ExitCode::OsErr,
Self::IoError(x) => x.to_exit_code(),
Self::JoinError(_) => ExitCode::Software,
Self::ConverToIpAddr(_) => ExitCode::NoHost,
Self::Fork => ExitCode::OsErr,
Self::Io(x) => x.to_exit_code(),
Self::Join(_) => ExitCode::Software,
}
}
}
@ -39,10 +39,10 @@ pub fn run(cmd: ListenSubcommand, opt: CommonOpt) -> Result<(), Error> {
Ok(Fork::Parent(pid)) => {
info!("[distant detached, pid = {}]", pid);
if fork::close_fd().is_err() {
return Err(Error::ForkError);
return Err(Error::Fork);
}
}
Err(_) => return Err(Error::ForkError),
Err(_) => return Err(Error::Fork),
}
} else {
let rt = tokio::runtime::Runtime::new()?;
@ -84,7 +84,7 @@ async fn run_async(cmd: ListenSubcommand, _opt: CommonOpt, is_forked: bool) -> R
// For the child, we want to fully disconnect it from pipes, which we do now
if is_forked && fork::close_fd().is_err() {
return Err(Error::ForkError);
return Err(Error::Fork);
}
// Let our server run to completion

@ -15,14 +15,14 @@ use tokio::io;
pub enum Error {
#[display(fmt = "Process failed with exit code: {}", _0)]
BadProcessExit(#[error(not(source))] i32),
IoError(io::Error),
RemoteProcessError(RemoteProcessError),
Io(io::Error),
RemoteProcess(RemoteProcessError),
}
impl ExitCodeError for Error {
fn is_silent(&self) -> bool {
match self {
Self::RemoteProcessError(x) => x.is_silent(),
Self::RemoteProcess(x) => x.is_silent(),
_ => false,
}
}
@ -30,8 +30,8 @@ impl ExitCodeError for Error {
fn to_exit_code(&self) -> ExitCode {
match self {
Self::BadProcessExit(x) => ExitCode::Custom(*x),
Self::IoError(x) => x.to_exit_code(),
Self::RemoteProcessError(x) => x.to_exit_code(),
Self::Io(x) => x.to_exit_code(),
Self::RemoteProcess(x) => x.to_exit_code(),
}
}
}

Loading…
Cancel
Save