From 4f6820f72ec51dc95bbff6674103d68a22863f42 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Tue, 2 Jun 2015 10:02:08 +0200 Subject: [PATCH] Enabled CodeCoverage support --- .coveralls.yml | 1 + .travis.yml | 4 ++-- README.md | 1 + test/test_helper.rb | 22 ++++++++++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 000000000..91600595a --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1 @@ +service_name: travis-ci diff --git a/.travis.yml b/.travis.yml index 416a10225..53adc5e29 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,13 +5,13 @@ before_install: # disable rvm, use system Ruby - rvm reset - wget https://raw.githubusercontent.com/yast/yast-devtools/master/travis-tools/travis_setup.sh - - sh ./travis_setup.sh -p "rake yast2-devtools yast2-testsuite yast2 yast2-storage yast2-proxy yast2-country yast2-packager" -g "rspec:2.14.1 yast-rake gettext rubocop:0.29.1" + - sh ./travis_setup.sh -p "rake yast2-devtools yast2-testsuite yast2 yast2-storage yast2-proxy yast2-country yast2-packager" -g "rspec:2.14.1 yast-rake gettext rubocop:0.29.1 simplecov coveralls" script: - rubocop - rake check:syntax - rake check:pot + - COVERAGE=1 rake test:unit - make -f Makefile.cvs - make - sudo make install - make check - diff --git a/README.md b/README.md index bfd036bdb..28ac9cdd2 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ YaST Network Module [![Travis Build](https://travis-ci.org/yast/yast-network.svg?branch=master)](https://travis-ci.org/yast/yast-network) [![Jenkins Build](http://img.shields.io/jenkins/s/https/ci.opensuse.org/yast-network-master.svg)](https://ci.opensuse.org/view/Yast/job/yast-network-master/) [![Code Climate](https://codeclimate.com/github/yast/yast-network/badges/gpa.svg)](https://codeclimate.com/github/yast/yast-network) +[![Coverage Status](https://coveralls.io/repos/yast/yast-network/badge.png)](https://coveralls.io/r/yast/yast-network) The YaST2 Network module manages network configuration including device configuration, DNS, Routing and more diff --git a/test/test_helper.rb b/test/test_helper.rb index bb52d67d8..8f6c03b88 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,25 @@ srcdir = File.expand_path("../../src", __FILE__) y2dirs = ENV.fetch("Y2DIR", "").split(":") ENV["Y2DIR"] = y2dirs.unshift(srcdir).join(":") + +require "yast" + +if ENV["COVERAGE"] + require "simplecov" + SimpleCov.start + + # For coverage we need to load all ruby files + # Note that clients/ are excluded because they run too eagerly by design + Dir["#{srcdir}/{include,modules}/**/*.rb"].each do |f| + require_relative f + end + + # use coveralls for on-line code coverage reporting at Travis CI + if ENV["TRAVIS"] + require "coveralls" + SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ + SimpleCov::Formatter::HTMLFormatter, + Coveralls::SimpleCov::Formatter + ] + end +end