┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHarald Sitter <[email protected]>2019-03-18 15:23:20 +0100
committerHarald Sitter <[email protected]>2019-03-18 15:24:13 +0100
commit81ff2a73f9d0985bca9e22f4e56d2b6738d15b4c (patch)
treeac744bef09f7512e3ba622989b6662379e074b64 /src
parent644d6f85223d486a412af9aaf4b40ef3d5d6705b (diff)
fix coverage generation when run through ctest
path construction is a bit disappointing and doesn't actually work all that well for out-of-tree PWDs. in lieu of an upstream fix let's try our best to get the correct coverage directory set. without this hack no results get recorded unfortunately.
Diffstat (limited to 'src')
-rw-r--r--src/settings/services/test/test_helper.rb26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/settings/services/test/test_helper.rb b/src/settings/services/test/test_helper.rb
index 98c29c139..9da5cf3c3 100644
--- a/src/settings/services/test/test_helper.rb
+++ b/src/settings/services/test/test_helper.rb
@@ -15,14 +15,35 @@
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+GLOBAL_COVERAGE_ROOT = File.dirname(__dir__) # ../
+
+# Simplecov is a bit meh and expects src and coverage to be under the
+# same root. Since we get run through cmake that assumption absolutely
+# doesn't hold true, so we'll need to figure out the coverage_dir relative
+# to the root and the root must always be the source :/
+# The relativity only works because internally the path gets expanded, this
+# isn't fully reliable, but oh well...
+# https://github.com/colszowka/simplecov/issues/716
+GLOBAL_COVERAGE_DIR = begin
+ require 'pathname'
+ src_path = Pathname.new(GLOBAL_COVERAGE_ROOT)
+ coverage_path = Pathname.new(File.join(Dir.pwd, 'coverage'))
+ coverage_path.relative_path_from(src_path).to_s
+end
+
begin
require 'simplecov'
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
[
SimpleCov::Formatter::HTMLFormatter
]
)
- SimpleCov.start
+
+ SimpleCov.start do
+ root GLOBAL_COVERAGE_ROOT
+ coverage_dir GLOBAL_COVERAGE_DIR
+ end
rescue LoadError
warn 'SimpleCov not loaded'
end
@@ -58,8 +79,9 @@ def covered_system(cmd, *argv)
begin
require 'simplecov'
SimpleCov.start do
+ root GLOBAL_COVERAGE_ROOT
+ coverage_dir GLOBAL_COVERAGE_DIR
command_name "#{cmd}_#{__test_method_name__}"
- merge_timeout 16
end
rescue LoadError
warn 'SimpleCov not loaded'