Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed --root option #108

merged 1 commit into from
Aug 5, 2016

fixed --root option #108

merged 1 commit into from
Aug 5, 2016


Copy link

@attie attie commented Jul 22, 2015

Previously, gcovr would get tangled up if you tried to output to a relative directory, and change the root (root_dir) away from the invocation working directory (starting_dir)

Copy link


Copy link

There appears to be lot of issues relating to out of source builds, and --root and --object-directory.
See #61 #64 #72 #112

Copy link

I made the following change to the oos testcase, such that I believe it more closely reflects how tools like autoconf/automake perform out of source builds (what they call vpath builds), and it fails:

diff --git a/gcovr/tests/oos/Makefile b/gcovr/tests/oos/Makefile
index a679d80..b5d5eb9 100644
--- a/gcovr/tests/oos/Makefile
+++ b/gcovr/tests/oos/Makefile
@@ -1,14 +1,14 @@
 CFLAGS= -fprofile-arcs -ftest-coverage -fPIC

-       mkdir -p build
-       $(CXX) $(CFLAGS) -c src/file1.cpp -o build/file1.o
-       $(CXX) $(CFLAGS) -c src/main.cpp -o build/main.o
-       $(CXX) $(CFLAGS) build/main.o build/file1.o -o build/testcase
+       mkdir -p build/src
+       cd build; $(CXX) $(CFLAGS) -c ../src/file1.cpp -o src/file1.o
+       cd build; $(CXX) $(CFLAGS) -c ../src/main.cpp -o src/main.o
+       cd build; $(CXX) $(CFLAGS) src/main.o src/file1.o -o testcase

 run: txt xml html


@@ -23,5 +23,5 @@ html:
        ../../../scripts/gcovr $(GCOVR_TEST_OPTIONS) -d --html --html-details -o coverage.html

-       rm -f build/*
+       rm -rf build/*
        rm -f coverage.txt coverage.xml coverage*.html
FAIL: test_oos (__main__.GcovrTxt)
function test: test_oos (__main__.GcovrTxt)
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pyutilib/th/", line 256, in <lambda>
    func = lambda self,c1=fn,c2=name,c3=suite: _run_fn_test(self,c1,c2,c3)
  File "/usr/local/lib/python2.7/dist-packages/pyutilib/th/", line 164, in _run_fn_test
    explanation = fn(self, name)
  File "", line 92, in gcovr_test_txt
    self.assertFileEqualsBaseline("coverage.txt", "reference/coverage.txt")
  File "/usr/local/lib/python2.7/dist-packages/pyutilib/th/", line 224, in assertFileEqualsBaseline"Unexpected output difference at line "+str(lineno) +":\n   testfile="+testfile+"\n   baseline="+baseline+"\nDiffs:\n"+diffs)
AssertionError: Unexpected output difference at line 7:
--- reference/coverage.txt

+++ coverage.txt

@@ -1,5 +1,5 @@

 File                                       Lines    Exec  Cover   Missing
-src/file1.cpp                                  2       2   100%
-src/main.cpp                                   8       7    87%   7
+TOTAL                                          0       0    --%


@whart222 you created this test, can you suggest the correct gcovr options to make it work with my changed test case?

@whart222 whart222 merged commit 22d215b into gcovr:master Aug 5, 2016
Copy link

whart222 commented Aug 5, 2016

I agree that this better captures the model for out-of-source builds. I'll work on that.

But this pull request really didn't add capability for executing with this model, so I'm closing it.

whart222 added a commit that referenced this pull request Aug 5, 2016
This was introduced in #108, but it broke nested builds.
JamesReynolds pushed a commit to JamesReynolds/gcovr that referenced this pull request Mar 8, 2018
This was introduced in gcovr#108, but it broke nested builds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants