From 33e8f1d27154556f92df91c3deecb0eee1a3670e Mon Sep 17 00:00:00 2001 From: Leandro Lisboa Penz Date: Thu, 27 Jan 2022 18:22:26 -0300 Subject: [PATCH] New doctest parameter allows us to disable documentation testing There are some issues with documentation tests, see https://github.com/taiki-e/cargo-llvm-cov/issues/2 and https://github.com/rust-lang/rust/issues/79417 --- README.md | 1 + action.yml | 3 +++ entrypoint | 11 ++++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ebf0385..c2b1752 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ jobs: - `output_type`: output type, one of `html`, `text`, `json` or `lcov`. - `output_path`: output path. - `test_args`: arguments to pass to the test - `--nocapture` for example. +- `doctest`: if `true` (the default) the documentation tests are also run. If neither `output_type` and `output_path` are defined, the action by diff --git a/action.yml b/action.yml index 5fc3cf0..5e2575b 100644 --- a/action.yml +++ b/action.yml @@ -16,6 +16,9 @@ inputs: default: '' test_args: description: Arguments to pass to the test + doctest: + description: Run documentation testing; true or false + default: true outputs: report: description: Name of report file, for compatibility with rust-grcov diff --git a/entrypoint b/entrypoint index 0085a39..f954d57 100755 --- a/entrypoint +++ b/entrypoint @@ -25,6 +25,8 @@ if [ -n "$INPUT_OUTPUT_TYPE" ]; then OUTPUT_ARGS+=( "--$INPUT_OUTPUT_TYPE" ) fi +DOCTEST="${INPUT_DOCTEST:-true}" + if [ -n "$INPUT_OUTPUT_PATH" ]; then OUTPUT_PATH="$INPUT_OUTPUT_PATH" OUTPUT_ARGS+=( --output-path "$OUTPUT_PATH" ) @@ -51,9 +53,16 @@ RUSTDOCFLAGS="$RUSTFLAGS" RUST_BACKTRACE=1 cargo llvm-cov --workspace clean + +# Run regular test: cargo llvm-cov --workspace --all-features --no-fail-fast --no-report -- "${TEST_ARGS[@]}" -cargo llvm-cov --workspace --all-features --no-fail-fast --no-report --doc -- "${TEST_ARGS[@]}" +if [ "$DOCTEST" = "true" ]; then + # Run doc tests: + cargo llvm-cov --workspace --all-features --no-fail-fast --no-report --doc -- "${TEST_ARGS[@]}" +fi +# Generate report including doc tests: cargo llvm-cov --no-run --doctests "${OUTPUT_ARGS[@]}" +# Print summary including doc tests: cargo llvm-cov --no-run --doctests if [ -n "$OUTPUT_PATH" ]; then