linux-test-project / lcov

LCOV
GNU General Public License v2.0
867 stars 235 forks source link

v2.0 seems unable to handle spaces in path #222

Closed niklasweimann closed 1 year ago

niklasweimann commented 1 year ago

When using lcov to merge files by appending a path using the -a parameter there seems to be an issue with spaces in the path even though the path is quoted. It used to work perfectly fine in v1.6 but since version v2.0 was published on http://dl-cdn.alpinelinux.org/alpine/edge/testing this merge fails.

I fixed this by removing the spaces in the path but i would hope to get the old behavior back.

This fails since v2.0:

lcov -o lcov.info -a "/builds/frontend/mono-repo/test-reports/test-reports/Chrome Headless 113.0.5672.126 (Linux x86_64)/lcov.info" -a "/builds/frontend2/mono-repo/test-reports/test-reports/Chrome Headless 113.0.5672.126 (Linux x86_64)/lcov.info"

Workaround:

lcov -o lcov.info -a "/builds/frontend/mono-repo/test-reports/lcov.info" -a "/builds/frontend2/mono-repo/test-reports/lcov.info"

Error Message:

Combining tracefiles.
.. found 2 files to aggregate.
Merging /builds/frontend/mono-repo/test-reports/test-reports/Chrome..1 remaining
lcov: ERROR: trace file '/builds/frontend/mono-repo/test-reports/test-reports/Chrome' does not exist
    (use "lcov --ignore-errors empty ..." to bypass this error)
henry2cox commented 1 year ago

Interesting artifact of implementation.

What happens if your command line looks like (workaround):

lcov -o lcov.info -a "/builds/frontend/mono-repo/test-reports/test-reports/Chrome\ Headless\ 113.0.5672.126\ (Linux\ x86_64)/lcov.info" -a "/builds/frontend2/mono-repo/test-reports/test-reports/Chrome\ Headless\ 113.0.5672.126\ (Linux\ x86_64)/lcov.info"

That is: explicitly escape spaces in the path expressions?

Presuming that the workaround works - then I believe I have a fix.

henry2cox commented 1 year ago

Incidentally: for reasons of runtime performace, lcov 2.0 supports glob patterns - so the above could have been:

lcov -o lcov.info -a "/builds/frontend*/mono-repo/test-reports/test-reports/Chrome\ Headless\ 113.0.5672.126\ (Linux\ x86_64)/lcov.info"

If there are just 2 files, then it won't make any difference. If there are a few thousand: it will. You will only notice the difference if you also use the --parallel option and have a multicore server.

niklasweimann commented 1 year ago

Hey 👋 I just checked the escaped version and this in fact works fine.

I used find to generate the "-a" parameters for all lcov files found in the project but i will try the regex version you suggested. Thanks 👍

henry2cox commented 1 year ago

but i will try the regex version you suggested.

At the risk of being pedantic: glob match - not regexp. Also: you need to protect the pattern from the shell because you want it expanded inside the tool - not outside.

In any case: my tests passed too - so I will go ahead and push the fix. At that point, your script should work as expected, with or without escaping the spaces.

Henry

henry2cox commented 1 year ago

fixed in sha 09a3b7ede3f0, I believe

henry2cox commented 1 year ago

I think that this one is fixed - so closing now.

If there is still a problem, please either reopen this issue or file a new one. Please include a detailed description of the problem and include a testcase which illustrates the issue if at all possible. Thanks Henry