Skip to content

Make test options dependent on ZLIB_ENABLE_TESTS#1933

Merged
Dead2 merged 1 commit intozlib-ng:developfrom
ccawley2011:cmake-dependent-options
Jul 28, 2025
Merged

Make test options dependent on ZLIB_ENABLE_TESTS#1933
Dead2 merged 1 commit intozlib-ng:developfrom
ccawley2011:cmake-dependent-options

Conversation

@ccawley2011
Copy link
Copy Markdown
Contributor

@ccawley2011 ccawley2011 commented Jul 11, 2025

Previously, building with -DZLIB_ENABLE_TESTS=OFF would still check for a C++ compiler unless -DWITH_GTEST=OFF was also supplied, even though it wouldn't be used.

Summary by CodeRabbit

  • Chores
    • Centralized all test-related build options under a single main option for enabling tests.
    • Sub-options for specific tests and benchmarks are now only available when tests are enabled, simplifying configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jul 11, 2025

Walkthrough

The CMake configuration was updated to introduce a new top-level option, ZLIB_ENABLE_TESTS, which now controls all test-related build options. Existing test and benchmark options were redefined as dependent on this flag using cmake_dependent_option, and redundant or relocated option declarations were removed.

Changes

File(s) Change Summary
CMakeLists.txt Added ZLIB_ENABLE_TESTS as a top-level option; converted test/benchmark options to depend on it; removed and relocated redundant option declarations.

Suggested labels

Build Env

Suggested reviewers

  • Dead2
  • nmoinvaz
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
CMakeLists.txt (1)

50-57: Dependency chain looks solid; consider exposing WITH_BENCHMARK_APPS in the CXX-enable guard for completeness

The new cmake_dependent_option statements correctly gate all test-related knobs behind ZLIB_ENABLE_TESTS, eliminating the spurious C++ compiler probe when tests are disabled – nice fix.

One tiny polish item: WITH_BENCHMARK_APPS can only become ON when WITH_BENCHMARKS is also ON, but it might still be worth including it in the guard that decides whether to call enable_language(CXX) (line 58) for symmetry with the feature list below. This keeps the intent obvious if someone ever relaxes that dependency later.

- if(WITH_GTEST OR WITH_FUZZERS OR WITH_BENCHMARKS)
+ if(WITH_GTEST OR WITH_FUZZERS OR WITH_BENCHMARKS OR WITH_BENCHMARK_APPS)
   enable_language(CXX)
 endif()

No functional change today, just a future-proof touch.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f891bd3 and d6941ee.

