Ensure doc tests are run in CI

This commit is contained in:
Benjamin Fry 2021-08-01 16:31:15 -04:00 committed by Dirkjan Ochtman
parent 236f98bdc4
commit 0e8e1b7bc9
7 changed files with 56 additions and 19 deletions

View File

@ -246,10 +246,22 @@ description = "Build all the crates"
command = "cargo"
args = ["build", "--lib", "--bins", "@@remove-empty(FEATURES)"]
[tasks.test]
description = "Run tests all the crates"
[tasks.test-all]
description = "Run tests in all crates"
command = "cargo"
args = ["test", "--lib", "--examples", "--tests", "--bins", "@@remove-empty(FEATURES)"]
args = ["test", "--lib", "--bins", "--examples", "--tests", "@@remove-empty(FEATURES)"]
[tasks.test-examples]
description = "A place-holder for crates to override with examples to run"
[tasks.test-docs]
description = "Run doc tests in all crates"
command = "cargo"
args = ["test", "--doc", "@@remove-empty(FEATURES)"]
[tasks.test]
description = "Run tests in all crates"
dependencies = ["test-all", "test-docs", "test-examples"]
[tasks.touch_all_rs]
description = "Touch all Rust files (for clippy)"

View File

@ -25,6 +25,7 @@ args = ["build", "--bins", "@@remove-empty(FEATURES)"]
[tasks.test]
command = "cargo"
dependencies = []
args = ["test", "--examples", "--tests", "--bins", "@@remove-empty(FEATURES)"]
[tasks.clippy]

View File

@ -78,15 +78,17 @@
//! ```
//! use std::net::*;
//! use async_std::prelude::*;
//! # #[cfg(feature = "system-config")]
//! use async_std_resolver::{resolver_from_system_conf, config};
//!
//! #[async_std::main]
//! async fn main() {
//! # #[cfg(feature = "system-config")]
//! # {
//! // Use the host OS'es `/etc/resolv.conf`
//! # #[cfg(unix)]
//! let resolver = resolver_from_system_conf().await.unwrap();
//! # #[cfg(unix)]
//! let response = resolver.lookup_ip("www.example.com.").await.unwrap();
//! # }
//! }
//! ```

View File

@ -139,6 +139,10 @@
//!
//! ```rust,no_run
//!
//! #[cfg(all(feature = "openssl", feature = "dnssec"))]
//! # fn main() {
//!
//! use std::fs::File;
//! use std::io::Read;
//! use std::net::Ipv4Addr;
@ -147,16 +151,13 @@
//! use chrono::Duration;
//! # #[cfg(feature = "openssl")]
//! use openssl::rsa::Rsa;
//! # use trust_dns_client::client::Client;
//! # use trust_dns_client::udp::UdpClientConnection;
//! use trust_dns_client::client::SyncClient;
//! use trust_dns_client::client::{Client, SyncClient};
//! use trust_dns_client::udp::UdpClientConnection;
//! use trust_dns_client::rr::{Name, RData, Record, RecordType};
//! use trust_dns_client::rr::dnssec::{Algorithm, SigSigner, KeyPair};
//! use trust_dns_client::op::ResponseCode;
//! use trust_dns_client::rr::rdata::key::KEY;
//!
//! # #[cfg(feature = "openssl")]
//! # fn main() {
//! # let address = "0.0.0.0:53".parse().unwrap();
//! # let conn = UdpClientConnection::new(address).unwrap();
//!
@ -206,7 +207,7 @@
//! let result = client.create(record, origin).unwrap();
//! assert_eq!(result.response_code(), ResponseCode::NoError);
//! # }
//! # #[cfg(not(feature = "openssl"))]
//! # #[cfg(not(all(feature = "openssl", feature = "dnssec")))]
//! # fn main() {
//! # }
//! ```
@ -228,7 +229,6 @@
//! use trust_dns_client::client::{Client, AsyncClient, ClientHandle};
//! use trust_dns_client::rr::{DNSClass, Name, RData, Record, RecordType};
//! use trust_dns_client::op::ResponseCode;
//! use trust_dns_client::rr::rdata::key::KEY;
//!
//! // We'll be using the current threads Tokio Runtime
//! let mut runtime = Runtime::new().unwrap();

View File

@ -22,6 +22,5 @@ args = ["run", "--example=global_resolver"]
command = "cargo"
args = ["run", "--example=multithreaded_runtime"]
# Also test that the examples run
[tasks.test]
[tasks.test-examples]
dependencies = ["example-global_resolver", "example-multithreaded_runtime"]

View File

@ -138,11 +138,33 @@
//! to a server, for example:
//!
//! ```rust,no_run
//! let result = io_loop.block_on(lookup_future.and_then(|ips| {
//! let ip = ips.next().unwrap();
//! TcpStream::connect()
//! }).and_then(|conn| /* do something with the connection... */)
//! ).unwrap();
//! # fn main() {
//! # #[cfg(feature = "tokio-runtime")]
//! # {
//! # use std::net::*;
//! # use tokio::runtime::Runtime;
//! # use trust_dns_resolver::TokioAsyncResolver;
//! # use trust_dns_resolver::config::*;
//! # use futures_util::TryFutureExt;
//! #
//! # let mut io_loop = Runtime::new().unwrap();
//! #
//! # let resolver = io_loop.block_on(async {
//! # TokioAsyncResolver::tokio(
//! # ResolverConfig::default(),
//! # ResolverOpts::default())
//! # }).expect("failed to connect resolver");
//! #
//! let ips = io_loop.block_on(resolver.lookup_ip("www.example.com.")).unwrap();
//!
//! let result = io_loop.block_on(async {
//! let ip = ips.iter().next().unwrap();
//! TcpStream::connect((ip, 443))
//! })
//! .and_then(|conn| Ok(conn) /* do something with the connection... */)
//! .unwrap();
//! # }
//! # }
//! ```
//!
//! It's beyond the scope of these examples to show how to deal with connection failures and

View File

@ -25,6 +25,7 @@ args = ["build", "--bins", "@@remove-empty(FEATURES)"]
[tasks.test]
command = "cargo"
dependencies = []
args = ["test", "--examples", "--tests", "--bins", "@@remove-empty(FEATURES)"]
[tasks.clippy]