Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
Add a test_args input
Browse files Browse the repository at this point in the history
  • Loading branch information
lpenz committed Jan 24, 2022
1 parent 43e76b4 commit 6b72aff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
- `dependencies_debian`: Debian packages to install before running the tests.
- `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.


If neither `output_type` and `output_path` are defined, the action by
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ inputs:
output_path:
description: Output path to pass to grcov and set as report variable
default: ''
test_args:
description: Arguments to pass to the test
outputs:
report:
description: Name of report file, for compatibility with rust-grcov
Expand Down
20 changes: 13 additions & 7 deletions entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@ else
}
fi

ARGS=()
TEST_ARGS=()
if [ -n "$INPUT_TEST_ARGS" ]; then
IFS=' ' read -r -a testargs <<< "$INPUT_TEST_ARGS"
TEST_ARGS+=( "${testargs[@]}" )
fi

OUTPUT_ARGS=()

if [ -n "$INPUT_OUTPUT_TYPE" ]; then
ARGS+=( "--$INPUT_OUTPUT_TYPE" )
OUTPUT_ARGS+=( "--$INPUT_OUTPUT_TYPE" )
fi

if [ -n "$INPUT_OUTPUT_PATH" ]; then
OUTPUT_PATH="$INPUT_OUTPUT_PATH"
ARGS+=( --output-path "$OUTPUT_PATH" )
OUTPUT_ARGS+=( --output-path "$OUTPUT_PATH" )
elif [ -z "$INPUT_OUTPUT_TYPE" ]; then
# Default if no output_type was specified either
OUTPUT_PATH="lcov.info"
ARGS+=( --lcov --output-path "$OUTPUT_PATH" )
OUTPUT_ARGS+=( --lcov --output-path "$OUTPUT_PATH" )
fi

export RUSTC_BOOTSTRAP
Expand All @@ -45,9 +51,9 @@ RUSTDOCFLAGS="$RUSTFLAGS"
RUST_BACKTRACE=1

cargo llvm-cov --workspace clean
cargo llvm-cov --workspace --all-features --no-fail-fast --no-report
cargo llvm-cov --workspace --all-features --no-fail-fast --no-report --doc
cargo llvm-cov --no-run --doctests "${ARGS[@]}"
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[@]}"
cargo llvm-cov --no-run --doctests "${OUTPUT_ARGS[@]}"
cargo llvm-cov --no-run --doctests

if [ -n "$OUTPUT_PATH" ]; then
Expand Down

0 comments on commit 6b72aff

Please sign in to comment.