A code coverage tool for Rust projects

Overview

Tarpaulin

Build Status Latest Version License:MIT Docker Developers Wiki

Tarpaulin is a code coverage reporting tool for the Cargo build system, named for a waterproof cloth used to cover cargo on a ship. Currently, tarpaulin provides working line coverage and while fairly reliable may still contain minor inaccuracies in the results. A lot of work has been done to get it working on a wide range of projects, but often unique combinations of packages and build features can cause issues so please report anything you find that's wrong. Also, check out our roadmap for planned features.

Tarpaulin only supports x86_64 processors running Linux. This is because instrumenting breakpoints into executables and tracing their execution requires processor and OS specific code. It is a goal when greater stability is reached to add wider system support, however this is sufficient to run Tarpaulin on popular CI tools like Travis.

It can also be run in Docker, which is useful for when you don't use Linux but want to run it locally, e.g. during development. See below for how to do that.

Below is the help-text for a thorough explanation of the flags and features available:

cargo-tarpaulin version: 0.18.5
Tool to analyse test coverage of cargo projects

USAGE:
    cargo tarpaulin [FLAGS] [OPTIONS] [-- <args>...]

FLAGS:
        --all                    Alias for --workspace (deprecated)
        --all-features           Build all available features
        --all-targets            Test all targets
        --avoid-cfg-tarpaulin    Remove --cfg=tarpaulin from the RUSTFLAG
        --benches                Test all benches
        --bins                   Test all binaries
    -b, --branch                 Branch coverage: NOT IMPLEMENTED
        --count                  Counts the number of hits during coverage
        --debug                  Show debug output - this is used for diagnosing issues with tarpaulin
        --doc                    Test only this library's documentation
        --dump-traces            Log tracing events and save to a json file. Also, enabled when --debug is used
        --examples               Test all examples
        --follow-exec            Follow executed processes capturing coverage information if they're part of your
                                 project.
        --force-clean            Adds a clean stage to work around cargo bugs that may affect coverage results
    -f, --forward                Forwards unexpected signals to test. Tarpaulin will still take signals it is expecting.
        --frozen                 Do not update Cargo.lock or any caches
    -h, --help                   Prints help information
        --ignore-config          Ignore any project config files
        --ignore-panics          Ignore panic macros in tests
        --ignore-tests           Ignore lines of test functions when collecting coverage
    -i, --ignored                Run ignored tests as well
        --lib                    Test only this package's library unit tests
    -l, --line                   Line coverage
        --locked                 Do not update Cargo.lock
        --no-default-features    Do not include default features
        --no-fail-fast           Run all tests regardless of failure
        --no-run                 Compile tests but don't run coverage
        --offline                Run without accessing the network
        --print-rust-flags       Print the RUSTFLAGS options that tarpaulin will compile your program with and exit
        --print-rustdoc-flags    Print the RUSTDOCFLAGS options that tarpaulin will compile any doctests with and exit
        --release                Build in release mode.
        --skip-clean             The opposite of --force-clean
        --tests                  Test all tests
    -V, --version                Prints version information
    -v, --verbose                Show extra output
        --workspace              Test all packages in the workspace

OPTIONS:
    -Z <FEATURES>...                 List of unstable nightly only flags
        --bench <NAME>...            Test only the specified bench target
        --bin <NAME>...              Test only the specified binary
        --ciserver <SERVICE>         Name of service, supported services are:
                                     travis-ci, travis-pro, circle-ci, semaphore, jenkins and codeship.
                                     If you are interfacing with coveralls.io or another site you can also specify a
                                     name that they will recognise. Refer to their documentation for this.
        --color <WHEN>               Coloring: auto, always, never [possible values: Auto, Always, Never]
        --command <CMD>              cargo subcommand to run. So far only test and build are supported [possible values:
                                     Test, Build]
        --config <FILE>              Path to a toml file specifying a list of options this will override any other
                                     options set
        --coveralls <KEY>            Coveralls key, either the repo token, or if you're using travis use $TRAVIS_JOB_ID
                                     and specify travis-{ci|pro} in --ciserver
        --example <NAME>...          Test only the specified example
    -e, --exclude <PACKAGE>...       Package id specifications to exclude from coverage. See cargo help pkgid for more
                                     info
        --exclude-files <FILE>...    Exclude given files from coverage results has * wildcard
        --fail-under <PERCENTAGE>    Sets a percentage threshold for failure ranging from 0-100, if coverage is below
                                     exit with a non-zero code
        --features <FEATURES>...     Features to be included in the target project
    -j, --jobs <N>                   Number of parallel jobs, defaults to # of CPUs
        --manifest-path <PATH>       Path to Cargo.toml
    -o, --out <FMT>...               Output format of coverage report [possible values: Json, Stdout, Xml, Html, Lcov]
        --output-dir <PATH>          Specify a custom directory to write report files
    -p, --packages <PACKAGE>...      Package id specifications for which package should be build. See cargo help pkgid
                                     for more info
        --profile <NAME>             Build artefacts with the specified profile
        --report-uri <URI>           URI to send report to, only used if the option --coveralls is used
    -r, --root <DIR>                 Calculates relative paths to root directory. If --manifest-path isn't specified it
                                     will look for a Cargo.toml in root
        --run-types <TYPE>...        Type of the coverage run [possible values: Tests, Doctests, Benchmarks, Examples,
                                     Lib, Bins, AllTargets]
        --rustflags <FLAGS>          rustflags to add when building project (can also be set via RUSTFLAGS env var)
        --target <TRIPLE>            Compilation target triple
        --target-dir <DIR>           Directory for all generated artifacts
        --test <NAME>...             Test only the specified test target
    -t, --timeout <SECONDS>          Integer for the maximum time in seconds without response from test before timeout
                                     (default is 1 minute).

ARGS:
    <args>...    Arguments to be passed to the test executables can be used to filter or skip certain tests

Note on tests using signals

If your tests or application make use of unix signals they may not work with tarpaulin. This is because tarpaulin relies on the sigtrap signal to catch when the instrumentation points are hit. The --forward option results in forwarding the signals from process stops not caused by SIGSTOP, SIGSEGV or SIGILL to the test binary.

Features

Below is a list of features currently implemented. As Tarpaulin loads binary files into memory and parses the debugging information, different setups could lead to coverage not working. In this instance, please raise an issue detailing your setup and an example project and I'll attempt to fix it (please link us to a repo and the commit containing your project and paste the verbose output).

  • Line coverage
  • Full compatibility with cargo test CLI arguments
  • Uploading coverage to https://coveralls.io or https://codecov.io
  • HTML report generation and other coverage report types
  • Coverage of tests, doctests, benchmarks and examples possible
  • Excluding irrelevant files from coverage
  • Config file for mutually exclusive coverage settings (see Config file section for details)

Usage

Installation

Tarpaulin is a command-line program, you install it into your linux development environment with cargo install:

cargo install cargo-tarpaulin

Tarpaulin used to rely on Cargo as a dependency and then require an ssl install as well as other libraries but now it uses your system cargo simplifying the installation and massively reducing the install time on CI.

When using the Nix package manager, the nixpkgs.cargo-tarpaulin package can be used. This ensures that tarpaulin will be built with the same rust version as the rest of your packages.

You can also use cargo-binstall:

cargo binstall cargo-tarpaulin

Environment Variables

