Skip to content

Warnings in tests are errors#7951

Merged
achamayou merged 9 commits into
microsoft:mainfrom
eddyashton:warnings_in_tests_are_errors
Jun 19, 2026
Merged

Warnings in tests are errors#7951
achamayou merged 9 commits into
microsoft:mainfrom
eddyashton:warnings_in_tests_are_errors

Conversation

@eddyashton

Copy link
Copy Markdown
Member

These changes are pristine, unseen, unsullied by human eyes. They exist beyond a quality assessment. I wrote this as a joke and then scrolled down a little and realised this include diffs from a totally different PR! Oh well, I'll deal with that tomorrow.

@eddyashton eddyashton requested a review from a team as a code owner June 17, 2026 16:06
Copilot AI review requested due to automatic review settings June 17, 2026 16:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make warnings in CCF’s C++ unit tests fail the build (treat warnings as errors) by enabling stricter compiler warning flags for unit-test targets and then updating a broad set of tests (plus a few supporting headers) to eliminate common warning sources (unused variables, signed/unsigned mismatches, unsafe strerror, VLAs, etc).

Changes:

  • Enable warning/error compile flags for unit test targets via CMake (add_warning_checks).
  • Introduce and adopt a thread-safe ccf::nonstd::strerror() wrapper to replace concurrency-unsafe std::strerror.
  • Refactor many tests to avoid warnings (unused variables, narrowing, shadowing, unused captures, designated init completeness, etc).

Custom instructions used:

  • .github/copilot-instructions.md
  • .github/instructions/reviewing.instructions.md

Reviewed changes

Copilot reviewed 46 out of 46 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/tls/test/main.cpp Replace strerror, remove VLAs, tighten test buffer handling
src/tasks/test/fan_in_tasks.cpp Fix signed/unsigned loop variable warnings
src/tasks/test/demo/clients.h Fix signed/unsigned / implicit conversion warnings
src/tasks/test/basic_tasks.cpp Remove unused WaitPoint variables
src/snapshots/snapshot_manager.h Use thread-safe ccf::nonstd::strerror in error paths
src/pal/test/snp_attestation_validation.cpp Fill designated initializers to silence warnings
src/node/test/snapshotter.cpp Update aggregate init / naming to avoid warnings
src/node/test/snapshot.cpp Rename to avoid shadowing/unused warnings
src/node/test/node_info_json.cpp Expand initializer to match updated struct layout
src/node/test/network_identity_subsystem.cpp Silence nodiscard/unused-result warnings in throw checks
src/node/test/historical_queries.cpp Remove unused locals/lambdas; rename loop vars
src/node/test/encryptor.cpp Assert commit result rather than unused variable
src/node/test/channels.cpp Remove unused locals; adjust switches/loop vars
src/node/rpc/test/tx_status_test.cpp Remove unused constants
src/node/rpc/test/node_frontend_test.cpp Rename locals; adjust status expectations (test logic)
src/node/rpc/test/frontend_test.cpp Remove unused lambda captures; rename locals
src/node/rpc/test/frontend_test_infra.h Rename locals to avoid shadowing/unreferenced warnings
src/kv/test/kv_test.cpp Remove unused locals; rename variables; fix switch completeness
src/kv/test/kv_snapshot.cpp Remove unused locals; rename constants/handles; reduce unused vars
src/kv/test/kv_dynamic_tables.cpp Remove unused handle variable
src/kv/test/kv_contention.cpp Rename loop variables to avoid shadowing and warnings
src/indexing/test/lfs.cpp Fix signed/unsigned loops; remove unused constant
src/indexing/test/indexing.cpp Remove unused constants/aliases
src/host/test/ledger.cpp Add [[maybe_unused]], fix loop index types, rename locals
src/host/tcp.h Replace std::strerror with ccf::nonstd::strerror
src/host/ledger.h Replace std::strerror with ccf::nonstd::strerror
src/endpoints/test/endpoint_registry.cpp Rename locals to avoid unused/shadowing warnings
src/ds/test/work_beacon.cpp Fix loop index types to avoid sign warnings
src/ds/test/serializer.cpp Mark unused helper; rename locals to avoid shadowing
src/ds/test/ring_buffer.cpp Fix loop types; remove unused captures; fix implicit conversions
src/ds/test/oversized.cpp Rename variables to avoid shadowing/unused warnings
src/ds/test/nonstd.cpp Rename locals to avoid shadowing/unused warnings
src/ds/test/messaging.cpp Fix incorrect unconditional REQUIRE; remove unused lambda/vars
src/ds/test/map_test.cpp Rename locals to avoid shadowing; fix index warnings
src/ds/test/json_schema.cpp Avoid reference-to-temporary warnings / adjust loop var
src/ds/test/dl_list.cpp Fully initialize aggregate to avoid missing-field warnings
src/ds/system.h Replace strerror with ccf::nonstd::strerror
src/ds/files.h Replace strerror with ccf::nonstd::strerror in file helpers
src/crypto/test/crypto.cpp Rename locals, fix loop index types, avoid shadowing
src/consensus/aft/test/main.cpp Remove redundant locals; fix loop/index conversions; simplify lambda captures
src/consensus/aft/test/logging_stub.h Add virtual destructors; mark unused; avoid unused-result warnings
src/consensus/aft/test/committable_suffix.cpp Fix implicit conversion warnings from rand() result
include/ccf/pal/snp_ioctl6.h Replace strerror with nonstd::strerror
include/ccf/ds/nonstd.h Add thread-safe strerror wrapper implementation
include/ccf/ds/contiguous_set.h Fix narrowing/sign conversion warnings; remove unused local
cmake/common.cmake Apply add_warning_checks() to unit-test targets

Comment thread include/ccf/ds/nonstd.h
Comment thread src/node/rpc/test/node_frontend_test.cpp
Comment thread src/node/test/channels.cpp Outdated
@achamayou achamayou added this to the 7.0.6 milestone Jun 17, 2026
@achamayou achamayou enabled auto-merge (squash) June 19, 2026 10:44
@achamayou achamayou merged commit 8e4d1ba into microsoft:main Jun 19, 2026
26 checks passed
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.

3 participants