]> git.sur5r.net Git - i3/i3/commitdiff
Merge pull request #1628 from acrisci/feature/complete-run-coverage
authorMichael Stapelberg <stapelberg@users.noreply.github.com>
Thu, 2 Apr 2015 07:33:05 +0000 (00:33 -0700)
committerMichael Stapelberg <stapelberg@users.noreply.github.com>
Thu, 2 Apr 2015 07:33:05 +0000 (00:33 -0700)
complete-run: add coverage report generation

common.mk
docs/testsuite
testcases/complete-run.pl

index b9e15a286fc27d335e4ae8c12a36ec8188dbd972..dcc90c964f968c975c7a7bbf2e62352d895de524 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -1,6 +1,5 @@
 UNAME=$(shell uname)
 DEBUG=1
-COVERAGE=0
 INSTALL=install
 LN=ln
 ifndef PREFIX
index 29a352185da2f2f39ec2e24cf47224671fda86d6..8fdb9635b9648fcc6e8e7e1b380a80801033c8e8 100644 (file)
@@ -160,6 +160,27 @@ $ ./complete-run.pl --parallel=1 --keep-xserver-output
 This will show the output of Xephyr, which is the X server implementation we
 use for testing.
 
+==== Coverage testing
+
+Coverage testing is possible with +lcov+, the front-end for GCC's coverage
+testing tool +gcov+. The testcases can generate a nice html report that tells
+you which functions and lines were covered during a run of the tests. You can
+use this tool to judge how effective your tests are.
+
+To use test coverage tools, first compile with coverage enabled.
+
+---------------------------------------------------
+COVERAGE=1 make
+---------------------------------------------------
+
+Then run the tests with the +--coverage-testing+ flag.
+
+---------------------------------------------------
+./complete-run.pl --coverage-testing
+---------------------------------------------------
+
+Then open +latest/i3-coverage/index.html+ in your web browser.
+
 ==== IPC interface
 
 The testsuite makes extensive use of the IPC (Inter-Process Communication)
index 9710017d71271866212c46638b7ebfb4a0103961..8a3b89f0ffe447f75be832c1270a9ba3d9cca830 100755 (executable)
@@ -86,6 +86,16 @@ foreach my $binary (@binaries) {
     die "$binary is not an executable" unless -x $binary;
 }
 
+if ($options{coverage}) {
+    qx(command -v lcov &> /dev/null);
+    die "Cannot find lcov needed for coverage testing." if $?;
+    qx(command -v genhtml &> /dev/null);
+    die "Cannot find genhtml needed for coverage testing." if $?;
+
+    # clean out the counters that may be left over from previous tests.
+    qx(lcov -d ../ --zerocounters &> /dev/null);
+}
+
 qx(Xephyr -help 2>&1);
 die "Xephyr was not found in your path. Please install Xephyr (xserver-xephyr on Debian)." if $?;
 
@@ -227,6 +237,17 @@ if ($numtests == 1) {
 
 END { cleanup() }
 
+if ($options{coverage}) {
+    print("\nGenerating test coverage report...\n");
+    qx(lcov -d ../ -b ../ --capture -o latest/i3-coverage.info);
+    qx(genhtml -o latest/i3-coverage latest/i3-coverage.info);
+    if ($?) {
+        print("Could not generate test coverage html. Did you compile i3 with test coverage support?\n");
+    } else {
+        print("Test coverage report generated in latest/i3-coverage\n");
+    }
+}
+
 exit ($aggregator->failed > 0);
 
 #
@@ -391,7 +412,8 @@ available in C<latest/xtrace-for-$test.log>.
 
 =item B<--coverage-testing>
 
-Exits i3 cleanly (instead of kill -9) to make coverage testing work properly.
+Generates a test coverage report at C<latest/i3-coverage>. Exits i3 cleanly
+during tests (instead of kill -9) to make coverage testing work properly.
 
 =item B<--parallel>