Skip to content

Instantly share code, notes, and snippets.

@collinjackson
Last active September 23, 2019 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save collinjackson/b760e6914883440579b72c9ac5d40807 to your computer and use it in GitHub Desktop.
Save collinjackson/b760e6914883440579b72c9ac5d40807 to your computer and use it in GitHub Desktop.
Gets coverage data for Flutter packages
#!/bin/bash
set -e
if [ $# -eq 0 ]
then
echo Usage: ./coverage.sh package_1 package_2 ...
exit 1
fi
for package in $@; do
echo $package
pub cache add $package >/dev/null # Download it if it's not already there
version=`pub cache add $package | awk '{print $4}' | sed -e s/[.]*$//`
pushd ~/.pub-cache/hosted/pub.dartlang.org/$package-$version/
grep flutter_test pubspec.yaml || (cp pubspec.yaml pubspec.yaml.bak && cat pubspec.yaml.bak | awk '/dev_dependencies/{print;print " flutter_test:";print " sdk: flutter";next}1' > pubspec.yaml)
(flutter test --coverage && genhtml coverage/lcov.info -o coverage --no-function-coverage -s -p `pwd` | tail -n 1)
(mv pubspec.yaml.bak pubspec.yaml)
popd
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment