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: include:
- { rust: stable, os: ubuntu-latest } - { rust: stable, os: ubuntu-latest }
- { rust: stable, os: macos-latest } - { rust: stable, os: macos-latest }
- { rust: stable, os: windows-latest } # - { rust: stable, os: windows-latest }
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Install Rust ${{ matrix.rust }} - name: Install Rust ${{ matrix.rust }}

@ -2092,6 +2092,10 @@ mod tests {
#[tokio::test] #[tokio::test]
async fn proc_run_should_send_back_stdout_periodically_when_available() { async fn proc_run_should_send_back_stdout_periodically_when_available() {
let (conn_id, state, tx, mut rx) = setup(1); 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 // Run a program that echoes to stdout
let req = Request::new( let req = Request::new(

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

@ -17,19 +17,19 @@ use tokio::{io, time::Duration};
pub enum Error { pub enum Error {
#[display(fmt = "Process failed with exit code: {}", _0)] #[display(fmt = "Process failed with exit code: {}", _0)]
BadProcessExit(#[error(not(source))] i32), BadProcessExit(#[error(not(source))] i32),
IoError(io::Error), Io(io::Error),
#[display(fmt = "Non-interactive but no operation supplied")] #[display(fmt = "Non-interactive but no operation supplied")]
MissingOperation, MissingOperation,
OperationFailed, OperationFailed,
RemoteProcessError(RemoteProcessError), RemoteProcess(RemoteProcessError),
TransportError(TransportError), Transport(TransportError),
} }
impl ExitCodeError for Error { impl ExitCodeError for Error {
fn is_silent(&self) -> bool { fn is_silent(&self) -> bool {
match self { match self {
Self::BadProcessExit(_) | Self::OperationFailed => true, Self::BadProcessExit(_) | Self::OperationFailed => true,
Self::RemoteProcessError(x) => x.is_silent(), Self::RemoteProcess(x) => x.is_silent(),
_ => false, _ => false,
} }
} }
@ -37,11 +37,11 @@ impl ExitCodeError for Error {
fn to_exit_code(&self) -> ExitCode { fn to_exit_code(&self) -> ExitCode {
match self { match self {
Self::BadProcessExit(x) => ExitCode::Custom(*x), 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::MissingOperation => ExitCode::Usage,
Self::OperationFailed => ExitCode::Software, Self::OperationFailed => ExitCode::Software,
Self::RemoteProcessError(x) => x.to_exit_code(), Self::RemoteProcess(x) => x.to_exit_code(),
Self::TransportError(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")] #[display(fmt = "Missing data for session")]
MissingSessionData, MissingSessionData,
ForkError(#[error(not(source))] i32), Fork(#[error(not(source))] i32),
IoError(io::Error), Io(io::Error),
Utf8Error(FromUtf8Error), Utf8(FromUtf8Error),
} }
impl ExitCodeError for Error { impl ExitCodeError for Error {
fn to_exit_code(&self) -> ExitCode { fn to_exit_code(&self) -> ExitCode {
match self { match self {
Self::MissingSessionData => ExitCode::NoInput, Self::MissingSessionData => ExitCode::NoInput,
Self::ForkError(_) => ExitCode::OsErr, Self::Fork(_) => ExitCode::OsErr,
Self::IoError(x) => x.to_exit_code(), Self::Io(x) => x.to_exit_code(),
Self::Utf8Error(_) => ExitCode::DataErr, Self::Utf8(_) => ExitCode::DataErr,
} }
} }
} }
@ -90,7 +90,7 @@ pub fn run(cmd: LaunchSubcommand, opt: CommonOpt) -> Result<(), Error> {
})? })?
} }
Ok(_) => {} Ok(_) => {}
Err(x) => return Err(Error::ForkError(x)), Err(x) => return Err(Error::Fork(x)),
} }
} }
#[cfg(unix)] #[cfg(unix)]

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

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

Loading…
Cancel
Save