Go Coverage in Shell: a tool for exploring Go Coverage reports from the command line

Overview

gocovsh

gocovsh is a CLI viewer of Go test coverage reports.

Installation

$ go install github.com/orlangure/gocovsh

More installation options will follow.

Usage

  1. Generate Go coverage report at your project's root with

    $ go test -cover -coverprofile coverage.out

    For more information about generating Go coverage reports, see my blog post.

  2. Run gocovsh at the same folder with coverage.out report and go.mod file (go.mod is required).

    $ gocovsh
    $ gocovsh --profile profile.out # for other coverage profile names
  3. Use j/k/enter/esc keys to explore the report. See built-in help for more key-bindings.

image

image

Issues
  • feat: sort by percentage (lowest to highest)

    feat: sort by percentage (lowest to highest)

    Basically, sorts from the lowest percentage to the highest.

    image

    Because seeing this is not very helpful to spot defects

    image

    The tests will not pass anymore because the golden file testing strategy is a nightmare to work with, especially when you have blank lines filled with spaces, as you can see on the screenshot below.

    image

    Thanks for this tool, it is very convenient !

    opened by EwenQuim 5
  • Bug: full file paths in coverage output (windows)

    Bug: full file paths in coverage output (windows)

    Describe the bug It doesn't work on windows

    To Reproduce Steps to reproduce the behavior:

    1. go install github.com/orlangure/[email protected]
    2. cd Some/Directory
    3. git clone https://github.com/tsoding/snitch
    4. cd snitch
    5. go test -v -cover -coverprofile coverage.out
    6. gocovsh --profile coverage.out
    7. Enter on a selected file.

    Expected behavior File paths are relative in the cover.out file eg. github.com/tsoding/snitch/logcmd.go:26.33,28.4 1 0. I don't think this issue is package-specific (snitch).

    Screenshots Files After Opening a file

    Desktop (please complete the following information):

    • OS: Windows 10
    • Info:
        Edition	Windows 10 Home Single Language
        Version	21H1
        Installed on	‎8/‎7/‎2020
        OS build	19043.1566
        Experience	Windows Feature Experience Pack 120.2212.4170.0
      
    • Terminal emulator: cmd.exe, clink, alacritty

    Additional context Not sure if this is windows specific but I'm on windows.

    opened by phanirithvij 4
  • Accept

    Accept "git diff" as input

    In addition to supporting file list input, this commit adds support for raw "git diff" output. In this case, only the changed files will appear, and only the lines marked as "added" in the diff will be shown. For every such line, its coverage status will be reported of course (red/green/gray).

    opened by orlangure 1
  • feat: use go mod proxying

    feat: use go mod proxying

    This enables read build info both on binaries built by goreleaser, as well as installed with go install directly.

    More info: https://carlosbecker.com/posts/supply-chain-goreleaser-go-mod-proxy/

    opened by caarlos0 1
  •  Support explicit selection of files to display

    Support explicit selection of files to display

    In larger projects, running gocovsh after making a small change will cause redundant work to find the changed files in the long, multi-page list. This flow appears to be the most common for a routine work: usually the developer will want to view their change coverage, and not the entire project coverage.

    To achieve this goal, the list of files should be piped into gocovsh. It allows to keep the "list" operation abstract: it can be a git diff with any arguments the user desires, if the result is a simple multi-line list of files.

    For example, the suggested usage would be:

    git diff --name-only | gocovsh		# view non-stashed changes
    git diff --name-only master | gocovsh	# view changes relative to master
    
    opened by orlangure 1
  • Calculate total coverage value per file

    Calculate total coverage value per file

    The value should be displayed in both list and code views:

    • in list view, next to every file name
    • in code view, either near the name at the top, or at the bottom near the progress indicator
    enhancement 
    opened by orlangure 0
  • Support 3 states of help: hidden, visible, full

    Support 3 states of help: hidden, visible, full

    After a couple usages the keys should be memorized, so the users might want to hide the help completely to add another row to the code view/list.

    In the future, help section state will be persisted in the optional configuration file, so that for every new gocovsh session the menu will be in the selected state.

    Closes #3

    opened by orlangure 0
  • feat: goreleaser setup

    feat: goreleaser setup

    closes #9 closes #8

    This adds:

    • build the binaries for windows, linux and darwin, amd64, arm64 and 386 (can add more if you want/need)
    • keyless sign archives with cosign
    • create a release on github and upload the artifacts
    • create/update the formula on a homebrew-tap repository

    TODOs for @orlangure

    • create a homebrew-tap repository
    • create a personal access token with write access
    • add it as a secret to this project (named GITHUB_PAT)
    • cut a new tag
    opened by caarlos0 0
  • Allow sorting files list by coverage

    Allow sorting files list by coverage

    For larger projects, it might be useful to support sorting the entries in the list by their total coverage. Another potentially useful mode could be sorting by the number of non-covered statements: show the files with the most potential improvements to make first.

    enhancement 
    opened by orlangure 2
  • Consider using cover.Boundary objects to colorize coverage

    Consider using cover.Boundary objects to colorize coverage

    https://github.com/golang/tools/blob/master/cmd/cover/html.go includes the logic of the built-in html based coverage viewer. It uses boundary objects that essentially mark where to start every color block. It should be more precise and battle tested than the original procedure that I wrote.

    enhancement 
    opened by orlangure 0
