GithubHelp home page GithubHelp logo

jason-cooke / grcov Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mozilla/grcov

1.0 1.0 0.0 2.86 MB

Rust tool to collect and aggregate code coverage data for multiple source files

License: Mozilla Public License 2.0

Rust 97.49% C 0.75% C++ 0.57% CSS 1.19%

grcov's Introduction

grcov

Build Status Build status codecov

grcov collects and aggregates code coverage information for multiple source files.

This is a project initiated by Mozilla to gather code coverage results on Firefox.

Usage

  1. Download grcov from https://github.com/mozilla/grcov/releases or run cargo install grcov
  2. Run grcov:
USAGE:
    grcov [FLAGS] [OPTIONS] <paths>...

FLAGS:
        --branch                          Enables parsing branch coverage information
        --guess-directory-when-missing
    -h, --help                            Prints help information
        --ignore-not-existing             Ignore source files that can't be found on the disk
        --llvm                            Speeds-up parsing, when the code coverage information is exclusively coming
                                          from a llvm build
    -V, --version                         Prints version information

OPTIONS:
        --commit-sha <COMMIT HASH>                   Sets the hash of the commit used to generate the code coverage data
        --filter <filter>
            Filters out covered/uncovered files. Use 'covered' to only return covered files, 'uncovered' to only return
            uncovered files [possible values: covered, uncovered]
        --ignore <PATH>...                           Ignore files/directories specified as globs
        --log <LOG>
            Set the file where to log (or stderr or stdout). Defaults to 'stderr' [default: stderr]

    -o, --output-file <FILE>                         Specifies the output file
    -t, --output-type <OUTPUT TYPE>
            Sets a custom output type [default: lcov]  [possible values: ade, lcov, coveralls, coveralls+, files,
            covdir, html]
        --path-mapping <PATH>...
    -p, --prefix-dir <PATH>
            Specifies a prefix to remove from the paths (e.g. if grcov is run on a different machine than the one that
            generated the code coverage information)
        --service-job-number <SERVICE JOB NUMBER>    Sets the service job number
        --service-name <SERVICE NAME>                Sets the service name
        --service-number <SERVICE NUMBER>            Sets the service number
    -s, --source-dir <DIRECTORY>                     Specifies the root directory of the source files
        --threads <NUMBER>                            [default: 16]
        --token <TOKEN>
            Sets the repository token from Coveralls, required for the 'coveralls' and 'coveralls+' formats

        --vcs-branch <VCS BRANCH>
            Set the branch for coveralls report. Defaults to 'master' [default: master]


ARGS:
    <paths>...    Sets the input paths to use

Let's see a few examples, assuming the source directory is ~/Documents/mozilla-central and the build directory is ~/Documents/mozilla-central/build.

LCOV output

grcov ~/Documents/mozilla-central/build -t lcov > lcov.info

As the LCOV output is compatible with lcov, genhtml can be used to generate a HTML summary of the code coverage:

genhtml -o report/ --show-details --highlight --ignore-errors source --legend lcov.info

Coveralls/Codecov output

grcov ~/Documents/FD/mozilla-central/build -t coveralls -s ~/Documents/FD/mozilla-central --token YOUR_COVERALLS_TOKEN > coveralls.json

grcov with Travis

Here is an example of .travis.yml file

language: rust

before_install:
  - curl -L https://github.com/mozilla/grcov/releases/latest/download/grcov-linux-x86_64.tar.bz2 | tar jxf -

matrix:
  include:
    - os: linux
      rust: nightly

script:
    - export CARGO_INCREMENTAL=0
    - export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Zno-landing-pads"
    - cargo build --verbose $CARGO_OPTIONS
    - cargo test --verbose $CARGO_OPTIONS
    - |
      zip -0 ccov.zip `find . \( -name "YOUR_PROJECT_NAME*.gc*" \) -print`;
      ./grcov ccov.zip -s . -t lcov --llvm --branch --ignore-not-existing --ignore "/*" -o lcov.info;
      bash <(curl -s https://codecov.io/bash) -f lcov.info;

Auto-formatting

This project is using pre-commit. Please run pre-commit install to install the git pre-commit hooks on your clone. Instructions on how to install pre-commit can be found here.

Every time you will try to commit, pre-commit will run checks on your files to make sure they follow our style standards and they aren't affected by some simple issues. If the checks fail, pre-commit won't let you commit.

Build & Test

In order to build, either LLVM 7 or LLVM 8 libraries and headers are required. If one of these versions is sucessfully installed, build with:

cargo build

To run unit and integration tests:

cargo test

To run just unit tests:

cargo test --lib

Minimum requirements

  • GCC 4.9 or higher is required (if parsing coverage artifacts generated by GCC).

License

Published under the MPL 2.0 license.

grcov's People

Contributors

marco-c avatar calixteman avatar gabriel-v avatar sylvestre avatar dependabot-preview[bot] avatar crawfordleeds avatar rhcu avatar midsorbet avatar lucianamarques avatar nerdypepper avatar atul9 avatar jgraham avatar badboy avatar tafia avatar svensevenslow avatar mozilla-github-standards avatar sush0512 avatar tompridham avatar vsham20 avatar byi8220 avatar kenkoooo avatar rei2hu avatar rrooij avatar

Stargazers

Mohammed Hasanul Chowdhury avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.