Skip to content

Commit 9dc41ca

Browse files
committed
Fix Book tests
Additionally: - add `chapter` argument to `test.book` command in `Makefile`
1 parent a9d032a commit 9dc41ca

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,17 @@ endif
105105
# Run Rust tests of Book.
106106
#
107107
# Usage:
108-
# make test.book [clean=(no|yes)]
108+
# make test.book [chapter=<name>] [clean=(no|yes)]
109109

110110
test.book:
111111
ifeq ($(clean),yes)
112112
cargo clean
113113
endif
114114
$(eval target := $(strip $(shell cargo -vV | sed -n 's/host: //p')))
115115
cargo build --all-features --tests
116-
OUT_DIR=target mdbook test book -L target/debug/deps $(strip \
116+
OUT_DIR='$(realpath .)/target' \
117+
mdbook test book $(if $(call eq,$(chapter),),,-c '$(chapter)') \
118+
-L target/debug/deps $(strip \
117119
$(if $(call eq,$(findstring windows,$(target)),),,\
118120
$(shell cargo metadata -q \
119121
| jq -r '.packages[] | select(.name == "windows_$(word 1,$(subst -, ,$(target)))_$(word 4,$(subst -, ,$(target)))") | .manifest_path' \

book/src/output/json.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use cucumber::{writer, World as _};
2121
#
2222
# #[tokio::main]
2323
# async fn main() -> io::Result<()> {
24-
let file = fs::File::create(dbg!(format!("{}/report.json", env!("OUT_DIR"))))?;
24+
let file = fs::File::create(format!("{}/report.json", env!("OUT_DIR")))?;
2525
World::cucumber()
2626
.with_writer(writer::Json::new(file))
2727
.run("tests/features/book")

book/src/output/junit.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use cucumber::{writer, World as _};
2121
#
2222
# #[tokio::main]
2323
# async fn main() -> io::Result<()> {
24-
let file = fs::File::create(dbg!(format!("{}/junit.xml", env!("OUT_DIR"))))?;
24+
let file = fs::File::create(format!("{}/junit.xml", env!("OUT_DIR")))?;
2525
World::cucumber()
2626
.with_writer(writer::JUnit::new(file, 0))
2727
.run("tests/features/book")

book/src/output/multiple.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ World::cucumber()
109109
writer::Coloring::Auto,
110110
writer::Verbosity::Default,
111111
)
112-
.tee::<World, _>(writer::Basic::raw(
113-
file,
114-
writer::Coloring::Never,
115-
2,
116-
))
117-
.summarized()
118-
.normalized(),
112+
.tee::<World, _>(writer::Basic::raw(
113+
file,
114+
writer::Coloring::Never,
115+
2,
116+
))
117+
.summarized()
118+
.normalized(),
119119
)
120120
.with_cli(cli) // Supply the parsed `cli::Opts`.
121121
.run_and_exit("tests/features/book")

0 commit comments

Comments
 (0)