]> cloud.milkyroute.net Git - dolphin.git/commitdiff
fix coverage generation when run through ctest
authorHarald Sitter <sitter@kde.org>
Mon, 18 Mar 2019 14:23:20 +0000 (15:23 +0100)
committerHarald Sitter <sitter@kde.org>
Mon, 18 Mar 2019 14:24:13 +0000 (15:24 +0100)
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.

src/settings/services/test/test_helper.rb

index 98c29c139163b3d7056e50ebab3a0eb0a2c0f6e4..9da5cf3c31e521290c15346c20762ef5fdb99ba3 100644 (file)
 # Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 # 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'
 begin
   require 'simplecov'
+
   SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
     [
       SimpleCov::Formatter::HTMLFormatter
     ]
   )
   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
 rescue LoadError
   warn 'SimpleCov not loaded'
 end
@@ -58,8 +79,9 @@ def covered_system(cmd, *argv)
     begin
       require 'simplecov'
       SimpleCov.start do
     begin
       require 'simplecov'
       SimpleCov.start do
+        root GLOBAL_COVERAGE_ROOT
+        coverage_dir GLOBAL_COVERAGE_DIR
         command_name "#{cmd}_#{__test_method_name__}"
         command_name "#{cmd}_#{__test_method_name__}"
-        merge_timeout 16
       end
     rescue LoadError
       warn 'SimpleCov not loaded'
       end
     rescue LoadError
       warn 'SimpleCov not loaded'