github.com/jonasnick/go-ethereum@v0.7.12-0.20150216215225-22176f05d387/gocoverage.sh (about)

     1  #!/bin/bash
     2  # The script does automatic checking on a Go package and its sub-packages, including:
     3  # 6. test coverage (http://blog.golang.org/cover)
     4  
     5  set -e
     6  
     7  # Run test coverage on each subdirectories and merge the coverage profile.
     8  
     9  echo "mode: count" > profile.cov
    10  
    11  # Standard go tooling behavior is to ignore dirs with leading underscors
    12  for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -type d);
    13  do
    14  if ls $dir/*.go &> /dev/null; then
    15      # echo $dir
    16      if [[ $dir != "./tests/vm" ]]
    17      then
    18          go test -covermode=count -coverprofile=$dir/profile.tmp $dir
    19      fi
    20      if [ -f $dir/profile.tmp ]
    21      then
    22          cat $dir/profile.tmp | tail -n +2 >> profile.cov
    23          rm $dir/profile.tmp
    24      fi
    25  fi
    26  done
    27  
    28  go tool cover -func profile.cov
    29