summaryrefslogtreecommitdiff
path: root/scripts/test/cov-exclude
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-04-12 21:12:10 -0400
committerNick Mathewson <nickm@torproject.org>2016-04-12 21:12:10 -0400
commit4043f2c95f4a47e69edc4d451673b7ffda066768 (patch)
tree31e26cf0e4e2d05ab75909d404b5c589896cacc5 /scripts/test/cov-exclude
parentbd34edc18d6e21f5ba7bddf5a7ebe6582e8dc639 (diff)
downloadtor-4043f2c95f4a47e69edc4d451673b7ffda066768.tar.gz
tor-4043f2c95f4a47e69edc4d451673b7ffda066768.zip
Adopt the LCOV convention for marking lines as unreachable by tests.
Document this convention. Add a script to post-process .gcov files in order to stop nagging us about excluded lines. Teach cov-diff to handle these post-processed files. Closes ticket 16792
Diffstat (limited to 'scripts/test/cov-exclude')
-rwxr-xr-xscripts/test/cov-exclude28
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/test/cov-exclude b/scripts/test/cov-exclude
new file mode 100755
index 0000000000..5117f11ec4
--- /dev/null
+++ b/scripts/test/cov-exclude
@@ -0,0 +1,28 @@
+#!/usr/bin/perl -p -i
+
+use warnings;
+use strict;
+our $excluding;
+
+# This script is meant to post-process a .gcov file for an input source
+# that was annotated with LCOV_EXCL_START, LCOV_EXCL_STOP, and LCOV_EXCL_LINE
+# entries. It doesn't understand the LCOV_EXCL_BR* variations.
+#
+# It replaces unreached reached lines with x:, and reached excluded lines
+# with !!!num:.
+
+BEGIN { our $excluding = 0; }
+
+if (m/LCOV_EXCL_START/) {
+ $excluding = 1;
+}
+if ($excluding and m/LCOV_EXCL_STOP/) {
+ $excluding = 0;
+}
+
+my $exclude_this = (m/LCOV_EXCL_LINE/);
+
+if ($excluding or $exclude_this) {
+ s{^\s*\#\#+:}{ x:};
+ s{^ (\s*)(\d+):}{$1!!!$2:};
+}