This is an automated email from the ASF dual-hosted git repository. jdanek pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
The following commit(s) were added to refs/heads/master by this push: new 9ac9ba4 PROTON-2221 Add coverage reporting for the Ruby binding (#130) 9ac9ba4 is described below commit 9ac9ba46fe4bd459630e1e46be363de618059ba9 Author: Jirka Daněk <d...@redhat.com> AuthorDate: Fri May 22 22:55:13 2020 +0200 PROTON-2221 Add coverage reporting for the Ruby binding (#130) Co-authored-by: Jiri Danek <jda...@redhat.com> --- .travis.yml | 2 +- docs/developers.md | 4 +++- ruby/CMakeLists.txt | 9 ++++++++- ruby/tests/collect_coverage.rb | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3572ff8..b51505d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -125,7 +125,7 @@ addons: install: - python -m pip install --user --upgrade pip - python -m pip install --user coverage setuptools wheel tox -- gem install minitest +- gem install minitest simplecov codecov before_script: - mkdir build diff --git a/docs/developers.md b/docs/developers.md index 2152864..3f86f6d 100644 --- a/docs/developers.md +++ b/docs/developers.md @@ -80,9 +80,11 @@ To run coverage reporting: # install coverage tools $ dnf install lcov $ pip install coverage + $ gem install simplecov $ cmake -DCMAKE_BUILD_TYPE=Coverage && make && ctest && make coverage - # Then browse to {CMAKE_BUILD_DIR}/coverage_results/html/index.html + # Then browse to {CMAKE_BUILD_DIR}/coverage_results/html/index.html to see C/C++ coverage + # and to {CMAKE_BUILD_DIR}/ruby/coverage/index.html for Ruby coverage Mailing list ------------ diff --git a/ruby/CMakeLists.txt b/ruby/CMakeLists.txt index 0463fe5..9dd7bc7 100644 --- a/ruby/CMakeLists.txt +++ b/ruby/CMakeLists.txt @@ -118,12 +118,18 @@ install(DIRECTORY examples/ to_native_path("${src}/lib;${src}/tests;${src}/spec;${bin};${c_lib_dir};$ENV{RUBYLIB}" RUBYLIB) to_native_path("${bin};${c_lib_dir};$ENV{PATH}" PATH) +if (CMAKE_BUILD_TYPE MATCHES "Coverage") + set(COVERAGE "COVERAGE=1") +endif () + execute_process(COMMAND ${RUBY_EXECUTABLE} -r minitest -e "" RESULT_VARIABLE result OUTPUT_QUIET ERROR_QUIET) if (result EQUAL 0) # Have minitest set(test_env "PATH=${PATH}" "RUBYLIB=${RUBYLIB}" + "${COVERAGE}" + "COVERAGE_DIR=${CMAKE_CURRENT_BINARY_DIR}/coverage" "SASLPASSWD=${CyrusSASL_Saslpasswd_EXECUTABLE}") macro(add_ruby_test script) @@ -133,7 +139,8 @@ if (result EQUAL 0) # Have minitest INTERPRETED NAME ${name} PREPEND_ENVIRONMENT ${test_env} - COMMAND ${RUBY_EXECUTABLE} ${script} -v + COMMAND ${RUBY_EXECUTABLE} -r${CMAKE_CURRENT_SOURCE_DIR}/tests/collect_coverage.rb ${script} -v + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} # simplecov doesn't report on code not under $CWD ${ARGN}) endmacro() diff --git a/ruby/tests/collect_coverage.rb b/ruby/tests/collect_coverage.rb new file mode 100644 index 0000000..bddbe90 --- /dev/null +++ b/ruby/tests/collect_coverage.rb @@ -0,0 +1,32 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + +if ENV['COVERAGE'] + require 'simplecov' + SimpleCov.start do + if ENV['TRAVIS'] + require 'codecov' + formatter SimpleCov::Formatter::MultiFormatter.new([ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::Codecov, + ]) + end + coverage_dir ENV['COVERAGE_DIR'] or 'coverage' + track_files 'ruby/lib/**/*.rb' + end +end --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org