From 9a6a856200a894e1186df8def397ee5826ce6250 Mon Sep 17 00:00:00 2001 From: Tatsuya Kawano Date: Sat, 10 Feb 2024 11:24:37 +0000 Subject: [PATCH] Update the doc tests on the `README.md` by replacing Skeptic with a regular `cargo test` command --- .ci_extras/pin-crate-vers-msrv.sh | 2 +- .github/workflows/LinuxCrossCompileTest.yml | 2 +- .github/workflows/{Skeptic.yml => Trybuild.yml} | 17 +---------------- .vscode/settings.json | 2 ++ Cargo.toml | 4 ---- README.md | 4 ++-- build.rs | 8 +------- src/lib.rs | 7 +++++++ tests/skeptic.rs | 2 -- 9 files changed, 15 insertions(+), 33 deletions(-) rename .github/workflows/{Skeptic.yml => Trybuild.yml} (71%) delete mode 100644 tests/skeptic.rs diff --git a/.ci_extras/pin-crate-vers-msrv.sh b/.ci_extras/pin-crate-vers-msrv.sh index a10eb759..d05ec46d 100755 --- a/.ci_extras/pin-crate-vers-msrv.sh +++ b/.ci_extras/pin-crate-vers-msrv.sh @@ -3,4 +3,4 @@ set -eux # Pin some dependencies to specific versions for the MSRV. -cargo update -p cargo-platform --precise 0.1.5 +# cargo update -p --precise diff --git a/.github/workflows/LinuxCrossCompileTest.yml b/.github/workflows/LinuxCrossCompileTest.yml index 57ffd4a9..f1221a40 100644 --- a/.github/workflows/LinuxCrossCompileTest.yml +++ b/.github/workflows/LinuxCrossCompileTest.yml @@ -76,7 +76,7 @@ jobs: - name: Remove integration tests and force enable rustc_version crate run: | rm -rf tests - sed -i '/actix-rt\|async-std\|reqwest\|skeptic/d' Cargo.toml + sed -i '/actix-rt\|async-std\|reqwest/d' Cargo.toml sed -i 's/target.*rustver.*\.//' Cargo.toml sed -i 's/build = "build.rs"/build = ".ci_extras\/build_linux_cross.rs"/' Cargo.toml cat Cargo.toml diff --git a/.github/workflows/Skeptic.yml b/.github/workflows/Trybuild.yml similarity index 71% rename from .github/workflows/Skeptic.yml rename to .github/workflows/Trybuild.yml index c5e1974a..8b24130f 100644 --- a/.github/workflows/Skeptic.yml +++ b/.github/workflows/Trybuild.yml @@ -1,4 +1,4 @@ -name: Skeptic and Trybuild +name: Trybuild on: push: @@ -44,21 +44,6 @@ jobs: with: toolchain: ${{ matrix.rust }} - - name: Run tests (sync feature) - run: cargo test --release --features sync - env: - RUSTFLAGS: '--cfg skeptic' - - - name: Run tests (release, sync and future) - run: cargo test --release --features 'sync, future' - env: - RUSTFLAGS: '--cfg skeptic' - - - name: Run tests (sync and future, without atomic64 and quanta) - run: cargo test --release --no-default-features --features 'sync, future' - env: - RUSTFLAGS: '--cfg skeptic' - - name: Run compile error tests (sync and future features, trybuild) if: ${{ matrix.rust == 'stable' }} run: cargo test ui_trybuild --release --features 'sync, future' diff --git a/.vscode/settings.json b/.vscode/settings.json index 22ae28b7..17072aa5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -24,6 +24,8 @@ "Descheduled", "devcontainer", "docsrs", + "doctest", + "doctests", "Einziger", "else's", "ENHANCEME", diff --git a/Cargo.toml b/Cargo.toml index 2280afa6..9d283d13 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,15 +80,11 @@ env_logger = "0.10.0" getrandom = "0.2" paste = "1.0.9" reqwest = { version = "0.11.11", default-features = false, features = ["rustls-tls"] } -skeptic = "0.13" tokio = { version = "1.19", features = ["fs", "io-util", "macros", "rt-multi-thread", "sync", "time" ] } [target.'cfg(trybuild)'.dev-dependencies] trybuild = "1.0" -[target.'cfg(skeptic)'.build-dependencies] -skeptic = "0.13.5" - [target.'cfg(rustver)'.build-dependencies] rustc_version = "0.4.0" diff --git a/README.md b/README.md index 1502097e..829fe943 100644 --- a/README.md +++ b/README.md @@ -497,13 +497,13 @@ To run all tests including `future` feature and doc tests on the README, use the following command: ```console -$ RUSTFLAGS='--cfg skeptic --cfg trybuild' cargo test --all-features +$ RUSTFLAGS='--cfg trybuild' cargo test --all-features ``` **Running All Tests without Default Features** ```console -$ RUSTFLAGS='--cfg skeptic --cfg trybuild' cargo test \ +$ RUSTFLAGS='--cfg trybuild' cargo test \ --no-default-features --features 'future, sync' ``` diff --git a/build.rs b/build.rs index 88e341e8..72a59c0e 100644 --- a/build.rs +++ b/build.rs @@ -1,9 +1,3 @@ -#[cfg(skeptic)] -fn main() { - // generates doc tests for `README.md`. - skeptic::generate_doc_tests(&["README.md"]); -} - #[cfg(rustver)] fn main() { use rustc_version::version; @@ -14,5 +8,5 @@ fn main() { ); } -#[cfg(not(any(skeptic, rustver)))] +#[cfg(not(rustver))] fn main() {} diff --git a/src/lib.rs b/src/lib.rs index 4bd4a800..5d31d0ac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -151,3 +151,10 @@ mod tests { t.compile_fail("tests/compile_tests/future/clone/*.rs"); } } + +#[cfg(all(doctest, sync))] +mod doctests { + // https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#include-items-only-when-collecting-doctests + #[doc = include_str!("../README.md")] + struct ReadMeDoctests; +} diff --git a/tests/skeptic.rs b/tests/skeptic.rs deleted file mode 100644 index 6b54ee21..00000000 --- a/tests/skeptic.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[cfg(skeptic)] -include!(concat!(env!("OUT_DIR"), "/skeptic-tests.rs"));