Commit 93cf8156b0c356be988edf4c2d22e153be9b2792

Authored by Jay Berkenbilt
1 parent d8f64a8a

Add ENABLE_COVERAGE option to build

CMakeLists.txt
... ... @@ -72,6 +72,7 @@ CMAKE_DEPENDENT_OPTION(
72 72 BUILD_DOC_DIST "Create distribution of manual" ON
73 73 "BUILD_DOC_PDF;BUILD_DOC_HTML" OFF)
74 74  
  75 +option(ENABLE_COVERAGE "Enable coverage reporting" OFF)
75 76 option(BUILD_SHARED_LIBS "Build qpdf shared libraries" ON)
76 77 option(BUILD_STATIC_LIBS "Build qpdf static libraries" ON)
77 78 option(QTEST_COLOR "Whether qtest's output should be in color" ON)
... ... @@ -296,6 +297,11 @@ set(CPACK_RESOURCE_FILE_LICENSE "${qpdf_SOURCE_DIR}/LICENSE.txt")
296 297 set(CPACK_PACKAGE_HOMEPAGE_URL "https://qpdf.sourceforge.io/")
297 298 set(CPACK_NSIS_MUI_ICON "${qpdf_SOURCE_DIR}/logo/qpdf.ico")
298 299  
  300 +if(ENABLE_COVERAGE)
  301 + add_compile_options(--coverage -O0)
  302 + add_link_options(--coverage)
  303 +endif()
  304 +
299 305 include(CPack)
300 306  
301 307 # Install components -- documented in _installation in
... ...
ChangeLog
  1 +2024-02-17 Jay Berkenbilt <ejb@ql.org>
  2 +
  3 + * Add ENABLE_COVERAGE cmake option to assist with generating
  4 + coverage reports.
  5 +
  6 + * From M. Holger: add QPDFObjectHandle::writeJSON to directly
  7 + write a JSON representation to a pipeline. This is much faster
  8 + than writing the serialized result of getJSON.
  9 +
1 10 2024-02-11 Jay Berkenbilt <ejb@ql.org>
2 11  
3 12 * The previous fix to #1056 was incomplete. When setting a check
... ...
README-maintainer.md
... ... @@ -25,19 +25,19 @@
25 25  
26 26 **Remember to check pull requests as well as issues in github.**
27 27  
  28 +Include `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` with cmake if using emacs lsp mode.
  29 +
28 30 Default:
29 31  
30 32 ```
31   -cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
32   - -DMAINTAINER_MODE=ON -DBUILD_STATIC_LIBS=OFF \
  33 +cmake -DMAINTAINER_MODE=ON -DBUILD_STATIC_LIBS=OFF \
33 34 -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
34 35 ```
35 36  
36 37 Debugging:
37 38  
38 39 ```
39   -cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
40   - -DMAINTAINER_MODE=ON -DBUILD_SHARED_LIBS=OFF \
  40 +cmake -DMAINTAINER_MODE=ON -DBUILD_SHARED_LIBS=OFF \
41 41 -DCMAKE_BUILD_TYPE=Debug ..
42 42 ```
43 43  
... ... @@ -45,13 +45,26 @@ Profiling:
45 45  
46 46 ```
47 47 CFLAGS=-pg LDFLAGS=-pg \
48   - cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
49   - -DMAINTAINER_MODE=ON -DBUILD_SHARED_LIBS=OFF \
  48 + cmake -DMAINTAINER_MODE=ON -DBUILD_SHARED_LIBS=OFF \
50 49 -DCMAKE_BUILD_TYPE=Debug ..
51 50 ```
52 51  
53 52 Then run `gprof gmon.out`. Note that gmon.out is not cumulative.
54 53  
  54 +Coverage:
  55 +
  56 +```
  57 +cmake -DMAINTAINER_MODE=ON -DBUILD_SHARED_LIBS=OFF \
  58 + -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON..
  59 +```
  60 +
  61 +Then, from the build directory, run the test suite (`ctest --verbose`) followed by
  62 +```
  63 +gcovr -r .. --html --html-details -o coverage-report.html
  64 +```
  65 +
  66 +Note that, in early 2024, branch coverage information is not very accurate with C++.
  67 +
55 68 Memory checks:
56 69  
57 70 ```
... ... @@ -59,8 +72,7 @@ CFLAGS=&quot;-fsanitize=address -fsanitize=undefined&quot; \
59 72 CXXFLAGS="-fsanitize=address -fsanitize=undefined" \
60 73 LDFLAGS="-fsanitize=address -fsanitize=undefined" \
61 74 CC=clang CXX=clang++ \
62   - cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
63   - -DMAINTAINER_MODE=ON -DBUILD_SHARED_LIBS=OFF \
  75 + cmake -DMAINTAINER_MODE=ON -DBUILD_SHARED_LIBS=OFF \
64 76 -DCMAKE_BUILD_TYPE=Debug ..
65 77 ```
66 78  
... ... @@ -691,8 +703,7 @@ export QPDF_BUILD_LIBDIR=$QPDF_SOURCE_TREE/build/libqpdf
691 703 export LD_LIBRARY_PATH=$QPDF_BUILD_LIBDIR
692 704 cd qpdf
693 705 mkdir build
694   -cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
695   - -DMAINTAINER_MODE=ON -DBUILD_STATIC_LIBS=OFF \
  706 +cmake -B build -DMAINTAINER_MODE=ON -DBUILD_STATIC_LIBS=OFF \
696 707 -DCMAKE_BUILD_TYPE=RelWithDebInfo
697 708 cat <<'EOF'
698 709 #!/bin/bash
... ...
job.sums
1 1 # Generated by generate_auto_job
2   -CMakeLists.txt f53d67f8c6ace1a2fb63dd9a963ead6b5cd698556f9d0adef2c10744a565b54f
  2 +CMakeLists.txt 9bfd82a7d225b88760ff5af211f9af35a0d9fcdd40fa15fdf7fc820944c2d5f9
3 3 generate_auto_job f64733b79dcee5a0e3e8ccc6976448e8ddf0e8b6529987a66a7d3ab2ebc10a86
4 4 include/qpdf/auto_job_c_att.hh 4c2b171ea00531db54720bf49a43f8b34481586ae7fb6cbf225099ee42bc5bb4
5 5 include/qpdf/auto_job_c_copy_att.hh 50609012bff14fd82f0649185940d617d05d530cdc522185c7f3920a561ccb42
... ...
manual/installation.rst
... ... @@ -302,6 +302,10 @@ CHECK_SIZES
302 302 that ensures an exact match between classes in ``sizes.cc`` and
303 303 classes in the library's public API. This option requires Python 3.
304 304  
  305 +ENABLE_COVERAGE
  306 + Compile with ``--coverage``. See README-maintainer.md for
  307 + information about generating coverage reports.
  308 +
305 309 ENABLE_QTC
306 310 This is off by default, except in maintainer mode. When off,
307 311 ``QTC::TC`` calls are compiled out by having ``QTC::TC`` be an empty
... ...
manual/release-notes.rst
... ... @@ -60,6 +60,10 @@ Planned changes for future 12.x (subject to change):
60 60 - Add ``file()``, ``range()``, and ``password()`` to
61 61 ``QPDFJob::PagesConfig`` as an alternative to ``pageSpec``.
62 62  
  63 + - Add ``QPDFObjectHandle::writeJSON`` to write the JSON
  64 + representation of the object directly to a pipeline. This is
  65 + much faster than calling ``QPDFObjectHandle::getJSON``.
  66 +
63 67 11.8.0: January 8, 2024
64 68 - Bug fixes:
65 69  
... ...