Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to travis-ci and codecov.io #10

Merged
merged 2 commits into from
Aug 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: dart
dart:
- stable
services:
- rabbitmq
script:
- export PATH="$PATH":"~/.pub-cache/bin"
- pub get --packages-dir
- pub global activate coverage
- cd test
- bash run.sh
- bash test_coverage.sh
- bash <(curl -s https://codecov.io/bash) -X gcov -f '*.lcov'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# dart_ampq

[![Build Status](https://drone.io/github.com/achilleasa/dart_amqp/status.png)](https://drone.io/github.com/achilleasa/dart_amqp/latest)
[![Coverage Status](https://coveralls.io/repos/achilleasa/dart_amqp/badge.svg)](https://coveralls.io/r/achilleasa/dart_amqp)
[![Build Status](https://travis-ci.org/achilleasa/dart_amqp.svg?branch=master)](https://travis-ci.org/achilleasa/dart_amqp)
[![codecov](https://codecov.io/gh/achilleasa/dart_amqp/branch/master/graph/badge.svg)](https://codecov.io/gh/achilleasa/dart_amqp)

Dart AMQP client implementing protocol version 0.9.1

Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ dev_dependencies:
mock: ">=0.11.0+2 <0.12.0"
http: ">=0.11.1+1 <0.12.0"
xml: ">=2.2.3 <3.0.0"
coverage: "^0.7.0"
dart_codecov_generator: "^0.4.0"
8 changes: 4 additions & 4 deletions test/lib/encode_decode_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ main({bool enableLogger : true}) {
test("timestamp", () {
// Use second accuracy
DateTime now = new DateTime.now();
now = now.subtract(new Duration(milliseconds : now.millisecond));
now = now.subtract(new Duration(milliseconds : now.millisecond, microseconds: now.microsecond));

encoder.writeTimestamp(now);
decoder = decoderFromEncoder(encoder);
Expand Down Expand Up @@ -176,7 +176,7 @@ main({bool enableLogger : true}) {
test("table", () {
// Use second accuracy
DateTime now = new DateTime.now();
now = now.subtract(new Duration(milliseconds : now.millisecond));
now = now.subtract(new Duration(milliseconds : now.millisecond, microseconds: now.microsecond));

Map tableData = {
"map" : {
Expand Down Expand Up @@ -211,7 +211,7 @@ main({bool enableLogger : true}) {
test("table (unsupported field exception)", () {
// Use second accuracy
DateTime now = new DateTime.now();
now = now.subtract(new Duration(milliseconds : now.millisecond));
now = now.subtract(new Duration(milliseconds : now.millisecond, microseconds: now.microsecond));

Map tableData = {
"unsupported" : new StreamController()
Expand All @@ -221,4 +221,4 @@ main({bool enableLogger : true}) {
});

});
}
}
2 changes: 1 addition & 1 deletion test/lib/queue_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ main({bool enableLogger : true}) {

// Use second accuracy
DateTime now = new DateTime.now();
now = now.subtract(new Duration(milliseconds : now.millisecond));
now = now.subtract(new Duration(milliseconds : now.millisecond, microseconds: now.microsecond));

consumer.listen(expectAsync((AmqpMessage message) {
expect(message.payloadAsJson, equals({"message" : "Test payload"}));
Expand Down
45 changes: 13 additions & 32 deletions test/test_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,14 @@

# Build test coverage reports. To use this script you need to:
# 1) Install lcov package
# 2) Clone dart-lang/coverage repo from GH (https://github.com/dart-lang/coverage)
# 3) Run pub update inside the cloned repo
#
# Then invoke this script passing the path to the coverage tools folder
#

COVERAGE_TOOLS=""

for i in "$@"
do
case ${i} in
-c=*|--coverage-tools=*)
COVERAGE_TOOLS="${i#*=}"
shift
;;
*)
# unknown option
;;
esac
done

if [ "$COVERAGE_TOOLS" == "" ]; then
echo "Please enter path to covert coverage tools folder with the -c or --coverage-tools option"
exit 1
fi
# 2) pub global activate coverage
# 3) Add .pub-cache/bin folder to your path

# Cleanup the backgrounded unit test runner on exit if something goes wrong
trap 'kill $(jobs -p)' EXIT


# Cleanup
mkdir -p coverage
rm -f coverage/coverage.json
rm -f coverage/coverage.lcov
rm -f coverage/filtered.lcov
Expand All @@ -42,21 +19,25 @@ dart --checked --enable-vm-service --package-root=../packages/ --pause-isolates-

# Run coverage collection tool
echo "Waiting for unit tests to run..."
dart --package-root=${COVERAGE_TOOLS}/packages ${COVERAGE_TOOLS}/bin/collect_coverage.dart --port=8181 -o coverage/coverage.json --wait-paused # --resume-isolates
collect_coverage --port=8181 -o coverage/coverage.json --wait-paused # --resume-isolates
echo "Collected coverage data..."

# Convert data to LCOV format
echo "Converting to LCOV format..."
dart --package-root=${COVERAGE_TOOLS}/packages ${COVERAGE_TOOLS}/bin/format_coverage.dart --package-root=../ -i coverage/coverage.json -l > coverage/coverage.lcov
format_coverage --package-root=../ -i coverage/coverage.json -l > coverage/coverage.lcov

# Remove LCOV blocks that do not belong to our project lib/ folder
echo "Filtering unrelated files from the LCOV data..."
PROJECT_ROOT=`pwd | sed -e "s/\\/[^\\/]*$//"`
sed -n '\:^SF.*'"$PROJECT_ROOT"'/lib:,\:end_of_record:p' coverage/coverage.lcov > coverage/filtered.lcov

# Format LCOV data to HTML
echo "Rendering HTML coverage report to: coverage/html"
genhtml coverage/filtered.lcov --output-directory coverage/html --ignore-errors source --quiet
if [ -n "genhtml" ]; then
echo "Rendering HTML coverage report to: coverage/html"
genhtml coverage/filtered.lcov --output-directory coverage/html --ignore-errors source --quiet
echo "The generated coverage data is available here: "`pwd`"/coverage/html/index.html"
fi

rm -f coverage/filtered.lcov

echo "The generated coverage data is available here: "`pwd`"/coverage/html/index.html"
echo
echo