When tarpaulin runs your tests it strives to run them in the same environment as if they were ran via cargo test. In order to achieve this it sets the following environment variables when executing the test binaries:

  • RUST_BACKTRACE - When --verbose flag is used
  • CARGO_MANIFEST_DIR - Path to Cargo.toml From --root | --manifest-path or guessed from the current or parent directory
  • CARGO_PKG_NAME - From Cargo.toml
  • CARGO_PKG_AUTHORS - From Cargo.toml
  • CARGO_PKG_VERSION - From Cargo.toml
  • LLVM_PROFILE_FILE - Used for LLVM coverage

Cargo Manifest

In order for tarpaulin to construct the Cargo environment correctly, tarpaulin needs to find Cargo.toml by either:

  • Using --root or --manifest-path or
  • By invoking Cargo from the current working directory within the project holding Cargo.toml manifest or
  • By invoking Cargo from a sub-directory within the project

If Cargo does not find any Cargo.toml from using either of above methods the run will error "cargo metadata" and exit.

Several RFCs are open in rust-lang to expose more of these directly in order to avoid the issues arising out of this.

Command line

To get detailed help on available arguments when running tarpaulin call:

cargo tarpaulin --help

Currently no options are required, if no root directory is defined Tarpaulin will run in the current working directory.

Below is a Tarpaulin run utilising one of our example projects. This is a relatively simple project to test and if you check the test, you can see the output correctly reports the lines the test hits.

cargo tarpaulin -v
[INFO tarpaulin] Running Tarpaulin
[INFO tarpaulin] Building project
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
[DEBUG tarpaulin] Processing simple_project
[INFO tarpaulin] Launching test
[INFO tarpaulin] running /home/xd009642/code/rust/tarpaulin/tests/data/simple_project/target/debug/deps/simple_project-b0accf6671d080e0

running 1 test
test tests::bad_test ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

[INFO tarpaulin] Coverage Results:
|| Uncovered Lines:
|| src/lib.rs: 6
|| src/unused.rs: 4-6
|| Tested/Total Lines:
|| src/lib.rs: 5/6
|| src/unused.rs: 0/3
||
55.56% coverage, 5/9 lines covered

Tarpaulin can also report the change in coverage for each file between runs. If the tests were updated in the previous example to cover all the lines we would expect the following output.

cargo tarpaulin -v
[INFO tarpaulin] Running Tarpaulin
[INFO tarpaulin] Building project
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
[DEBUG tarpaulin] Processing simple_project
[INFO tarpaulin] Launching test
[INFO tarpaulin] running /home/xd009642/code/rust/tarpaulin/tests/data/simple_project/target/debug/deps/simple_project-b0accf6671d080e0

running 1 test
test tests::bad_test ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

[INFO tarpaulin] Coverage Results:
|| Tested/Total Lines:
|| src/lib.rs: 6/6 +16.67%
|| src/unused.rs: 3/3 +100%
||
100% coverage, 9/9 lines covered, +44.44% change in coverage

Hint: if using coveralls.io with travis-ci run with the options --ciserver travis-ci --coveralls $TRAVIS_JOB_ID. The coveralls.io repo-token is mainly designed for private repos and it won't generate a badge for the coverage results submitted (although you can still see them on the coveralls web interface). For an example of a project using Tarpaulin, you can check out my crate keygraph-rs.

Ignoring code in files

Before tarpaulin 0.13.4 you could ignore code in blocks with #[cfg_attr(tarpaulin, skip)] this has changed with 0.13.4 and onwards and the new instructions are described below. If you get compiler errors mentioning unknown attribute skip use the --avoid-cfg-tarpaulin flag, this affects a small number of users as it wasn't a largely adopted feature so also look to updating your code or seeing if any of your dependencies are out of date.

Tarpaulin allows you to ignore modules or functions using attributes. Below is an example of ignoring the main function in a project:

#[cfg(not(tarpaulin_include))]
fn main() {
    println!("I won't be included in results");
}

// Also supports the rustc `no_coverage` attribute.
#[no_coverage]
fn not_included() {

}

However, the skip attribute only allows you to exclude code from coverage it doesn't change the code present in the binaries or what tests are ran. Because of this, --cfg=tarpaulin is used when building your project for Tarpaulin allowing you to also conditionally include/exclude code from compilation entirely. For example to have a test that isn't included in the test binaries when built with tarpaulin and cannot be ran just do:

#[test]
#[cfg(not(tarpaulin))]
fn big_test_not_for_tarpaulin() {
    // Something that would be very slow in tarpaulin or not work
}

If you still want the test included in the binary just ignored by default you can use:

#[test]
#[cfg_attr(tarpaulin, ignore)]
fn ignored_by_tarpaulin() {

}

There is also nightly support for using tool attributes with tarpaulin for skip. For example:

#![feature(register_tool)]
#![register_tool(tarpaulin)]

#[tarpaulin::skip]
fn main() {
    println!("I won't be in coverage stats");
}

Continuous Integration Services

Tarpaulin aims to be easy to add to your CI workflow. With well tested support for Travis-CI it also supports sending CI specific meta-data to coveralls.io for Circle, Semaphore, Jenkins and Codeship (though only Jenkins has been tested).

You can also use Tarpaulin on Azure, check out crate-ci/azure-pipelines for an example config.

Travis-ci and Coverage Sites

The expected most common usecase is launching coverage via a CI service to upload to a site like codecov or coveralls. Given the built in support and ubiquity of travis-ci it seems prudent to document the required steps here for new users. To follow these steps you'll first need a travis-ci and a project setup for your coverage reporting site of choice.

We recommend taking the minimal rust .travis.yml, installing the libssl-dev dependency tarpaulin has and then running Tarpaulin with the version of rustc you require. Tarpaulin is installed in before_cache to allow it to be cached and prevent having to reinstall every Travis run. You can also replace cargo test with a verbose run of tarpaulin to see the test results as well as coverage output.

Tarpaulin is ran after success as there are still some unstable features which could cause coverage runs to fail. If you don't rely on any of these features you can alternatively replace cargo test with a call to cargo tarpaulin.

For codecov.io you'll need to export CODECOV_TOKEN are instructions on this in the settings of your codecov project.

language: rust
# tarpaulin has only been tested on bionic and trusty other distros may have issues
dist: bionic
addons:
    apt:
        packages:
            - libssl-dev
cache: cargo
rust:
  - stable
  - beta
  - nightly
matrix:
  allow_failures:
    - rust: nightly

before_script: |
  if [[ "$TRAVIS_RUST_VERSION" == stable ]]; then
    cargo install cargo-tarpaulin
  fi

script:
- cargo clean
- cargo build
- cargo test

after_success: |
  if [[ "$TRAVIS_RUST_VERSION" == stable ]]; then
    # Uncomment the following line for coveralls.io
    # cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID

    # Uncomment the following two lines create and upload a report for codecov.io
    # cargo tarpaulin --out Xml
    # bash <(curl -s https://codecov.io/bash)
  fi

If you rely on certain nightly features you may need to change the before_script to before_cache to force tarpaulin to reinstall each time. However, if it can be avoided it will speed up your CI runs.

