pboettch / json-schema-validator

JSON schema validator for JSON for Modern C++
Other
464 stars 133 forks source link

gcovr is confused by smtp-address-validator.cpp #283

Closed serge-s closed 9 months ago

serge-s commented 10 months ago

gcovr provides a utility for managing the use of the GNU gcov utility and generating summarized code coverage results.

Repro steps:

build the library with tests & code coverage enabled

cmake . -Bbuild -DJSON_VALIDATOR_BUILD_TESTS=ON -DJSON_VALIDATOR_TEST_COVERAGE=ON cmake --build ./build

run tests to produce coverage results

cmake --build ./build --target test

run gcovr to produce human-readable results

/usr/bin/gcovr --object-directory=build -r .

this generates multiple warnings:

(WARNING) GCOV produced the following errors processing json-schema-validator/build/CMakeFiles/nlohmann_json_schema_validator.dir/src/smtp-address-validator.cpp.gcda:
        Cannot open source file smtp-address-validator.rl
Cannot open source file smtp-address-validator.cpp

        Cannot open source file smtp-address-validator.rl
Cannot open source file smtp-address-validator.cpp

        Cannot open source file smtp-address-validator.rl
Cannot open source file smtp-address-validator.cpp

        (gcovr could not infer a working directory that resolved it.)

Possible root cause:

gcovr is confused by the '#line' entries in src/smtp-address-validator.cpp - at least removing them makes the warning go away.

pboettch commented 10 months ago

This file was important. Go ahead and do a PR which fixes it.

And are you going to share your coverage work?

serge-s commented 10 months ago

This file was important. Go ahead and do a PR which fixes it.

https://github.com/pboettch/json-schema-validator/pull/284

And are you going to share your coverage work?

I haven't done any coverage work on the library itself - faced this issue when I was trying to enable coverage for my code that uses json-schema-validator and faced gcovr errors. I did notice some irregularities with the json-schema-validator tests though which I will try to address separately.