I'm using lcov, I want to exclude some files/directories from my coverage reports.
When I use os.system():
os.system("lcov --remove build/unit_test_coverage.info \'*test*\' \'*mock*\' -o build/unit_test_coverage.info")
It excludes the files/directories as I expect.
But when I use subprocess.call() like this:
subprocess.call(["lcov", "--remove", "build/unit_test_coverage.info", "\'*test*\'", "\'*mock*\'", "-o", "build/unit_test_coverage.info"])
The files/directories are not exluded.
Anyone know why?
subprocess.call
does not use a shell by default so you do not need to escape or protect "*". Do it like this:The docs for
subprocess.call
say to look at the docs forPopen
to see how the arguments work. There it says that the shell is only used if you also specifyshell=True
and give it a string as first argument. There is also a "note" block there explaining this stuff.