Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/producer.rs:544: No input files found #1087

Open
J4CKVVH173 opened this issue Aug 2, 2023 · 3 comments
Open

src/producer.rs:544: No input files found #1087

J4CKVVH173 opened this issue Aug 2, 2023 · 3 comments

Comments

@J4CKVVH173
Copy link

I try to configurate gitlab ci-cd for rust and I would like to have a test's coverage. I used the instruction from grcov but when I try to run grcov target/coverage --binary-path target/debug -s . -o target/coverage --keep-only 'src/*' --output-types html,cobertura I get this rust's panic message: A panic occurred at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/grcov-0.8.19/src/producer.rs:544: No input files found.
I can't understand where I messed up.

Full gitlab-ci sript body

  variables:
    LLVM_PROFILE_FILE: "target/coverage/%p-%m.profraw"
  script:
    - apt update
    - apt upgrade -y
    - apt install -y pkg-config libssl-dev
    - cargo test

    - mkdir target/coverage
    - cargo install grcov
    - grcov target/coverage --binary-path target/debug -s . -o target/coverage --keep-only 'src/*' --output-types html,cobertura
    # Extract just the top-level coverage number from the XML report.
    - xmllint --xpath "concat('Coverage:\ ', 100 * string(//coverage/@line-rate), '%')" target/coverage/cobertura.xml
@ktbrennan28
Copy link

Hey, I am having the same issue with a Windows environment. Were you able to resolve this?

@richard-mck
Copy link

I found I need to follow the full set of instructions not just the gitlab-specific elements.

I'm using an image with grcov pre-installed. My CI job works as expected, here's what it looks like:

cargo coverage:
  stage: test
  variables:
    CARGO_TEST_OPTS: "--workspace"
    TEST_BIN_ARGS: ""
    LLVM_PROFILE_FILE: "target/coverage/%p-%m.profraw"
    RUSTFLAGS: "-Cinstrument-coverage"
  script:
    - mkdir -p target/coverage
    - rustup component add llvm-tools-preview
    - cargo build
    - cargo test ${CARGO_TEST_OPTS} -- ${TEST_BIN_ARGS}
    - grcov target/coverage -b target/debug -o target/coverage --output-types cobertura
  artifacts:
    paths:
      - target/coverage
    reports:
      coverage_report:
        coverage_format: cobertura
        path: target/coverage/cobertura.xml

Without the build step, the profraw files weren't getting generated.

@J4CKVVH173
Copy link
Author

I've found out that it's important to add extra keys to rust test runner and after this grcov worked

LLVM_PROFILE_FILE='target/coverage/%p-%m.profraw' RUSTFLAGS='-C instrument-coverage' cargo test - test runner for Docker rust:1.71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants