Giter VIP home page Giter VIP logo

cover's Introduction

Documentation CircleCI codecov Go Report Card GitHub tag (latest SemVer)

cover

Go cover tool for maximum productivity.

It is similar to go tool cover -html=cover.out but not leaving the terminal. It was inspired by gocovsh but I wanted it to work a bit different.

The aim is to help me in writing tests spending as little attention and key presses as possible.

Screenshot

Key features

  • You dont leave the terminal.
  • It's non-interactive like ls, cd and most of cli commands. Life is too short to navigate menus.
  • It's precise, it only output the code you asked.

How to use

Go to the project dir, it requires to be inside the project to work (go.mod needed).

Create coverage profile as usual: go test -coverprofile cover.out ./....

Render it cover (cover.out is the default profile name). By default it renders all files in the current directory recursive (./...).

But the best part is filters. You determine what coverage target you want, you may have simple rule (all files at least 80% covered) or as much flexible as you want (separate coverage target for each file, package or function, exclude experimental subpackages or unexported functions).

Then you may write your tests with very little distraction: no typing, no clicking, no switching to browser and back, very little of scrolling.

You may also use it as an automated checker as it can return exit code 1 if something is selected. You set the rules and eliminate what breaks them.

cover --exit-code <target_filters...> && echo "You are covered!" || echo "There is something to cover"

Filters

Select by path. Paths are relative to the current directory.

. # not recursive
./wire
tlog.go

Select by package name, type name, function name or combined

wire
Encoder
AppendValue
wire.Encoder.AppendValue
github.com/nikandfor/tlog/ext/tlflag.OpenWriter

File filter is a glob, function filter is a regexp.

./ext/tl*

wire.Encoder.Append.+

Filter by coverage.

tlog.go:b70  # filter by file name, then by coverage: *b* for below, 70 is percent
             # Select all functions in a file with coverage below 70%

# there are 'b' (below) or 'l' (less then) and 'a' (above) or 'g' (greater then) filters

Logger:b80:a10  # all methods of Logger with coverage from 10% to 80%
:b80            # every function in the current directory covered below 80% recursive

# function coverage is compared by default, but if `...` wildcard path filter suffix is used then file total coverage is compared.

wire:l80     # functions with less than 80% coverage
ext/...:l80  # files with less than 80% total coverage

Negative filter. Filter prefixed with ! unselects previously selected functions.

!unsafe.go
!./ext/...

!tq/parse
!tlog.[a-z].+

Filter chaining.

# quotes to prevent shell substitution

./ext/... '!tlgraylog'                 # extensions except tlgraylog
./wire/ '!Encoder' '!Decoder' '!:a80'  # functions in wire package except Encoder and Decoder methods and except well covered
...:b80                                # files to cover

Examples are from tlog.

cover's People

Contributors

nikandfor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.