Make 'cargo test' succeed again

This commit is contained in:
Tim Kuehn
2020-11-12 11:30:20 -08:00
parent d21cbddb0d
commit 3d43310e6a
6 changed files with 87 additions and 8 deletions

View File

@@ -21,6 +21,80 @@ jobs:
test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
test:
name: Test Suite, Serde enabled
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --features serde1
test:
name: Test Suite, Tokio enabled
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --features tokio1
test:
name: Test Suite, Serde Transport enabled
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --features serde-transport
test:
name: Test Suite, TCP enabled
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --features tcp
test:
name: Test Suite, All Features Enabled
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1

View File

@@ -17,7 +17,7 @@ default = []
serde1 = ["tarpc-plugins/serde1", "serde", "serde/derive"]
tokio1 = ["tokio/rt-multi-thread"]
serde-transport = ["tokio-serde/json", "tokio-util/codec"]
serde-transport = ["serde1", "tokio1", "tokio-serde/json", "tokio-util/codec"]
tcp = ["tokio/net", "tokio/stream"]
full = ["serde1", "tokio1", "serde-transport", "tcp"]
@@ -59,7 +59,7 @@ rustdoc-args = ["--cfg", "docsrs"]
[[example]]
name = "compression"
required-features = ["serde-transport"]
required-features = ["serde-transport", "tcp"]
[[example]]
name = "server_calling_server"

View File

@@ -165,6 +165,9 @@
//! # future::ready(format!("Hello, {}!", name))
//! # }
//! # }
//! # #[cfg(not(feature = "tokio1"))]
//! # fn main() {}
//! # #[cfg(feature = "tokio1")]
//! #[tokio::main]
//! async fn main() -> io::Result<()> {
//! let (client_transport, server_transport) = tarpc::transport::channel::unbounded();

View File

@@ -78,6 +78,7 @@ impl<Item, SinkItem> Sink<SinkItem> for UnboundedChannel<Item, SinkItem> {
}
#[cfg(test)]
#[cfg(feature = "tokio1")]
mod tests {
use crate::{
client, context,
@@ -89,7 +90,6 @@ mod tests {
use log::trace;
use std::io;
#[cfg(feature = "tokio1")]
#[tokio::test]
async fn integration() -> io::Result<()> {
let _ = env_logger::try_init();

View File

@@ -1,4 +1,4 @@
#[tarpc::service]
#[tarpc::service(derive_serde = false)]
trait World {
async fn hello(name: String) -> String;
}

View File

@@ -6,12 +6,11 @@ use futures::{
use std::io;
use tarpc::{
client::{self},
context, serde_transport,
context,
server::{self, BaseChannel, Channel, Handler},
transport::channel,
};
use tokio::join;
use tokio_serde::formats::Json;
#[tarpc_plugins::service]
trait Service {
@@ -58,12 +57,15 @@ async fn sequential() -> io::Result<()> {
Ok(())
}
#[cfg(feature = "serde1")]
#[cfg(all(feature = "serde-transport", feature = "tcp"))]
#[tokio::test]
async fn serde() -> io::Result<()> {
use tarpc::serde_transport;
use tokio_serde::formats::Json;
let _ = env_logger::try_init();
let transport = serde_transport::tcp::listen("localhost:56789", Json::default).await?;
let transport = tarpc::serde_transport::tcp::listen("localhost:56789", Json::default).await?;
let addr = transport.local_addr();
tokio::spawn(
tarpc::Server::default()