{"id":13478471,"url":"https://github.com/xd009642/tarpaulin","last_synced_at":"2026-01-17T20:23:49.621Z","repository":{"id":37458113,"uuid":"87561381","full_name":"xd009642/tarpaulin","owner":"xd009642","description":"A code coverage tool for Rust projects","archived":false,"fork":false,"pushed_at":"2025-05-06T09:44:07.000Z","size":3768,"stargazers_count":2687,"open_issues_count":60,"forks_count":186,"subscribers_count":16,"default_branch":"develop","last_synced_at":"2025-05-07T23:36:20.814Z","etag":null,"topics":["cargo","coverage-report","coverage-reporting","hacktoberfest","rust","tarpaulin"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/cargo-tarpaulin","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xd009642.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"xd009642","patreon":null,"custom":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null}},"created_at":"2017-04-07T15:37:02.000Z","updated_at":"2025-05-06T15:34:58.000Z","dependencies_parsed_at":"2023-10-24T19:31:30.458Z","dependency_job_id":"1fabfb4f-0e24-4d3c-9686-9384fe8a8a15","html_url":"https://github.com/xd009642/tarpaulin","commit_stats":{"total_commits":1593,"total_committers":88,"mean_commits":"18.102272727272727","dds":"0.44569993722536094","last_synced_commit":"de9c43f371ae7204a48c0a9878fd99397775c9c1"},"previous_names":[],"tags_count":107,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xd009642%2Ftarpaulin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xd009642%2Ftarpaulin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xd009642%2Ftarpaulin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xd009642%2Ftarpaulin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xd009642","download_url":"https://codeload.github.com/xd009642/tarpaulin/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254249199,"owners_count":22039029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cargo","coverage-report","coverage-reporting","hacktoberfest","rust","tarpaulin"],"created_at":"2024-07-31T16:01:57.514Z","updated_at":"2026-01-17T20:23:49.606Z","avatar_url":"https://github.com/xd009642.png","language":"Rust","funding_links":["https://github.com/sponsors/xd009642"],"categories":["Rust","Development tools","Crates","Utilities","Cargo Subcommands"],"sub_categories":["Testing","Coverage","Parsers"],"readme":"# Tarpaulin\n\n[![Build Status](https://github.com/xd009642/tarpaulin/workflows/Build/badge.svg)](https://github.com/xd009642/tarpaulin/actions)\n[![Latest Version](https://img.shields.io/crates/v/cargo-tarpaulin.svg)](https://crates.io/crates/cargo-tarpaulin)\n[![License:MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Docker](https://img.shields.io/docker/automated/xd009642/tarpaulin.svg)](https://hub.docker.com/r/xd009642/tarpaulin/)\n[![Developers Wiki](https://img.shields.io/badge/development-wiki-yellowgreen.svg)](https://github.com/xd009642/tarpaulin/wiki/Developers)\n[![Coverage Status](https://coveralls.io/repos/github/xd009642/tarpaulin/badge.svg?branch=develop)](https://coveralls.io/github/xd009642/tarpaulin?branch=develop)\n\nTarpaulin is a code coverage reporting tool for the Cargo build system, named\nfor a waterproof cloth used to cover cargo on a ship.\n\nCurrently, Tarpaulin provides working line coverage, and while fairly reliable,\nmay still contain  minor inaccuracies in the results. A lot of work has been\ndone to get it working on a wide range of projects, but unique combinations of\npackages and build features can cause issues, so please report anything\nyou find that's wrong. Also, check out our roadmap for planned features.\n\nOn Linux, Tarpaulin's default tracing backend is still Ptrace and will only work\non x86\\_64 processors. This can be changed to the llvm coverage instrumentation\nwith `--engine llvm`. For Mac and Windows, this is the default collection\nmethod.\n\nIt can also be run in Docker, which is useful for when you don't use Linux but\nwant to run it locally, e.g. during development. See below for how to do that.\n\nBelow is the help-text for a thorough explanation of the flags and features\navailable:\n\n```\nCargo-Tarpaulin is a tool to determine code coverage achieved via tests\n\nUsage: cargo tarpaulin [OPTIONS] [-- \u003cARGS\u003e...]\n\nArguments:\n  [ARGS]...  Arguments to be passed to the test executables can be used to filter or skip certain tests\n\nOptions:\n      --print-rust-flags           Print the RUSTFLAGS options that tarpaulin will compile your program with and exit\n      --print-rustdoc-flags        Print the RUSTDOCFLAGS options that tarpaulin will compile any doctests with and exit\n      --color \u003cWHEN\u003e               Coloring: auto, always, never [possible values: Auto, Always, Never]\n      --debug                      Show debug output - this is used for diagnosing issues with tarpaulin\n  -v, --verbose                    Show extra output\n      --dump-traces                Log tracing events and save to a json file. Also, enabled when --debug is used\n      --stderr                     Print tarpaulin logs to stderr instead - test output will still be printed to stdout\n      --run-types \u003cTYPE\u003e           Type of the coverage run [possible values: Tests, Doctests, Benchmarks, Examples, Lib, Bins, AllTargets]\n      --benches                    Test all benches\n      --doc                        Test only this library's documentation\n      --all-targets                Test all targets (excluding doctests)\n      --lib                        Test only this package's library unit tests\n      --bins                       Test all binaries\n      --examples                   Test all examples\n      --tests                      Test all tests\n      --config \u003cFILE\u003e              Path to a toml file specifying a list of options this will override any other options set\n      --ignore-config              Ignore any project config files\n      --bin [\u003cNAME\u003e...]            Test only the specified binary\n      --example [\u003cNAME\u003e...]        Test only the specified example\n      --test [\u003cNAME\u003e...]           Test only the specified test target\n      --bench [\u003cNAME\u003e...]          Test only the specified bench target\n      --no-fail-fast               Run all tests regardless of failure\n      --profile \u003cNAME\u003e             Build artifacts with the specified profile\n      --ignore-tests               Ignore lines of test functions when collecting coverage (default)\n      --no-dead-code               Stops tarpaulin from building projects with -Clink-dead-code\n      --include-tests              Include lines of test functions when collecting coverage\n      --ignore-panics              Ignore panic macros in tests\n      --count                      Counts the number of hits during coverage\n  -i, --ignored                    Run ignored tests as well\n  -l, --line                       Line coverage\n      --skip-clean                 The opposite of --force-clean\n      --force-clean                Adds a clean stage to work around cargo bugs that may affect coverage results\n      --fail-under \u003cPERCENTAGE\u003e    Sets a percentage threshold for failure ranging from 0-100, if coverage is below exit with a non-zero code\n  -b, --branch                     Branch coverage: NOT IMPLEMENTED\n  -f, --forward                    Forwards unexpected signals to test. This is now the default behaviour\n      --coveralls \u003cKEY\u003e            Coveralls key, either the repo token, or if you're using travis use $TRAVIS_JOB_ID and specify travis-{ci|pro} in --ciserver\n      --report-uri \u003cURI\u003e           URI to send report to, only used if the option --coveralls is used\n      --no-default-features        Do not include default features\n      --features [\u003cFEATURES\u003e...]   Features to be included in the target project\n      --all-features               Build all available features\n      --all                        Alias for --workspace (deprecated)\n      --workspace                  Test all packages in the workspace\n  -p, --packages [\u003cPACKAGE\u003e...]    Package id specifications for which package should be build. See cargo help pkgid for more info\n  -e, --exclude [\u003cPACKAGE\u003e...]     Package id specifications to exclude from coverage. See cargo help pkgid for more info\n      --exclude-files [\u003cFILE\u003e...]  Exclude given files from coverage results has * wildcard\n      --include-files [\u003cFILE\u003e...]  Include only given files in coverage results. Can have a * wildcard\n  -t, --timeout \u003cSECONDS\u003e          Integer for the maximum time in seconds without response from test before timeout (default is 1 minute)\n      --post-test-delay \u003cSECONDS\u003e  Delay after test to collect coverage profiles\n      --follow-exec                Follow executed processes capturing coverage information if they're part of your project\n      --release                    Build in release mode\n      --no-run                     Compile tests but don't run coverage\n      --implicit-test-threads      Don't supply an explicit `--test-threads` argument to test executable. By default tarpaulin will infer the default rustc would pick if not ran via tarpaulin and set it\n      --locked                     Do not update Cargo.lock\n      --frozen                     Do not update Cargo.lock or any caches\n      --target \u003cTRIPLE\u003e            Compilation target triple\n      --target-dir \u003cDIR\u003e           Directory for all generated artifacts\n      --offline                    Run without accessing the network\n      --avoid-cfg-tarpaulin        Remove --cfg=tarpaulin from the RUSTFLAG\n  -j, --jobs \u003cN\u003e                   Number of parallel jobs, defaults to # of CPUs\n      --rustflags \u003cFLAGS\u003e          Rustflags to add when building project (can also be set via RUSTFLAGS env var)\n      --objects [\u003cobjects\u003e...]     Other object files to load which contain information for llvm coverage - must have been compiled with llvm coverage instrumentation (ignored for ptrace)\n  -Z [\u003cFEATURES\u003e...]               List of unstable nightly only flags\n  -o, --out [\u003cFMT\u003e...]             Output format of coverage report [possible values: Json, Stdout, Xml, Html, Lcov]\n      --engine \u003cENGINE\u003e            Coverage tracing backend to use [possible values: Auto, Ptrace, Llvm]\n      --output-dir \u003cPATH\u003e          Specify a custom directory to write report files\n      --command \u003cCMD\u003e              cargo subcommand to run. So far only test and build are supported [possible values: Test, Build]\n  -r, --root \u003cDIR\u003e                 Calculates relative paths to root directory. If --manifest-path isn't specified it will look for a Cargo.toml in root\n      --manifest-path \u003cPATH\u003e       Path to Cargo.toml\n      --ciserver \u003cSERVICE\u003e         CI server being used, if unspecified tarpaulin may automatically infer for coveralls uploads\n      --fail-immediately           Option to fail immediately after a single test fails\n  -h, --help                       Print help\n  -V, --version                    Print version\n```\n\n### Note on tests using signals\n\nIf your tests or application make use of unix signals they may not work with\nptrace instrumentation in Tarpaulin. This is because Tarpaulin relies on the\nsigtrap signal to catch when the instrumentation points are hit. The\n`--forward` option results in forwarding the signals from process stops not\ncaused by SIGSTOP, SIGSEGV or SIGILL to the test binary.\n\n### Nuances with LLVM Coverage\n\nDespite generally being far more accurate there are some nuances with the LLVM\ncoverage instrumentation.\n\n1. If a test has a non-zero exit code coverage data isn't returned\n2. Some areas of thread unsafety\n3. Unable to handle fork and similar syscalls (one process will overwrite another's\nprofraw file)\n\nIn these cases coverage results may differ a lot between ptrace and llvm and llvm\ncoverage may be a worse choice. Things like doc tests with the `should_panic`\nattribute or `--no-fail-fast` won't report any coverage because of non-zero\nexit codes and if you use these and want coverage data from them you should\navoid the llvm coverage backend.\n\n## Features\n\nBelow is a list of features currently implemented. As Tarpaulin loads binary\nfiles into memory and parses the debugging information, different setups could\nlead to coverage not working. In this instance, please raise an issue detailing\nyour setup and an example project and I'll attempt to fix it (please link us to\na repo and the commit containing your project and paste the verbose output).\n\n* Line coverage\n* Full compatibility with cargo test CLI arguments\n* Uploading coverage to \u003chttps://coveralls.io\u003e or \u003chttps://codecov.io\u003e\n* HTML report generation and other coverage report types\n* Coverage of tests, doctests, benchmarks and examples possible\n* Excluding irrelevant files from coverage\n* Config file for mutually exclusive coverage settings (see `Config file` section for details)\n\n## Issues and Contributing\n\nIssues, feature requests and pull requests are always welcome! For a guide on\nhow to approach bugs found in Tarpaulin and add features please check\n[CONTRIBUTING](CONTRIBUTING.md). If you're having any troubles also look to our\n[TROUBLESHOOTING](TROUBLESHOOTING.md)\n\nRust 1.23 introduced a regression in the compiler affecting Tarpaulin's\naccuracy. If you see missing lines or files, check your compiler version.\n\n## Usage\n\n### Installation\n\nTarpaulin is a command-line program, you install it into your development\nenvironment with cargo install:\n\n```text\ncargo install cargo-tarpaulin\n```\n\nWhen using the [Nix](https://nixos.org/nix) package manager, the `nixpkgs.cargo-tarpaulin` package can be used.\nThis ensures that Tarpaulin will be built with the same rust version as the rest of your packages.\n\nYou can also use [cargo-binstall](https://github.com/ryankurte/cargo-binstall):\n\n```text\ncargo binstall cargo-tarpaulin\n```\n\n### Environment Variables\n\nWhen Tarpaulin runs your tests it strives to run them in the same environment as if they were run via cargo test.\nTo achieve this it sets the following environment variables when executing the test binaries:\n\n- **RUST_BACKTRACE**      - _Set to `1` when --verbose flag is used unless it is already set_\n- **CARGO_MANIFEST_DIR**  - _Path to Cargo.toml From --root | --manifest-path or guessed from the current or parent directory_\n- **CARGO_PKG_NAME**      - _From Cargo.toml_\n- **CARGO_PKG_AUTHORS**   - _From Cargo.toml_\n- **CARGO_PKG_VERSION**   - _From Cargo.toml_\n- **LLVM_PROFILE_FILE**   - _Used for LLVM coverage_\n\n### Cargo Manifest\n\nFor Tarpaulin to construct the Cargo environment correctly, Tarpaulin needs to find Cargo.toml by either:\n\n- Using *--root* or *--manifest-path* or\n- By invoking Cargo from the current working directory within the project holding Cargo.toml manifest or\n- By invoking Cargo from a sub-directory within the project\n\nIf Cargo does not find any Cargo.toml from using either of the above methods the run will error \"cargo metadata\" and exit.\n\nSeveral RFCs are open in rust-lang to expose [more of these](https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-3rd-party-subcommands) directly in order to avoid the issues arising out of this.\n\n### Command line\n\nTo get detailed help on available arguments when running Tarpaulin call:\n\n```bash\ncargo tarpaulin --help\n```\n\nCurrently, no options are required, if no root directory is defined Tarpaulin\nwill run in the current working directory.\n\nBelow is a Tarpaulin run utilising one of our example projects. This is a\nrelatively simple project to test and if you check the test, you can see the\noutput correctly reports the lines the test hits.\n\n```bash\ncargo tarpaulin\nJan 30 21:43:33.715  INFO cargo_tarpaulin::config: Creating config\nJan 30 21:43:33.908  INFO cargo_tarpaulin: Running Tarpaulin\nJan 30 21:43:33.908  INFO cargo_tarpaulin: Building project\nJan 30 21:43:33.908  INFO cargo_tarpaulin::cargo: Cleaning project\n   Compiling simple_project v0.1.0 (/home/daniel/personal/tarpaulin/tests/data/simple_project)\n    Finished test [unoptimized + debuginfo] target(s) in 0.51s\nJan 30 21:43:34.631  INFO cargo_tarpaulin::process_handling::linux: Launching test\nJan 30 21:43:34.631  INFO cargo_tarpaulin::process_handling: running /home/daniel/personal/tarpaulin/tests/data/simple_project/target/debug/deps/simple_project-417a21905eb8be09\n\nrunning 1 test\ntest tests::bad_test ... ok\n\ntest result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s\n\nJan 30 21:43:35.563  INFO cargo_tarpaulin::report: Coverage Results:\n|| Uncovered Lines:\n|| src/lib.rs: 6\n|| src/unused.rs: 4-6\n|| Tested/Total Lines:\n|| src/lib.rs: 3/4\n|| src/unused.rs: 0/3\n||\n42.86% coverage, 3/7 lines covered\n```\n\nTarpaulin can also report the change in coverage for each file between runs. If\nthe tests were updated in the previous example to cover all the lines we would\nexpect the following output.\n\n```text\ncargo tarpaulin\nJan 30 21:45:37.611  INFO cargo_tarpaulin::config: Creating config\nJan 30 21:45:37.623  INFO cargo_tarpaulin: Running Tarpaulin\nJan 30 21:45:37.623  INFO cargo_tarpaulin: Building project\nJan 30 21:45:37.623  INFO cargo_tarpaulin::cargo: Cleaning project\n   Compiling simple_project v0.1.0 (/home/daniel/personal/tarpaulin/tests/data/simple_project)\n    Finished test [unoptimized + debuginfo] target(s) in 0.40s\nJan 30 21:45:38.085  INFO cargo_tarpaulin::process_handling::linux: Launching test\nJan 30 21:45:38.085  INFO cargo_tarpaulin::process_handling: running /home/daniel/personal/tarpaulin/tests/data/simple_project/target/debug/deps/simple_project-417a21905eb8be09\n\nrunning 2 tests\ntest unused::blah ... ok\ntest tests::bad_test ... ok\n\ntest result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s\n\nJan 30 21:45:38.990  INFO cargo_tarpaulin::report: Coverage Results:\n|| Uncovered Lines:\n|| src/lib.rs: 6\n|| Tested/Total Lines:\n|| src/lib.rs: 3/4 +0.00%\n|| src/unused.rs: 3/3 +100.00%\n||\n85.71% coverage, 6/7 lines covered, +42.86% change in coverage\n```\n\nHint: if using coveralls.io with travis-ci run with the options\n`--ciserver travis-ci --coveralls $TRAVIS_JOB_ID`. The coveralls.io repo-token\nis mainly designed for private repos and it won't generate a badge for the\ncoverage results submitted (although you can still see them on the coveralls\nweb interface). For an example of a project using Tarpaulin, you can check out\nmy crate [keygraph-rs](https://github.com/xd009642/keygraph-rs).\n\n### Ignoring code in files\n\nTarpaulin allows you to ignore modules or functions using attributes.\nBelow is an example of ignoring the main function in a project:\n\n```Rust\n#[cfg(not(tarpaulin_include))]\nfn main() {\n    println!(\"I won't be included in results\");\n}\n\n// Also supports the nightly rustc `coverage(off)` attribute.\n#[coverage(off)]\nfn not_included() {\n\n}\n```\n\nUnfortunately, due to the unexpected cfg warnings cargo now emits you will\nlikely want to add the recommended lints to your `Cargo.toml`, or utilise any\nexisting build scripts. If you're using a nightly compiler then making use of\nunstable coverage attributes may be preferable.\n\nHowever, the skip attribute only allows you to exclude code from coverage\nit doesn't change the code present in the binaries or what tests are run.\nBecause of this, `--cfg=tarpaulin` is used when building your project for\nTarpaulin allowing you to also conditionally include/exclude code from\ncompilation entirely. For example to have a test that isn't included in\nthe test binaries when built with Tarpaulin and cannot be run just do:\n\n```Rust\n#[test]\n#[cfg(not(tarpaulin))]\nfn big_test_not_for_tarpaulin() {\n    // Something that would be very slow in tarpaulin or not work\n}\n```\n\nIf you still want the test included in the binary and ignored by default\nyou can use:\n\n```Rust\n#[test]\n#[cfg_attr(tarpaulin, ignore)]\nfn ignored_by_tarpaulin() {\n\n}\n```\n\nThere is also nightly support for using tool attributes with Tarpaulin for\nskip. For example:\n\n```Rust\n#![feature(register_tool)]\n#![register_tool(tarpaulin)]\n\n#[tarpaulin::skip]\nfn main() {\n    println!(\"I won't be in coverage stats\");\n}\n```\n\n### Recompilation\n\nAs Tarpaulin changes the `RUSTFLAGS` when building tests sometimes rebuilds of\ntest binaries can't be avoided. There is also a `--force-clean` and `--skip-clean`\nargument, the default has been changed at times to avoid issues with incremental\ncompilation when changing `RUSTFLAGS`. If you aim to reduce the amount of\nunnecessary recompilation attempting to add the `--skip-clean` flag should be\nthe first step. After that you can either:\n\n1. Use `cargo tarpaulin --print-rust-flags` and use those flags for dev and coverage\n2. Use `--target-dir` when running Tarpaulin and have a coverage build and dev build\n\n### Continuous Integration Services\n\nTarpaulin aims to be easy to add to your CI workflow. With well-tested support\nfor Travis-CI it also supports sending CI specific meta-data to coveralls.io for\nCircle, Semaphore, Jenkins and Codeship (though only Jenkins has been tested).\n\nYou can also use Tarpaulin on Azure, check out\n[crate-ci/azure-pipelines](https://github.com/crate-ci/azure-pipelines) for an\nexample config.\n\n#### Travis-ci and Coverage Sites\n\nThe expected most common use case is launching coverage via a CI service to\nupload to a site like codecov or coveralls. Given the built-in support and\nubiquity of travis-ci it seems prudent to document the required steps here for\nnew users. To follow these steps you'll first need a travis-ci and a project setup\nfor your coverage reporting site of choice.\n\nWe recommend taking the minimal rust .travis.yml, installing the libssl-dev\ndependency Tarpaulin has and then running Tarpaulin with the version of\nrustc you require. Tarpaulin is installed in `before_cache` to allow it to be cached\nand prevent having to reinstall every Travis run. You can also replace `cargo test`\nwith a verbose run of Tarpaulin to see the test results as well as coverage output.\n\nTarpaulin is run after success as there are still some unstable features which could\ncause coverage runs to fail. If you don't rely on any of these features you can\nalternatively replace `cargo test` with a call to `cargo tarpaulin`.\n\nFor codecov.io you'll need to export `CODECOV_TOKEN` there are instructions on this in\nthe settings of your codecov project.\n\n```yml\nlanguage: rust\n# tarpaulin has only been tested on bionic and trusty other distros may have issues\ndist: bionic\naddons:\n    apt:\n        packages:\n            - libssl-dev\ncache: cargo\nrust:\n  - stable\n  - beta\n  - nightly\nmatrix:\n  allow_failures:\n    - rust: nightly\n\nbefore_script: |\n  if [[ \"$TRAVIS_RUST_VERSION\" == stable ]]; then\n    cargo install cargo-tarpaulin\n  fi\n\nscript:\n- cargo clean\n- cargo build\n- cargo test\n\nafter_success: |\n  if [[ \"$TRAVIS_RUST_VERSION\" == stable ]]; then\n    # Uncomment the following line for coveralls.io\n    # cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID\n\n    # Uncomment the following two lines create and upload a report for codecov.io\n    # cargo tarpaulin --out xml\n    # bash \u003c(curl -s https://codecov.io/bash)\n  fi\n```\n\nIf you rely on certain nightly features you may need to change the `before_script` to\n`before_cache` to force Tarpaulin to reinstall each time. However, if it can be avoided it\nwill speed up your CI runs.\n\nAlternatively, there are the prebuilt docker images or you can use\n[cargo-binstall](https://github.com/cargo-bins/cargo-binstall).\n\nThe prebuilt binary is built using github actions ubuntu:latest image, because of this it\ndoesn't work on xenial or trusty, but it works on bionic. You should still keep the rest\nof the recommended travis settings.\n\n### GitHub Actions\n\nFile `.github/workflows/coverage.yml`\nExample how to run coverage within `docker` with `seccomp` in GitHub Actions and push the result\nto \u003ccodecov.io\u003e.\n\n```yml\nname: coverage\n\non: [push]\njobs:\n  test:\n    name: coverage\n    runs-on: ubuntu-latest\n    container:\n      image: xd009642/tarpaulin:develop-nightly\n      options: --security-opt seccomp=unconfined\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v2\n\n      - name: Generate code coverage\n        run: |\n          cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out xml\n\n      - name: Upload to codecov.io\n        uses: codecov/codecov-action@v5\n        with:\n          token: ${{secrets.CODECOV_TOKEN}}\n          fail_ci_if_error: true\n```\n\n#### CircleCI\n\nTo run Tarpaulin on CircleCI you need to run Tarpaulin in docker and set the\nmachine flag to true as shown below:\n\n```yml\njobs:\n  coverage:\n    machine: true\n    steps:\n      - checkout\n      - run:\n          name: Coverage with docker\n          command: docker run --rm --security-opt seccomp=unconfined -v \"${PWD}:/volume\" xd009642/tarpaulin\n```\n\n#### Gitlab Pipelines\n\nTo get the coverage results showing up in your Gitlab pipelines add the following regex to the `Test\ncoverage` section in the gitlab job definition in `.gitlab-ci.yml`:\n\n```yml\njob: ...\n  coverage: '/^\\d+.\\d+% coverage/'\n```\n\nGitlab can [show coverage information] in the diff of a merge request. For that, use\n\n```yml\njob: ...\n  artifacts:\n    reports:\n      coverage_report:\n        coverage_format: cobertura\n        path: cobertura.xml\n```\n\nand generate a `cobertura.xml` as described under [Pycobertura](#pycobertura).\n\n  [show coverage information]: https://docs.gitlab.com/ee/ci/testing/test_coverage_visualization.html\n\nFor installation add `cargo install cargo-tarpaulin -f` to the script section.\n\n### Docker\n\nTarpaulin has builds deployed to [docker-hub](https://hub.docker.com/r/xd009642/tarpaulin/),\nto run Tarpaulin on any system that has Docker, run this in your project directory:\n\n```text\ndocker run --rm --security-opt seccomp=unconfined -v \"${PWD}:/volume\" xd009642/tarpaulin\n```\n\nThis builds your project inside Docker and runs Tarpaulin without any arguments. There are\nalso tags available for the latest version on the develop branch in stable or nightly. And\nversions after 0.5.6 will have the latest release built with the rust stable and nightly\ncompilers. To get the latest development version built with rustc-nightly run the following:\n\n```text\ndocker run --rm --security-opt seccomp=unconfined -v \"${PWD}:/volume\" xd009642/tarpaulin:develop-nightly\n```\n\nNote that the build might fail if the Docker image doesn't contain any necessary\ndependencies. In that case, you can install dependencies before, like this:\n\n```text\ndocker run --rm --security-opt seccomp=unconfined -v \"${PWD}:/volume\" xd009642/tarpaulin sh -c \"apt-get install xxx \u0026\u0026 cargo tarpaulin\"\n```\n\nAlternatively, taking the seccomp json and setting all seccomp actions\nfor the `personality` syscall to `SCMP_ACT_ALLOW` to avoid removing all\nthe seccomp policies for Docker.\n\n### Config file\n\nTarpaulin has a config file setting where multiple coverage setups can be\nencoded in a toml file. This can be provided by an argument,\nby the environment variable `CARGO_TARPAULIN_CONFIG_FILE` or if a\n`.tarpaulin.toml` or `tarpaulin.toml` is present in the same directory as\nthe projects manifest or in the root directory that will be used unless\n`--ignore-config` is passed. Below is an example file:\n\n```toml\n[feature_a_coverage]\nfeatures = \"feature_a\"\n\n[feature_a_and_b_coverage]\nfeatures = \"feature_a feature_b\"\nrelease = true\n\n[report]\ncoveralls = \"coveralls_key\"\nout = [\"Html\", \"Xml\"]\n```\n\nHere we'd create three configurations, one would run your tests with\n`feature_a` enabled, and the other with the tests built-in release and\nboth `feature_a` and `feature_b` enabled. The last configuration uses a reserved\nconfiguration name `report` and this doesn't result in a coverage run but\naffects the report output. This is a reserved feature name and any non-reporting\nbased options chosen will not affect the output of Tarpaulin.\n\nFor reference on available keys and their types refer to the CLI help text\nat the start of the readme or [`src/config/mod.rs`](https://github.com/xd009642/tarpaulin/blob/develop/src/config/mod.rs) for the concrete types\nif anything is unclear. For arguments to be passed into the test binary that\nfollow `--` in Tarpaulin use `args` in the toml file. Find an example in the projects [`tarpaulin.toml](./tarpaulin.toml) file.\n\nSetting the field `config` will not affect the run as it won't be parsed\nfor additional configuration.\n\nFor the flags `--lib`, `--examples`, `--benches`, `--tests`, `--all-targets`,\n`--doc`, `--bins` use the `run-types` entry in the config file.\n\n## Extending Tarpaulin\n\nThere are some tools available which can extend Tarpaulin functionality for\nother potential user needs.\n\n### Procedural Macros\n\nNormally, Tarpaulin can't report on code coverage within the code for a\nprocedural macro. You'll need to add a test that expands the macro at run-time\nto get those stats. The\n[`runtime-macros` crate](https://crates.io/crates/runtime-macros) was made for\nthis purpose, and its documentation describes how to use it with Tarpaulin.\n\n### Pycobertura\n\n[`pycobertura`](https://pypi.python.org/pypi/pycobertura) is a python library\nfor working with cobertura reports. It offers a report diffing tool as well as\nits own report implementations.\n\nTo generate a `cobertura.xml` simply run the following Tarpaulin command:\n\n```text\ncargo tarpaulin --out xml\n```\n\nThen install `pycobertura` with pip and execute the desired command.\n\nAs Tarpaulin doesn't allow you to change the name of the generated cobertura\nreport be mindful of this if diffing reports between multiple commits.\n\n## License\n\nTarpaulin is currently licensed under the terms of both the MIT license and the\nApache License (Version 2.0). See LICENSE-MIT and LICENSE-APACHE for more\ndetails.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxd009642%2Ftarpaulin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxd009642%2Ftarpaulin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxd009642%2Ftarpaulin/lists"}