Alternatively, there are the prebuilt docker images or the travis-install shell script. The travis-install script will install the latest tagged release built on travis to your travis instance and significantly speeds up the travis builds. You can install via that script using bash <(curl https://raw.githubusercontent.com/xd009642/tarpaulin/master/travis-install.sh).

The prebuilt binary is built using github actions ubuntu:latest image, because of this it doesn't work on xenial or trusty, but it works on bionic. You should still keep the rest of the recommended travis settings.

GitHub Actions

File .github/workflows/coverage.yml Example how to run coverage within docker with seccomp in GitHub Actions and push the result to <codecov.io>.

name:                           coverage

on:                             [push]
jobs:
  test:
    name:                       coverage
    runs-on:                    ubuntu-latest
    container:
      image:                    xd009642/tarpaulin:develop-nightly
      options:                  --security-opt seccomp=unconfined
    steps:
      - name:                   Checkout repository
        uses:                   actions/checkout@v2

      - name:                   Generate code coverage
        run: |
          cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml

      - name:                   Upload to codecov.io
        uses:                   codecov/codecov-action@v2
        with:
          # token:                ${{secrets.CODECOV_TOKEN}} # not required for public repos
          fail_ci_if_error:     true

CircleCI

To run tarpaulin on CircleCI you need to run tarpaulin in docker and set the machine flag to true as shown below:

jobs:
  coverage:
    machine: true
    steps:
      - checkout
      - run:
          name: Coverage with docker
          command: docker run --security-opt seccomp=unconfined -v "${PWD}:/volume" xd009642/tarpaulin

Gitlab Pipelines

To get the coverage results showing up in your Gitlab pipelines add the following regex to the Test coverage parsing section in the CI/CD settings.

^\d+.\d+% coverage

Or add the regex to the job definition in .gitlab-ci.yml:

job: ...
  coverage: '/^\d+.\d+% coverage/'

Gitlab can show coverage information in the diff of a merge request. For that, use

job: ...
  artifacts:
    reports:
      cobertura:
        - cobertura.xml

and generate a cobertura.xml as described under Pycobertura.

For installation add cargo install cargo-tarpaulin -f to the script section.

Docker

Tarpaulin has builds deployed to docker-hub, to run Tarpaulin on any system that has Docker, run this in your project directory:

docker run --security-opt seccomp=unconfined -v "${PWD}:/volume" xd009642/tarpaulin

This builds your project inside Docker and runs Tarpaulin without any arguments. There are also tags available for the latest version on the develop branch in stable or nightly. And versions after 0.5.6 will have the latest release built with the rust stable and nightly compilers. To get the latest development version built with rustc-nightly run the following:

docker run --security-opt seccomp=unconfined -v "${PWD}:/volume" xd009642/tarpaulin:develop-nightly

Note that the build might fail if the Docker image doesn't contain any necessary dependencies. In that case, you can install dependencies before, like this:

docker run --security-opt seccomp=unconfined -v "${PWD}:/volume" xd009642/tarpaulin sh -c "apt-get install xxx && cargo tarpaulin"

Config file

Tarpaulin has a config file setting where multiple coverage setups can be encoded in a toml file. This can be provided by an argument or if a .tarpaulin.toml or tarpaulin.toml is present in the same directory as the projects manifest or in the root directory that will be used unless --ignore-config is passed. Below is an example file:

[feature_a_coverage]
features = "feature_a"

[feature_a_and_b_coverage]
features = "feature_a feature_b"
release = true

[report]
coveralls = "coveralls_key"
out = ["Html", "Xml"]

Here we'd create three configurations, one would run your tests with feature_a enabled, and the other with the tests built in release and both feature_a and feature_b enabled. The last configuration uses a reserved configuration name report and this doesn't result in a coverage run but affects the report output. This is a reserved feature name and any non-reporting based options chosen will have no effect on the output of tarpaulin.

For reference on available keys and their types refer to the CLI help text at the start of the readme or src/config/mod.rs for the concrete types if anything is unclear. For arguments to be passed into the test binary that follow -- in tarpaulin use args in the toml file.

Setting the field config will have no effect on the run as it won't be parsed for additional configuration.

For the flags --lib, --examples, --benches, --tests, --all-targets, --doc, --bins use the run-types entry in the config file.

Extending Tarpaulin

There are some tools available which can extend tarpaulin functionality for other potential user needs.

Procedural Macros

Normally, Tarpaulin can't report on code coverage within the code for a procedural macro. You'll need to add a test that expands the macro at run-time in order to get those stats. The runtime-macros crate was made for this purpose, and its documentation describes how to use it with Tarpaulin.

Pycobertura

pycobertura is a python library for working with cobertura reports. It offers a report diffing tool as well as its own report implementations.

To generate a cobertura.xml simply run the following tarpaulin command:

cargo tarpaulin --out Xml

Then install pycobertura with pip and execute the desired command.

As tarpaulin doesn't allow you to change the name of the generated cobertura report be mindful of this if diffing reports between multiple commits.

Issues and Contributing

Issues, feature requests and pull requests are always welcome! For a guide on how to approach bugs found in Tarpaulin and adding features please check CONTRIBUTING.

Rust 1.23 introduced a regression in the compiler affecting tarpaulin's accuracy. If you see missing lines or files, check your compiler version.

Roadmap

  • Branch coverage for tests
  • Condition coverage for tests
  • MCDC coverage reports
  • LLVM coverage support
  • Support for embedded targets
  • OSX support
  • Windows support

License

Tarpaulin is currently licensed under the terms of both the MIT license and the Apache License (Version 2.0). See LICENSE-MIT and LICENSE-APACHE for more details.

Comments
  • Instrumentation address clash errors and segfaults

    Instrumentation address clash errors and segfaults

    as seen in failing builds https://circleci.com/gh/holochain/holochain-rust/1514

    using 0.6.11 and nightly-2018-12-26

    i've tried various flags passed to tarpaulin, but builds always seem to fail with this error

    also seeing Error a segfault occured when executing test

    potentially related https://github.com/xd009642/tarpaulin/issues/35 as we are using threads

    bug Instrumentation 
    opened by thedavidmeister 83
  • link error with undefined reference to `main' on Arch

    link error with undefined reference to `main' on Arch

    I tried running an internal project through tarpaulin today and it appears to fail in the link stage. I'm not really sure what's going on here, but it does work inside an ubuntu xenial docker container on the same project (running docker in --privileged mode to work around ASLR errors from lacking EPERM), so I'm guessing it's something to do with gcc7.

    Here is the output after all the Compiling lines:

       Compiling indicatif v0.3.3
    error: linking with `cc` failed: exit code: 1
      |
      = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/clux/sqbu/lal/target/debug/deps/serde_derive-0c82b8e5158c5e10.0.o" "-o" "/home/clux/sqbu/lal/target/debug/deps/libserde_derive-0c82b8e5158c5e10.so" "/home/clux/sqbu/lal/target/debug/deps/serde_derive-0c82b8e5158c5e10.crate.metadata.o" "-nodefaultlibs" "-L" "/home/clux/sqbu/lal/target/debug/deps" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/clux/sqbu/lal/target/debug/deps/libserde_codegen_internals-d56dd4dc3a22cef8.rlib" "/home/clux/sqbu/lal/target/debug/deps/libsyn-593a087ca2571565.rlib" "/home/clux/sqbu/lal/target/debug/deps/libsynom-1fddc0802262e2b9.rlib" "/home/clux/sqbu/lal/target/debug/deps/libquote-565e17019bbf404d.rlib" "/home/clux/sqbu/lal/target/debug/deps/libunicode_xid-0718538d6479f922.rlib" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-l" "proc_macro-21659b2d231fd6e3" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax-93b867817c21b413" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_data_structures-7c7ac4ebfcbb1807" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "rustc_errors-8975c93dcf60bb3d" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "syntax_pos-364f7f3b054e6796" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "serialize-204d1e77b99bcb91" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "term-4959b4e709084e0a" "-L" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "std-35ad9950c7e5074b" "-Wl,-Bstatic" "/home/clux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-863b57a66ba6c3e1.rlib" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-shared" "-no-pie"
      = note: /usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../lib/crt1.o: In function `_start':
              (.text+0x20): undefined reference to `main'
              collect2: error: ld returned 1 exit status
              
    
    error: aborting due to previous error(s)
    
    error: Could not compile `serde_derive`.
    Build failed, waiting for other jobs to finish...
    

    system:

    $ uname -a
    Linux kjttks 4.12.3-1-ARCH #1 SMP PREEMPT Sat Jul 22 15:32:02 UTC 2017 x86_64 GNU/Linux
    $ rustc --version
    rustc 1.19.0 (0ade33941 2017-07-17)
    $ cargo tarpaulin --version
    cargo-tarpaulin version: 0.3.9
    $ cc -Q -v
    Using built-in specs.
    COLLECT_GCC=cc
    COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/lto-wrapper
    Target: x86_64-pc-linux-gnu
    Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp
    Thread model: posix
    gcc version 7.1.1 20170630 (GCC) 
    
    bug compiler or linker bug 
    opened by clux 52
  • Tarpaulin fails to do coverage test on proc-macro repos

    Tarpaulin fails to do coverage test on proc-macro repos

    I am not sure what to look or how to debug the issue but the error message is

    ERROR: failed to read cargo metadata: EOF while parsing a value at line 1 column 0
    

    It only appears in proc-macro repos.

    Travis CI log for failing job with tarpaulin: https://travis-ci.org/Rair-Project/rair-core/jobs/638586153 Travis CI log for same job passing tests without tarpaulin https://travis-ci.org/Rair-Project/rair-core/builds/638586152

    bug 
    opened by oddcoder 48
  • OSX support tracking issue

    OSX support tracking issue

    This is a tracking issue for OSX support on tarpaulin

    • [x] Figure out why my OSX tests don't have the __debug_info section
    • [x] Update nix and libc to add ptrace support
    • [x] Update tarpaulin to use updated nix
    • [x] Fix other compile issues
    • [x] Refactor ASLR disabling in OSX (not done via personality ffi call)
      • [ ] Figure out if this has worked (GDB uses same method so it should)
    • [ ] Look into the IPC ports that are used to send things like termination signals. They are necessary - ptrace on mac isn't fit for purpose
    • [x] Investigate and update PTRACE_EVENT based code. OSX doesn't support PTRACE_EVENT
      • I've stuck in ptrace event currently but returns -1 so probably doing nothing
    • [x] Look at how poke/peek differs with the user struct in OSX vs linux and update code if needed
    • [ ] General tidy up and refactor
    • [ ] Tracing working on ARM (for future apple devices)

    Resources/links

    • Abusing Mach on Mac OS X - http://www.uninformed.org/?v=4&a=3&t=pdf

    2018/12/05 - gets into initialising the breakpoints to track coverage but none are ever hit and no exit signal.

    Original issue text

    localhost:src b$ rustc --version rustc 1.30.0-nightly (721913067 2018-08-26)

    localhost:src b$ RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin Updating registry https://github.com/rust-lang/crates.io-index Installing cargo-tarpaulin v0.6.7 Compiling serde v1.0.78 Compiling semver-parser v0.7.0 Compiling proc-macro2 v0.4.19 Compiling version_check v0.1.4 Compiling pkg-config v0.3.14 Compiling cc v1.0.24 Compiling unicode-xid v0.1.0 Compiling num-traits v0.2.5 Compiling void v1.0.2 Compiling build_const v0.2.1 Compiling matches v0.1.8 Compiling libc v0.2.43 Compiling stable_deref_trait v1.1.1 Compiling rand_core v0.2.1 Compiling scopeguard v0.3.3 Compiling ryu v0.2.6 Compiling unicode-normalization v0.1.7 Compiling failure_derive v0.1.2 Compiling ucd-util v0.1.1 Compiling regex v1.0.5 Compiling nodrop v0.1.12 Compiling memoffset v0.2.1 Compiling percent-encoding v1.0.1 Compiling utf8-ranges v1.0.1 Compiling core-foundation-sys v0.6.1 Compiling crossbeam-utils v0.5.0 Compiling rustc-demangle v0.1.9 Compiling cfg-if v0.1.5 Compiling itoa v0.4.3 Compiling unicode-width v0.1.5 Compiling fnv v1.0.6 Compiling bitflags v1.0.4 Compiling quick-error v1.2.2 Compiling same-file v1.0.3 Compiling byteorder v1.2.6 Compiling adler32 v1.0.3 Compiling nix v0.11.0 Compiling strsim v0.7.0 Compiling termcolor v1.0.3 Compiling remove_dir_all v0.5.1 Compiling hex v0.3.2 Compiling vec_map v0.8.1 Compiling plain v0.2.3 Compiling ansi_term v0.11.0 Compiling glob v0.2.11 Compiling md5 v0.3.8 Compiling termcolor v0.3.6 Compiling shell-escape v0.1.4 Compiling fallible-iterator v0.1.5 Compiling lazycell v0.6.0 Compiling crossbeam v0.3.2 Compiling home v0.3.3 Compiling unreachable v1.0.0 Compiling unicode-bidi v0.3.4 Compiling crc v1.8.1 Compiling owning_ref v0.3.3 Compiling lazy_static v1.1.0 Compiling rand v0.5.5 Compiling memchr v2.0.2 Compiling commoncrypto-sys v0.2.0 Compiling atty v0.2.11 Compiling fs2 v0.4.3 Compiling num_cpus v1.8.0 Compiling memmap v0.6.2 Compiling arrayvec v0.4.7 Compiling regex-syntax v0.6.2 Compiling socket2 v0.3.8 Compiling log v0.4.5 Compiling filetime v0.2.1 Compiling encoding_rs v0.8.6 Compiling uuid v0.6.5 Compiling textwrap v0.10.0 Compiling humantime v1.1.1 Compiling walkdir v2.2.5 Compiling parity-wasm v0.31.3 Compiling backtrace v0.3.9 Compiling smallvec v0.6.5 Compiling cmake v0.1.33 Compiling libz-sys v1.0.20 Compiling openssl-sys v0.9.35 Compiling curl-sys v0.4.8 Compiling miniz-sys v0.1.10 Compiling lock_api v0.1.3 Compiling aho-corasick v0.6.8 Compiling commoncrypto v0.2.0 Compiling gimli v0.16.1 Compiling jobserver v0.1.11 Compiling tar v0.4.16 Compiling clap v2.32.0 Compiling tempfile v3.0.3 Compiling libssh2-sys v0.2.10 Compiling libgit2-sys v0.7.7 Compiling num-traits v0.1.43 Compiling quote v0.6.8 Compiling crypto-hash v0.3.1 Compiling core-foundation v0.6.1 Compiling thread_local v0.3.6 Compiling crossbeam-epoch v0.6.0 Compiling enum_primitive v0.1.1 Compiling semver v0.9.0 Compiling serde_json v1.0.27 Compiling toml v0.4.6 Compiling serde_ignored v0.0.4 Compiling syn v0.14.9 Compiling syn v0.15.3 Compiling gzip-header v0.1.2 Compiling flate2 v1.0.2 Compiling curl v0.4.14 Compiling rustc_version v0.2.3 Compiling idna v0.1.5 Compiling deflate v0.7.18 Compiling parking_lot_core v0.3.1 Compiling url v1.7.1 Compiling synstructure v0.9.0 Compiling scroll_derive v0.9.4 Compiling parking_lot v0.6.4 Compiling globset v0.4.2 Compiling env_logger v0.5.13 Compiling serde_derive v1.0.78 Compiling crossbeam-channel v0.2.5 Compiling scroll v0.9.0 Compiling goblin v0.0.17 Compiling ignore v0.4.4 Compiling git2 v0.7.5 Compiling failure v0.1.2 Compiling quick-xml v0.12.3 Compiling git2-curl v0.8.1 Compiling object v0.10.0 Compiling crates-io v0.17.0 Compiling coveralls-api v0.3.3 Compiling cargo v0.29.0 Compiling cargo-tarpaulin v0.6.7 error[E0432]: unresolved import nix::sys::ptrace --> src/ptrace_control.rs:3:15 | 3 | use nix::sys::ptrace::*; | ^^^^^^ Could not find ptrace in sys

    error[E0408]: variable PTRACE_EVENT_FORK is not bound in all patterns --> src/statemachine.rs:356:37 | 356 | PTRACE_EVENT_FORK | PTRACE_EVENT_VFORK => { | ----------------- ^^^^^^^^^^^^^^^^^^ pattern doesn't bind PTRACE_EVENT_FORK | | | variable not in all patterns

    error[E0408]: variable PTRACE_EVENT_VFORK is not bound in all patterns --> src/statemachine.rs:356:17 | 356 | PTRACE_EVENT_FORK | PTRACE_EVENT_VFORK => { | ^^^^^^^^^^^^^^^^^ ------------------ variable not in all patterns | | | pattern doesn't bind PTRACE_EVENT_VFORK

    error[E0433]: failed to resolve. Use of undeclared type or module Options --> src/ptrace_control.rs:13:28 | 13 | let options: Options = Options::PTRACE_O_TRACESYSGOOD | | ^^^^^^^ Use of undeclared type or module Options

    error[E0433]: failed to resolve. Use of undeclared type or module Options --> src/ptrace_control.rs:14:9 | 14 | Options::PTRACE_O_TRACEEXEC | Options::PTRACE_O_TRACEEXIT | | ^^^^^^^ Use of undeclared type or module Options

    error[E0433]: failed to resolve. Use of undeclared type or module Options --> src/ptrace_control.rs:14:39 | 14 | Options::PTRACE_O_TRACEEXEC | Options::PTRACE_O_TRACEEXIT | | ^^^^^^^ Use of undeclared type or module Options

    error[E0433]: failed to resolve. Use of undeclared type or module Options --> src/ptrace_control.rs:15:9 | 15 | Options::PTRACE_O_TRACECLONE | Options::PTRACE_O_TRACEFORK | | ^^^^^^^ Use of undeclared type or module Options

    error[E0433]: failed to resolve. Use of undeclared type or module Options --> src/ptrace_control.rs:15:40 | 15 | Options::PTRACE_O_TRACECLONE | Options::PTRACE_O_TRACEFORK | | ^^^^^^^ Use of undeclared type or module Options

    error[E0433]: failed to resolve. Use of undeclared type or module Options --> src/ptrace_control.rs:16:9 | 16 | Options::PTRACE_O_TRACEVFORK; | ^^^^^^^ Use of undeclared type or module Options

    error[E0433]: failed to resolve. Use of undeclared type or module Request --> src/ptrace_control.rs:31:16 | 31 | ptrace(Request::PTRACE_SINGLESTEP, pid, ptr::null_mut(), ptr::null_mut()) | ^^^^^^^ Use of undeclared type or module Request

    error[E0433]: failed to resolve. Use of undeclared type or module Request --> src/ptrace_control.rs:38:16 | 38 | ptrace(Request::PTRACE_PEEKDATA, pid, address as * mut c_void, ptr::null_mut()) | ^^^^^^^ Use of undeclared type or module Request

    error[E0433]: failed to resolve. Use of undeclared type or module Request --> src/ptrace_control.rs:47:16 | 47 | ptrace(Request::PTRACE_POKEDATA, pid, address as * mut c_void, data as * mut c_void) | ^^^^^^^ Use of undeclared type or module Request

    error[E0433]: failed to resolve. Use of undeclared type or module Request --> src/ptrace_control.rs:54:16 | 54 | ptrace(Request::PTRACE_PEEKUSER, pid, RIP as * mut c_void, ptr::null_mut()) | ^^^^^^^ Use of undeclared type or module Request

    error[E0433]: failed to resolve. Use of undeclared type or module Request --> src/ptrace_control.rs:61:16 | 61 | ptrace(Request::PTRACE_POKEUSER, pid, RIP as * mut c_void, pc as * mut c_void) | ^^^^^^^ Use of undeclared type or module Request

    error[E0412]: cannot find type Persona in this scope --> src/personality.rs:12:26 | 12 | const ADDR_NO_RANDOMIZE: Persona = 0x004_0000; | ^^^^^^^ not found in this scope

    error[E0412]: cannot find type Persona in this scope --> src/personality.rs:13:20 | 13 | const GET_PERSONA: Persona = 0xFFFF_FFFF; | ^^^^^^^ not found in this scope

    error[E0412]: cannot find type Persona in this scope --> src/personality.rs:24:25 | 24 | fn personality(persona: Persona) -> Result<c_int> { | ^^^^^^^ not found in this scope

    error[E0412]: cannot find type Options in this scope --> src/ptrace_control.rs:13:18 | 13 | let options: Options = Options::PTRACE_O_TRACESYSGOOD | | ^^^^^^^ did you mean Option?

    error[E0425]: cannot find function setoptions in this scope --> src/ptrace_control.rs:17:5 | 17 | setoptions(pid, options) | ^^^^^^^^^^ did you mean options?

    error[E0425]: cannot find function detach in this scope --> src/ptrace_control.rs:21:5 | 21 | detach(pid) | ^^^^^^ not found in this scope

    error[E0425]: cannot find function cont in this scope --> src/ptrace_control.rs:25:5 | 25 | cont(pid, sig) | ^^^^ not found in this scope

    error[E0425]: cannot find function ptrace in this scope --> src/ptrace_control.rs:31:9 | 31 | ptrace(Request::PTRACE_SINGLESTEP, pid, ptr::null_mut(), ptr::null_mut()) | ^^^^^^ not found in this scope help: possible candidate is found in another module, you can import it into scope | 1 | use nix::libc::ptrace; |

    error[E0425]: cannot find function ptrace in this scope --> src/ptrace_control.rs:38:9 | 38 | ptrace(Request::PTRACE_PEEKDATA, pid, address as * mut c_void, ptr::null_mut()) | ^^^^^^ not found in this scope help: possible candidate is found in another module, you can import it into scope | 1 | use nix::libc::ptrace; |

    error[E0425]: cannot find function ptrace in this scope --> src/ptrace_control.rs:47:9 | 47 | ptrace(Request::PTRACE_POKEDATA, pid, address as * mut c_void, data as * mut c_void) | ^^^^^^ not found in this scope help: possible candidate is found in another module, you can import it into scope | 1 | use nix::libc::ptrace; |

    error[E0425]: cannot find function ptrace in this scope --> src/ptrace_control.rs:54:9 | 54 | ptrace(Request::PTRACE_PEEKUSER, pid, RIP as * mut c_void, ptr::null_mut()) | ^^^^^^ not found in this scope help: possible candidate is found in another module, you can import it into scope | 1 | use nix::libc::ptrace; |

    error[E0425]: cannot find function ptrace in this scope --> src/ptrace_control.rs:61:9 | 61 | ptrace(Request::PTRACE_POKEUSER, pid, RIP as * mut c_void, pc as * mut c_void) | ^^^^^^ not found in this scope help: possible candidate is found in another module, you can import it into scope | 1 | use nix::libc::ptrace; |

    error[E0425]: cannot find function traceme in this scope --> src/ptrace_control.rs:66:5 | 66 | traceme() | ^^^^^^^ not found in this scope

    error[E0425]: cannot find function getevent in this scope --> src/ptrace_control.rs:70:5 | 70 | getevent(pid) | ^^^^^^^^ not found in this scope

    error[E0599]: no associated item named __WALL found for type nix::sys::wait::WaitPidFlag in the current scope --> src/statemachine.rs:231:75 | 231 | let wait = waitpid(Pid::from_raw(-1), Some(WaitPidFlag::WNOHANG | WaitPidFlag::__WALL)); | ^^^^^^^^^^^^^^^^^^^ associated item not found in nix::sys::wait::WaitPidFlag

    error[E0599]: no variant named PtraceEvent found for type nix::sys::wait::WaitStatus in the current scope --> src/statemachine.rs:251:13 | 251 | WaitStatus::PtraceEvent(c,s,e) => { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variant not found in nix::sys::wait::WaitStatus

    error: aborting due to 30 previous errors

    Some errors occurred: E0408, E0412, E0425, E0432, E0433, E0599. For more information about an error, try rustc --explain E0408. error: failed to compile cargo-tarpaulin v0.6.7, intermediate artifacts can be found at /var/folders/26/ghqp1zl50yq3bp47zljpksk80000gn/T/cargo-install5pqpq9

    Caused by: Could not compile cargo-tarpaulin.

    To learn more, run the command again with --verbose.

    enhancement tracking-issue BIG-TASK 
    opened by dataf3l 40
  • Tarpaulin fails with  `Error: cannot find attribute 'skip' in this scope

    Tarpaulin fails with `Error: cannot find attribute 'skip' in this scope"` with rust 1.52.0 even if skip isn't used

    Describe the bug

    When trying to run tarpaulin in our project with rust v1.52.0 it fails with the error:

    error: Broken pipe (os error 32)
    warning: build failed, waiting for other jobs to finish...
    error: Broken pipe (os error 32)
    error: build failed
    May 07 11:14:50.974 ERROR cargo_tarpaulin: Failed to compile tests! Error: cannot find attribute `skip` in this scope
    Error: "Failed to compile tests! Error: cannot find attribute `skip` in this scope"
    

    tarpaulin works with rust 1.51.0 and we do not use the skip attribute in the codebase

    To Reproduce

    clone https://github.com/tremor-rs/tremor-runtime and update the rust-toolchain file to 1.52.0

    Expected behavior

    projects working in 1.51.0 also work in 1.52.0

    opened by Licenser 32
  • Doctests aren't taken into account

    Doctests aren't taken into account

    I saw you had doc tests on the roadmap which is something I could really use in combine as a they should handle most of the coverage (https://coveralls.io/builds/12513027/source?filename=src%2Fbyte.rs#L47).

    Opening this issue to inquire/track when this would be implemented.

    enhancement hacktoberfest 
    opened by Marwes 29
  • Inconsistent segfault error (non-deterministic)

    Inconsistent segfault error (non-deterministic)

    On a project I'm working on, I have this inconsistent error

    [ERROR tarpaulin] Failed to get test coverage! Error: Failed to run tests: A segfault occurred while executing tests
    Error: "Failed to get test coverage! Error: Failed to run tests: A segfault occurred while executing tests"
    ##[error]The process '/usr/share/rust/.cargo/bin/cargo' failed with exit code 1
    

    I say inconsistent because it never happens at the same time of the process. I've been able to reproduce locally at some point but then, launching the same cargo tarpaulin command over and over, it eventually works. Funnier, it seems that once it works, it always works (I even was able to do a cargo clean and make it work). So the error never happen consistently.

    I'm working on Ubuntu 20.04 with the following (but this error also happened on our CI https://github.com/CanalTP/transit_model/pull/558/checks?check_run_id=716136628)

    $> rustup --version
    rustup 1.21.1 (7832b2ebe 2019-12-20)
    $> cargo --version
    cargo 1.43.0 (2cbe9048e 2020-05-03)
    $> rustc --version
    rustc 1.43.1 (8d69840ab 2020-05-04)
    $> cargo tarpaulin --version
    cargo-tarpaulin version: 0.13.2
    

    I looked for similar issues but didn't feel like the problem was the same. Sorry if this is a duplicate.

    opened by woshilapin 26
  • tarpaulin skip no longer working since 0.13.4

    tarpaulin skip no longer working since 0.13.4

    See: https://github.com/wayfair-tremor/tremor-runtime/pull/321/checks?check_run_id=803402444

    This is seems to be a regression since 0.13.3

       Compiling value-trait v0.1.10
    error: could not compile `value-trait`.
    
    To learn more, run the command again with --verbose.
    warning: build failed, waiting for other jobs to finish...
    error: build failed
    [ERROR tarpaulin] Failed to compile tests! Error: cannot find attribute `skip` in this scope
    Error: "Failed to compile tests! Error: cannot find attribute `skip` in this scope"
    ##[error]The process '/usr/share/rust/.cargo/bin/cargo' failed with exit code 1
    
    opened by Licenser 25
  • bug: tests fail when running cargo tarpaulin with recent nightly toolchain

    bug: tests fail when running cargo tarpaulin with recent nightly toolchain

    Describe the bug We have been using tarpaulin for our project for quite some time.

    We haven't had any issues until now. We updated toolchain to more recent one -> nightly-2021-11-08.

    And using tarpaulin to generate code coverage, our tests started failing. The tests produce different results than expected.

    However, running just the tests without tarpaulin is fine and results are correct.

    Note using any earlier toolchain than the one from 2021-11-08 is fine (eg. 2021-11-07 is fine ).

    To Reproduce our project is quite complex, using even more complex Substrate framework.

    However to reproduce - it is fairly simple:

    1. Clone repository Basilisk-node
    2. There is rust-toolchain file - edit to change toolchain to one from 2021-11-08.
    3. Run make coverage ( takes quite some time ). Fails.
    4. Run make test. Tests pass.

    Expected behavior I'd expect tests not to fail considering they pass correctly without tarpaulin.

    Personally, I cannot tell yet what can cause this issue.

    I'll dig deeper to figure out what have the failing tests in common - it is not obvious from the first quick look.

    but I figured it would be good to let you know, as there might be something which you are already aware of.

    Version cargo tarpaulin --version cargo-tarpauin version: 0.18.5

    opened by enthusiastmartin 24
  • "Unexpected stop" when running with tarpaulin

    Not sure what's up here. When testing git-workarea using tarpaulin, I see it testing test_gitdir, saying "Unexpected stop" and then quitting. However, the binaries are still running (test test::test_gitdir has been running for over 60 seconds).

    bug 
    opened by mathstuf 24
  • fails on travis with ASLR disable failed: EPERM

    fails on travis with ASLR disable failed: EPERM

    0.42s$ bash <(curl https://raw.githubusercontent.com/xd009642/tarpaulin/master/travis-install.sh)
    cargo-tarpaulin
    after_success.2
    178.59s$ cargo tarpaulin --out Xml &&
        bash <(curl -s https://codecov.io/bash)
        
    Building project
    Launching test
    ASLR disable failed: EPERM: Operation not permitted
    thread 'main' panicked at 'Failed to trace: Sys(EPERM)', /checkout/src/libcore/result.rs:906:4
    note: Run with `RUST_BACKTRACE=1` for a backtrace.
    Unexpected grab
    Error while collecting coverage. EPERM: Operation not permitted
    Coverage Results
    #
    # Omitted 
    #
    0.00% coverage, 0/302 lines covered
    Tarpaulin finished
    

    Travis log: https://travis-ci.org/swc-project/swc/builds/328637807#L2967

    I use nightly

    opened by kdy1 20
  • `#[no_coverage]` is working but `#[cfg_attr(tarpaulin, no_coverage)]` not

    `#[no_coverage]` is working but `#[cfg_attr(tarpaulin, no_coverage)]` not

    Describe the bug

    I am conditionally add no_coverage attribute only if --cfg tarpaulin is set.

    #[cfg_attr(tarpaulin, no_coverage)]
    mod info;
    

    It's not working but putting just #[no_coverage] works as expected.

    To Reproduce

    1. Create function and add attribute #[cfg_attr(tarpaulin, no_coverage)].
    2. Run cargo tarpaulin.
    3. Check report - function is included in coverage lines.
    4. Change attribute into #[no_coverage].
    5. Run cargo tarpaulin.
    6. Check report - function is ignored as expected.

    Expected behavior

    Item should be ignored from coverage.

    Live example

    Check my ferric-bytes/chksum-build repo - specially code below.

    https://github.com/ferric-bytes/chksum-build/blob/299e286ddfea98edc0687d63c8959ce7e3ebd264/src/lib.rs#L178-L179

    Possible fix

    As far as I understand some extra checks should be added to this function.

    https://github.com/xd009642/tarpaulin/blob/343e912bf33a3872ff9f49d48686831d7ca701da/src/source_analysis/attributes.rs#L35-L73

    opened by ventaquil 0
  • cargo_tarpaulin: Error while parsing

    cargo_tarpaulin: Error while parsing

    Cargo tarpaulin: 0.22.0 Rust: 1.65.0 OS: ubuntu0.20.04.1

    Describe the bug For some reason the command fails on my build runner while it works on my local Mac OS machine. The test relies on a certain environment config and I ensured that the file is in place. As it seems it does not start executing any tests.

    Run RUN_MODE=emea-test-local cargo tarpaulin --release --out Lcov --timeout 600
    Dec 07 15:41:08.003 INFO cargo_tarpaulin::config: Creating config
    Dec 07 15:41:08.626 INFO cargo_tarpaulin: Running Tarpaulin
    Dec 07 15:41:08.626 INFO cargo_tarpaulin: Building project
    Dec 07 15:41:08.626 INFO cargo_tarpaulin::cargo: Cleaning project
       Compiling autocfg v1.1.0
       ...
        Finished release [optimized] target(s) in 1m 56s
    Dec 07 15:43:05.753ERROR cargo_tarpaulin: Error while parsing
    Error: "Error while parsing"
    

    To Reproduce These are my dependencies.

    [dependencies]
    axum = "0.6.1"
    axum-extra = { version = "0.4.0", features = ["spa"] }
    axum-sessions = "0.4.0"
    chrono = { version = "0.4.21", features = ["serde"] }
    config = { version = "0.13.1", features = ["yaml"], default-features = false }
    dashmap = "5.3.4"
    eyre = "0.6.8"
    futures = "0.3.23"
    futures-util = "0.3.23"
    http-auth-basic = "0.3.3"
    hyper = { version = "0.14.20", features = ["full"] }
    hyper-tls = "0.5.0"
    ldap3 = { version = "0.10.5", default-features = false, features = ["tls"] }
    openidconnect = "2.3.2"
    rand = { version= "0.8.5", features = ["min_const_gen"] }
    regex = "1.6.0"
    serde = { version = "1.0.138", features = ["derive"] }
    serde_json = "1.0.83"
    sqlx = { version = "0.6.0", features = [ "runtime-async-std-native-tls", "postgres", "macros", "chrono", "json" ], default-features = false }
    strum = "0.24"
    strum_macros = "0.24"
    tokio = { version = "1.0", features = ["full"] }
    tokio-tls = "0.3.1"
    tower = "0.4.13"
    tower-http = { version = "0.3.0", features = ["fs", "trace", "add-extension", "auth"], default-features = false }
    tracing = "0.1"
    tracing-subscriber = { version = "0.3", features = ["env-filter"] }
    url = "2.3.1"
    

    Expected behavior Successfull run.

    opened by lcmgh 0
  • No coverage for cdylib crate called from C/C++ executables

    No coverage for cdylib crate called from C/C++ executables

    Describe the bug

    I have a project (https://github.com/Luthaf/rascaline/, coverage branch, PR with CI is https://github.com/Luthaf/rascaline/pull/126) which is built as both a rust crate (tarpaulin works great here, thanks a lot!) and exports a C API through a cdylib crate (rascaline-c-api). The C API is then used to create a C++ (and Python) interface for the code.

    The C and C++ API are tested as a normal C/C++ project, using CMake to first build the rust code, and then build C and C++ test executables. I made sure to pass the right flags to rustc (setting RUSTFLAGS="-Cdebuginfo=2 --cfg=tarpaulin -Cinstrument-coverage -Clink-dead-code") when building the rust shared library.

    The LLVM-based coverage instrumentation seems to work fine, generating .profraw files (I added a small patch in https://github.com/Luthaf/tarpaulin/commit/c67eb17884510e06fe7fca0ce61fc15805367537 since the profraw files are generated inside a different directory), but then no coverage is reported for the c-api crate at all. I added a handful of dbg! inside cargo-tarpaulin and llvm-profparser, and as far as I understand the code it seems that the profraw files contain at least some coverage data.

    To Reproduce

    git clone https://github.com/Luthaf/rascaline
    cd rascaline 
    git checkout coverage
    cargo tarpaulin --all-features --workspace --engine=llvm --test=c-api-tests --skip-clean --verbose
    

    Here is the output I get: tarpaulin-rascaline.txt

    I'm wondering if there could be an issue with file name parsing or something like this, since all the path shown are relative to the rascaline-c-api crate, and not the root of the repository/root of the cargo workspace.

    If you have a couple of pointer/thinks I could look for, I'm happy to continue debugging this and send a PR once it is fixed.

    Expected behavior

    Using an instrumented shared library from C or C++ should be able to collect and report coverage on the C API implementation in rust.

    opened by Luthaf 2
  • `--follow-exec` gives Instrumentation address clash and segfault

    `--follow-exec` gives Instrumentation address clash and segfault

    I have a test binary that starts the main binary and tests its APIs. When I run tarpaulin with --follow-exec as follows

    cargo tarpaulin --follow-exec --out Xml  --profile coverage --bin tests-bin --verbose
    

    I get a segfault and the verbose output shows the following message

    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x104eb5a
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x104c927
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x104f9d4
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x105103f
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x104c554
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x104c611
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x104c7f2
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x104febf
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x104d914
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x104fcda
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x104ca3f
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x1050df2
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x1050e5a
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x1051f14
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x104ed3f
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x10521bf
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x104fa91
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x1050c11
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x1051cd4
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x1051f72
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x10520a7
    Dec 02 13:05:15.538 DEBUG cargo_tarpaulin::statemachine::linux: Instrumentation address clash, ignoring 0x104ec27
    
    opened by mokhaled2992 0
  • [Windows] Tarpaulin creates lcov.info in the wrong folder

    [Windows] Tarpaulin creates lcov.info in the wrong folder

    Describe the bug

    When tarpaulin writes lcov.info it gets the wrong current directory. It writes the file into an subfolder instead of the root folder. Specifying --root or --output-dir did not help.

    To Reproduce

    Project structure: challenge-rust

    root/Cargo.toml
    root/explore_dungeon
    root/find_unique_interval
    root/level_buildings
    root/start_chain_reaction
    root/src
    
    • Action: Run cargo tarpaulin --ignore-tests --out Lcov --all

      • Want: root/lcov.info
      • Actual: root/find_unique_interval/lcov.info
    • Action: Run cargo tarpaulin --ignore-tests --out Lcov --all --root .

      • Want: root/lcov.info
      • Actual: root/find_unique_interval/lcov.info
    • Action: Run cargo tarpaulin --ignore-tests --out Lcov --all --output-dir target\tarpaulin

      • Want: root/target/tarpaulin/lcov.info
      • Actual: root/find_unique_interval/target/tarpaulin/lcov.info

    Workaround :link:

    • Force tarpaulin to read the current directory during configuration stage
    • Use the root directory in lcov.rs for a relative path
    • Combine it with output_dir
    • Use --output-dir target\tarpaulin to aovid an empty out_dir because it will try to get the current directory if empty
    • Working Example: cargo tarpaulin --ignore-tests --out Lcov --all --output-dir target\tarpaulin
    • Still Failing Example: Run cargo tarpaulin --ignore-tests --out Lcov --all
      • Want: root/lcov.info
      • Actual: root/find_unique_interval//lcov.info

    Software versions

    • rustc 1.64.0 (a55dd71d5 2022-09-19)
    • cargo 1.64.0 (387270bc7 2022-09-16)
    • cargo-tarpaulin version: 0.23.1
    • Windows 10: 21H2 (Build 19044.2251)
    • VS Code: 1.73.1
    • Coverage Gutters v2.10.2
    opened by dkudlek 0
Releases(0.22.0)
Owner
Software engineer interested in C++, Rust, computer vision and machine intelligence. He/Him.
null
Minimal virus genome coverage assessment for metagenomic diagnostics

vircov Minimal virus genome coverage assessment for metagenomic diagnostics Overview v0.5.0 Purpose Implementation Installation Usage Tests Concept Cl

Eike Steinig 14 Oct 17, 2022
Common utilities code used across Fulcrum Genomics Rust projects

fgoxide Common utilities code used across Fulcrum Genomics Rust projects. Why? There are many helper functions that are used repeatedly across project

Fulcrum Genomics 2 Nov 2, 2022
Removes generated and downloaded files from code projects to free up space

makeclean Removes generated and downloaded files from code projects to free up space. Features: List, cleans and archives projects depending on how lo

Kevin Bader 2 Mar 11, 2022
A simple string interner / symbol table for Rust projects.

Symbol Interner A small Rust crate that provides a naïve string interner. Consult the documentation to learn about the types that are exposed. Install

Ryan Chandler 1 Nov 18, 2021
A bundler (mainly for TypeScript projects) made in Rust

TSAR A bundler (mainly for TypeScript projects) made in Rust. Also my first Rust Project! What does TSAR stand for Like phar (PHP Archive) or JAR (Jav

null 2 Mar 19, 2022
A group of Rust projects for interacting with and producing software bill of materials (SBOMs).

sbom-rs A group of Rust projects for interacting with and producing software bill of materials (SBOMs). Examples cargo-sbom Create a SPDX SBOM for a C

Paul Sastrasinh 2 Jul 10, 2023
Graceful shutdown util for Rust projects using the Tokio Async runtime.

Shutdown management for graceful shutdown of tokio applications. Guard creating and usage is lock-free and the crate only locks when: the shutdown sig

Plabayo 54 Sep 29, 2023
Framework is a detector for different frameworks in one projects

Framework is a detector for different frameworks in one projects Usage use

Inherd OS Team (硬核开源小组) 3 Oct 24, 2022
Bindings to the Tauri API for projects using wasm-bindgen

tauri-sys Raw bindings to the Tauri API for projects using wasm-bindgen Installation This crate is not yet published to crates.io, so you need to use

Jonas Kruckenberg 25 Jan 9, 2023
Experimental Rust tool for generating FFI definitions allowing many other languages to call Rust code

Diplomat is an experimental Rust tool for generating FFI definitions allowing many other languages to call Rust code. With Diplomat, you can simply define Rust APIs to be exposed over FFI and get high-level C, C++, and JavaScript bindings automatically!

null 255 Dec 30, 2022
A tool to run web applications on AWS Lambda without changing code.

AWS Lambda Adapter A tool to run web applications on AWS Lambda without changing code. How does it work? AWS Lambda Adapter supports AWS Lambda functi

AWS Samples 321 Jan 2, 2023
Migrate C code to Rust

C2Rust helps you migrate C99-compliant code to Rust. The translator (or transpiler) produces unsafe Rust code that closely mirrors the input C code. T

Immunant 3k Jan 8, 2023
Minimal, flexible framework for implementing solutions to Advent of Code in Rust

This is advent_of_code_traits, a minimal, flexible framework for implementing solutions to Advent of Code in Rust.

David 8 Apr 17, 2022
Simplified glue code generation for Deno FFI libraries written in Rust.

deno_bindgen This tool aims to simplify glue code generation for Deno FFI libraries written in Rust. Quickstart # install CLI deno install -Afq -n den

Divy Srivastava 173 Dec 17, 2022
Easy to use Rust i18n library based on code generation

rosetta-i18n rosetta-i18n is an easy-to-use and opinionated Rust internationalization (i18n) library powered by code generation. rosetta_i18n::include

null 38 Dec 18, 2022
A simple code boilerplate generator written in Rust.

?? Cgen What is Cgen? A modern, cross-platform, multi-language boilerplate generator aimed to make your code generation less hectic! If you wish to su

Rithul Kamesh 1 Dec 25, 2021
Rust macro that uses GPT3 codex to generate code at compiletime

gpt3_macro Rust macro that uses GPT3 codex to generate code at compiletime. Just describe what you want the function to do and (optionally) define a f

Maximilian von Gaisberg 59 Dec 18, 2022
Generate bindings to use Rust code in Qt and QML

Rust Qt Binding Generator This code generator gets you started quickly to use Rust code from Qt and QML. In other words, it helps to create a Qt based

KDE GitHub Mirror 768 Dec 24, 2022
A rollup plugin that compile Rust code into WebAssembly modules

rollup-plugin-rust tl;dr -- see examples This is a rollup plugin that loads Rust code so it can be interop with Javascript base project. Currently, th

Fahmi Akbar Wildana 37 Aug 1, 2022