GithubHelp home page GithubHelp logo

bashcov's Introduction

bashcov and bashunit - unit testing for bash

This repository contains two tools. bashcov is a generic execution coverage tracer for bash. It can be used to examine code coverage of arbitrary script executions. bashunit executes unit tests from files matching *_test.sh, and generates coverage analysis for all the tested scripts.

bashunit - unit testing for bash scripts

Using bashunit you can create practical unit tests for bash programs. Using built-in coverage analysis and convention-based code organization, you can incrementally integrate test code into an existing shell project.

Please review the unit tests for bashcov as an example.

bashcov - execution coverage for bash scripts

Using bashcov you can run a bash script and measure execution coverage. This can be useful for writing and measuring unit tests for bash programs.

Example:

Using bashcov on itself, to print the help message and quit:

./bashcov ./bashcov

This executes bashcov under a trace, processes the trace file and creates bashcov.coverage. In general all executed (or sourced and executed) scripts are processed. The resulting coverage analysis is written to bashcov.coverage and is modeled after gcov output.

For the example above, with most of the script body and license omitted, the output looks as follows. The integer indicates the number of times a given line was executed.

  -: #!/bin/bash
  Licence text omitted for brevity
  -: 
  1: declare -A -i cov_files  # set of files encountered
  1: declare -A -i cov_lines  # set of file:line pairs executed
  -: 
  -: main() {
  1: 	if [ $# -eq 0 ]; then
  1: 		echo "usage: bashcov SCRIPT [ARGUMENTS]"
  1: 		exit 0
  -: 	fi
  Body of "main", omitted for brevity
  -: }
  -: 
  1: main "$@"

bashcov's People

Contributors

zyga avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

bashcov's Issues

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.