Error while trying to create html report using gcovr, "NoneType" object has no "startswith" attribute
I am getting the error
'NoneType' object has no attribute 'startswith'
when trying to generate html report using gcovr (test coverage estimation tool)
Any idea how I should fix it? For information, I'm on Ubuntu 14.04. See the error message below:
parallels:try_gcovr$ gcovr -r . --html
Traceback (most recent call last):
File "/usr/local/bin/gcovr", line 1970, in <module>
print_html_report(covdata, options.html_details)
File "/usr/local/bin/gcovr", line 1373, in print_html_report
ttmp = os.path.abspath(options.output).split('.')
File "/usr/lib/python2.7/posixpath.py", line 367, in abspath
if not isabs(path):
File "/usr/lib/python2.7/posixpath.py", line 61, in isabs
return s.startswith('/')
AttributeError: 'NoneType' object has no attribute 'startswith'
+3
source to share
1 answer
I had the same problem and solved it using the following command.
gcovr --html --html-details -o output-file-name.html -v -r.
Here's my settings and commands:
$ ls; ls testDir
main.cpp Makefile test.cpp testDir
test.cpp test.h
$ make test
g++ -fprofile-arcs -ftest-coverage -fPIC -O0 -c main.cpp -o main.o
g++ -o test testDir/test.o main.o -lgcov -coverage
$ ./test
hello world
$ ls;ls testDir
main.cpp main.gcda main.o test
main.gcno Makefile test.cpp testDir
test.cpp test.gcda test.gcno test.h test.o
$ gcovr -r . --html
Traceback (most recent call last):
File "/usr/bin/gcovr", line 1970, in <module>
print_html_report(covdata, options.html_details)
File "/usr/bin/gcovr", line 1373, in print_html_report
ttmp = os.path.abspath(options.output).split('.')
File "/usr/lib64/python2.7/posixpath.py", line 343, in abspath
if not isabs(path):
File "/usr/lib64/python2.7/posixpath.py", line 53, in isabs
return s.startswith('/')
AttributeError: 'NoneType' object has no attribute 'startswith'
$ gcovr --html --html-details -o output.html -v -r .
//a bunch of gcov output while generating files...
$ ls; ls testDir
main.cpp Makefile output.html output.testDir_test.cpp.html test.cpp testDir
output.main.cpp.html test
test.cpp test.gcda test.gcno test.h test.o
$ cat Makefile
OBJS=testDir/test.o main.o
EXEC_TARGET=test
CXXFLAGS+=-fprofile-arcs -ftest-coverage -fPIC -O0
bla:
@echo $(GXX)
LINKLIBSCTT+=-lgcov -coverage
#Executable target rule
$(EXEC_TARGET): $(OBJS)
$(CXX) $(LINK_FLAGS) -o $(EXEC_TARGET) $(OBJS) $(LINKLIBSCTT)
#implicit rule to compile object files
%.o: %.cpp
$(CXX) $(INCLUDES) $(CXXFLAGS) -c $^ -o $@
clean:
rm -f *.o *.rpo *.d $(EXEC_TARGET)
+3
source to share