Releases(v0.5.1)
Owner
Yury Fedorov
Software Developer
Yury Fedorov
A tool for exploring each layer in a docker image

dive A tool for exploring a docker image, layer contents, and discovering ways to shrink the size of your Docker/OCI image. To analyze a Docker image

Alex Goodman 33.1k Aug 8, 2022
painless task queue manager for shell commands with an intuitive cli interface (execute shell commands in distributed cloud-native queue manager).

EXEQ DOCS STILL IN PROGRESS. Execute shell commands in queues via cli or http interface. Features Simple intuitive tiny cli app. Modular queue backend

Mohammed Al Ashaal 12 Jan 29, 2022
ap 是一个 shell 工具,可以让其它 shell 命令的输出能够自动进入交互翻页模式

ap -- auto-pager ap 是一个 shell 工具,可以让其它 shell 命令的输出能够自动进入交互翻页模式。 ap 由两部分组成,一个 Go 语言编写的二进制程序,负责捕获命令的输出并支持翻页, 和一组 shell 脚本,负责为用户指定的命令清单创建与之同名的 wrapper。 经

flw 12 Apr 12, 2022
An open-source GitLab command line tool bringing GitLab's cool features to your command line

GLab is an open source GitLab CLI tool bringing GitLab to your terminal next to where you are already working with git and your code without switching

Clement Sam 2k Jul 27, 2022
A command line tool to prompt for a value to be included in another command line.

readval is a command line tool which is designed for one specific purpose—to prompt for a value to be included in another command line. readval prints

Venky 0 Dec 22, 2021
CLI for exploring AWS EC2 Spot inventory. Inspect AWS Spot instance types, saving, price, and interruption frequency.

spotinfo The spotinfo is a command-line tool that helps you determine AWS Spot instance types with the least chance of interruption and provides the s

Alexei Ledenev 68 Aug 4, 2022
Tools for exploring OpenVG

Testbed for exploring OpenVG on the Raspberry Pi. First program Here is the graphics equivalent of "hello, world" // first OpenVG program // Anthony S

Anthony Starks 392 Jun 17, 2022
Query git repositories with SQL. Generate reports, perform status checks, analyze codebases. 🔍 📊

askgit is a command-line tool for running SQL queries on git repositories. It's meant for ad-hoc querying of git repositories on disk through a common interface (SQL), as an alternative to patching together various shell commands.

AskGit 3.1k Aug 3, 2022
Scrappy is a cli tool that allows multiple web scrappers to monitor periodically for a basic ruleset coverage and inform users when the criteria have been met.

Scrappy - A multi-type web scrapper with alerting Scrappy is a cli tool that allows multiple web scrappers to monitor periodically for a basic ruleset

Michalis Zampetakis 0 Nov 7, 2021
git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.

Table of contents Introduction Reference Contributing Introduction Overview git-xargs is a command-line tool (CLI) for making updates across multiple

Gruntwork 622 Aug 7, 2022
git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command

git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command. You give git-xargs:

Maxar Infrastructure 1 Feb 5, 2022
A command line tool for simplified docker volume command built with go

dockervol A command line tool for simplified docker volume command built with go. Features: Remove anonymous volume (beta) Remove volume by matching n

Moh Achun Armando 0 Dec 18, 2021
Run any shell command in a temporary proxy environment.

Run any shell command in a temporary proxy environment.

Wonder 4 Jun 2, 2022
An unsupervised coverage-guided kernel fuzzer

syzkaller - kernel fuzzer syzkaller is an unsupervised coverage-guided kernel fuzzer. Linux kernel fuzzing has the most support, akaros, freebsd, fuch

Tinker Board 2 - Android 0 Oct 27, 2021
🎄 Go code coverage to SVG treemap

?? Go cover to Treemap Useful when you have large project with lots of files and packages $ go install github.com/nikolaydubina/[email protected]

Nikolay Dubina 102 Jul 29, 2022
Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies.

asciigraph Go package to make lightweight ASCII line graphs ╭┈╯. Installation go get github.com/guptarohit/asciigraph Usage Basic graph package main

Rohit Gupta 2k Aug 5, 2022
fofax is a fofa query tool written in go, positioned as a command-line tool and characterized by simplicity and speed.

fofaX 0x00 Introduction fofax is a fofa query tool written in go, positioned as

null 419 Jul 30, 2022
Package command provide simple API to create modern command-line interface

Package command Package command provide simple API to create modern command-line interface, mainly for lightweight usage, inspired by cobra Usage pack

chenen 0 Jan 16, 2022
Watcher - A simple command line app to watch files in a directory for changes and run a command when files change!

Watcher - Develop your programs easily Watcher watches all the files present in the directory it is run from of the directory that is specified while

Geet Sethi 1 Mar 27, 2022