From e3a72edf707b2ee60c0ce39e594946ab063e1091 Mon Sep 17 00:00:00 2001 From: tyranron Date: Wed, 2 Nov 2022 16:32:50 +0100 Subject: [PATCH] Fix mdBook tests on Windows (rust-lang/rust#99466) --- .github/workflows/ci.yml | 7 ++----- Makefile | 7 ++++++- book/README.md | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f38a684..c90ff78e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -263,9 +263,7 @@ jobs: os: - ubuntu - macOS - # TODO: Re-enable once rust-lang/rust#99466 is fixed: - # https://github.com/rust-lang/rust/issues/99466 - #- windows + - windows toolchain: - stable - beta @@ -277,8 +275,7 @@ jobs: with: toolchain: ${{ matrix.toolchain }} - run: rustup default ${{ matrix.toolchain }} - - - run: cargo install mdbook + - uses: peaceiris/actions-mdbook@v1 - run: make test.book diff --git a/Makefile b/Makefile index 833a61e8..8c1db098 100644 --- a/Makefile +++ b/Makefile @@ -93,8 +93,13 @@ test.book: ifeq ($(clean),yes) cargo clean endif + $(eval target := $(strip $(shell cargo -vV | sed -n 's/host: //p'))) cargo build - mdbook test book -L target/debug/deps + mdbook test book -L target/debug/deps $(strip \ + $(if $(call eq,$(findstring windows,$(target)),),,\ + $(shell cargo metadata -q \ + | jq -r '.packages[] | select(.name == "windows_$(word 1,$(subst -, ,$(target)))_$(word 4,$(subst -, ,$(target)))") | .manifest_path' \ + | sed -e "s/^/-L '/" -e 's/Cargo.toml/lib/' -e "s/$$/'/" ))) # Run Rust tests of project crates. diff --git a/book/README.md b/book/README.md index 93ac3407..aa5a26a1 100644 --- a/book/README.md +++ b/book/README.md @@ -45,10 +45,11 @@ The output will be in the `_rendered/` directory. ### Testing -To run the tests validating all code examples in the book, run: +To run the tests validating all code examples in the book, run (from project root dir): ```bash -mdbook test -L ../target/debug/deps +cargo build +mdbook test -L target/debug/deps -# or via shortcut from project root dir: +# or via shortcut: make test.book ```