Giter Site home page Giter Site logo

Support multiple filter options about gcovr HOT 2 CLOSED

gcovr avatar gcovr commented on May 18, 2024
Support multiple filter options

from gcovr.

Comments (2)

whart222 avatar whart222 commented on May 18, 2024

Patch from [email protected]

From 40946a6ad78cf79369676e65b3447b1ac14df2e9 Mon Sep 17 00:00:00 2001
From: Robert Rosengren <[email protected]>
Date: Tue, 30 Apr 2013 10:53:44 +0200
Subject: [PATCH 2/2] Multiple filter-options supported

---
 scripts/gcovr |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/scripts/gcovr b/scripts/gcovr
index e375ffe..c7a7381 100755
Index: scripts/gcovr
===================================================================
--- a/scripts/gcovr
+++ b/scripts/gcovr
@@ -359,15 +359,21 @@
     #
     # Return if the filename does not match the filter
     #
-    if not options.filter.match(fname):
-        if options.verbose:
-            sys.stdout.write("  Filtering coverage data for file %s\n" % fname)
-        return
+    filtered_fname = None
+    if len(options.filter) > 0:
+        for i in range(0,len(options.filter)):
+            if options.filter[i].match(fname):
+                filtered_fname = options.filter[i].sub('',fname)
+                break
+        if filtered_fname is None:
+            if options.verbose:
+                sys.stdout.write("  Filtering coverage data for file %s\n" % fname)
+            return
     #
     # Return if the filename matches the exclude pattern
     #
     for i in range(0,len(options.exclude)):
-        if options.exclude[i].match(options.filter.sub('',fname)) or \
+        if (filtered_fname is not None and options.exclude[i].match(filtered_fname)) or \
                options.exclude[i].match(fname) or \
                options.exclude[i].match(os.path.abspath(fname)):
             if options.verbose:
@@ -873,9 +879,9 @@
         default=False)
 parser.add_option("-f","--filter",
         help="Keep only the data files that match this regular expression",
-        action="store",
+        action="append",
         dest="filter",
-        default=None)
+        default=[])
 parser.add_option("-e","--exclude",
         help="Exclude data files that match this regular expression",
         action="append",
@@ -945,10 +951,8 @@
 #
 for i in range(0,len(options.exclude)):
     options.exclude[i] = re.compile(options.exclude[i])
-if options.filter is not None:
-    options.filter = re.compile(options.filter)
-else:
-    options.filter = re.compile('')
+for i in range(0,len(options.filter)):
+    options.filter[i] = re.compile(options.filter[i])
 if options.root is not None:
     if not options.root:
         sys.stderr.write(

from gcovr.

whart222 avatar whart222 commented on May 18, 2024

Tests are passing with this merge, so I'm closing this ticket. Thanks!

from gcovr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.