📒 Files selected for processing (1)
  • CMakeLists.txt (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: pps83
PR: zlib-ng/zlib-ng#0
File: :0-0
Timestamp: 2025-01-13T18:28:11.751Z
Learning: In zlib-ng, removing preprocessor guards (like HAVE_*) should be described as removing unused conditional compilation checks rather than removing functionality, as the underlying implementation often remains intact.
Learnt from: mtl1979
PR: zlib-ng/zlib-ng#1925
File: arch/loongarch/lasxintrin_ext.h:38-65
Timestamp: 2025-07-04T16:59:44.683Z
Learning: In zlib-ng, the policy for supporting old compilers is to maintain compatibility for up to two years after GitHub removes support for them in CI, or when there is no long-time contributor left testing for the architecture if the architecture was not supported by GitHub Actions at all.
Learnt from: mtl1979
PR: zlib-ng/zlib-ng#1904
File: arch/riscv/Makefile.in:12-14
Timestamp: 2025-04-15T09:20:52.333Z
Learning: Optional feature flags in Makefile.in templates should default to empty strings. The configure script should detect feature support and update these variables accordingly during the configuration process.
CMakeLists.txt (4)
Learnt from: pps83
PR: zlib-ng/zlib-ng#0
File: :0-0
Timestamp: 2025-01-13T18:28:11.751Z
Learning: In zlib-ng, removing preprocessor guards (like HAVE_*) should be described as removing unused conditional compilation checks rather than removing functionality, as the underlying implementation often remains intact.
Learnt from: mtl1979
PR: zlib-ng/zlib-ng#1925
File: arch/loongarch/lasxintrin_ext.h:38-65
Timestamp: 2025-07-04T16:59:44.683Z
Learning: In zlib-ng, the policy for supporting old compilers is to maintain compatibility for up to two years after GitHub removes support for them in CI, or when there is no long-time contributor left testing for the architecture if the architecture was not supported by GitHub Actions at all.
Learnt from: mtl1979
PR: zlib-ng/zlib-ng#1904
File: arch/riscv/Makefile.in:12-14
Timestamp: 2025-04-15T09:20:52.333Z
Learning: Optional feature flags in Makefile.in templates should default to empty strings. The configure script should detect feature support and update these variables accordingly during the configuration process.
Learnt from: KungFuJesus
PR: zlib-ng/zlib-ng#1872
File: arch/x86/chorba_sse2.c:0-0
Timestamp: 2025-02-18T02:53:23.621Z
Learning: In zlib-ng, when macro names and parameters are self-explanatory and scalar versions of the code provide context, additional documentation for the macros may not be necessary.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (60)
  • GitHub Check: Windows GCC Native Instructions (AVX)
  • GitHub Check: macOS Clang Native Instructions (ARM64)
  • GitHub Check: Windows MSVC 2022 v142 Win32
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: Ubuntu GCC Native Instructions (AVX)
  • GitHub Check: macOS GCC Symbol Prefix
  • GitHub Check: Windows GCC Native Instructions (AVX)
  • GitHub Check: macOS Clang Native Instructions (ARM64)
  • GitHub Check: Windows MSVC 2022 v142 Win32
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: Ubuntu GCC Native Instructions (AVX)
  • GitHub Check: macOS GCC Symbol Prefix
  • GitHub Check: Windows GCC Native Instructions (AVX)
  • GitHub Check: macOS Clang Native Instructions (ARM64)
  • GitHub Check: Windows MSVC 2022 v142 Win32
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: Ubuntu GCC Native Instructions (AVX)
  • GitHub Check: macOS GCC Symbol Prefix
  • GitHub Check: Windows GCC Native Instructions (AVX)
  • GitHub Check: macOS Clang Native Instructions (ARM64)
  • GitHub Check: Windows MSVC 2022 v142 Win32
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: Ubuntu GCC Native Instructions (AVX)
  • GitHub Check: macOS GCC Symbol Prefix
  • GitHub Check: Windows GCC Native Instructions (AVX)
  • GitHub Check: macOS Clang Native Instructions (ARM64)
  • GitHub Check: Windows MSVC 2022 v142 Win32
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: Ubuntu GCC Native Instructions (AVX)
  • GitHub Check: macOS GCC Symbol Prefix
  • GitHub Check: Windows GCC Native Instructions (AVX)
  • GitHub Check: macOS Clang Native Instructions (ARM64)
  • GitHub Check: Windows MSVC 2022 v142 Win32
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: Ubuntu GCC Native Instructions (AVX)
  • GitHub Check: macOS GCC Symbol Prefix
  • GitHub Check: Windows GCC Native Instructions (AVX)
  • GitHub Check: macOS Clang Native Instructions (ARM64)
  • GitHub Check: Windows MSVC 2022 v142 Win32
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: Ubuntu GCC Native Instructions (AVX)
  • GitHub Check: macOS GCC Symbol Prefix
  • GitHub Check: Windows GCC Native Instructions (AVX)
  • GitHub Check: macOS Clang Native Instructions (ARM64)
  • GitHub Check: Windows MSVC 2022 v142 Win32
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: Ubuntu GCC Native Instructions (AVX)
  • GitHub Check: macOS GCC Symbol Prefix
  • GitHub Check: Windows GCC Native Instructions (AVX)
  • GitHub Check: macOS Clang Native Instructions (ARM64)
  • GitHub Check: Windows MSVC 2022 v142 Win32
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: Ubuntu GCC Native Instructions (AVX)
  • GitHub Check: macOS GCC Symbol Prefix
  • GitHub Check: Windows GCC Native Instructions (AVX)
  • GitHub Check: macOS Clang Native Instructions (ARM64)
  • GitHub Check: Windows MSVC 2022 v142 Win32
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: Ubuntu GCC Native Instructions (AVX)
  • GitHub Check: macOS GCC Symbol Prefix

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.66%. Comparing base (f891bd3) to head (d6941ee).
⚠️ Report is 22 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #1933       +/-   ##
============================================
+ Coverage    39.39%   81.66%   +42.27%     
============================================
  Files           74      150       +76     
  Lines         7885    13618     +5733     
  Branches      1303     3052     +1749     
============================================
+ Hits          3106    11121     +8015     
+ Misses        4536     1521     -3015     
- Partials       243      976      +733     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@Dead2 Dead2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Dead2 Dead2 merged commit a5f3388 into zlib-ng:develop Jul 28, 2025
146 checks passed
@ccawley2011 ccawley2011 deleted the cmake-dependent-options branch July 28, 2025 18:38
@Dead2 Dead2 mentioned this pull request Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants