Skip to content

Commit

Permalink
Fix Book tests
Browse files Browse the repository at this point in the history
Additionally:
- add `chapter` argument to `test.book` command in `Makefile`
  • Loading branch information
tyranron committed Jun 14, 2024
1 parent a9d032a commit 9dc41ca
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,17 @@ endif
# Run Rust tests of Book.
#
# Usage:
# make test.book [clean=(no|yes)]
# make test.book [chapter=<name>] [clean=(no|yes)]

test.book:
ifeq ($(clean),yes)
cargo clean
endif
$(eval target := $(strip $(shell cargo -vV | sed -n 's/host: //p')))
cargo build --all-features --tests
OUT_DIR=target mdbook test book -L target/debug/deps $(strip \
OUT_DIR='$(realpath .)/target' \
mdbook test book $(if $(call eq,$(chapter),),,-c '$(chapter)') \
-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' \
Expand Down
2 changes: 1 addition & 1 deletion book/src/output/json.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use cucumber::{writer, World as _};
#
# #[tokio::main]
# async fn main() -> io::Result<()> {
let file = fs::File::create(dbg!(format!("{}/report.json", env!("OUT_DIR"))))?;
let file = fs::File::create(format!("{}/report.json", env!("OUT_DIR")))?;
World::cucumber()
.with_writer(writer::Json::new(file))
.run("tests/features/book")
Expand Down
2 changes: 1 addition & 1 deletion book/src/output/junit.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use cucumber::{writer, World as _};
#
# #[tokio::main]
# async fn main() -> io::Result<()> {
let file = fs::File::create(dbg!(format!("{}/junit.xml", env!("OUT_DIR"))))?;
let file = fs::File::create(format!("{}/junit.xml", env!("OUT_DIR")))?;
World::cucumber()
.with_writer(writer::JUnit::new(file, 0))
.run("tests/features/book")
Expand Down
14 changes: 7 additions & 7 deletions book/src/output/multiple.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ World::cucumber()
writer::Coloring::Auto,
writer::Verbosity::Default,
)
.tee::<World, _>(writer::Basic::raw(
file,
writer::Coloring::Never,
2,
))
.summarized()
.normalized(),
.tee::<World, _>(writer::Basic::raw(
file,
writer::Coloring::Never,
2,
))
.summarized()
.normalized(),
)
.with_cli(cli) // Supply the parsed `cli::Opts`.
.run_and_exit("tests/features/book")
Expand Down

0 comments on commit 9dc41ca

Please sign in to comment.