Skip to content

Test that close() leaves every reason as it was and sends nothing more - #33

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/test-what-close-leaves-behind
Nov 13, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/test-what-close-leaves-behind

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • Adds closeLeavesTheReasonAsItWasAndSendsNothingMore to test/test_trace_client.cpp, which is a Stage B (unit-test expansion) cycle with no production change.
  • The README ("Turning it off") promises that disabledReason() is unchanged by close(). Until now this was asserted only for a client that was reporting (closeIsPromptAndIdempotent). The new test asserts it for every disabled reason (config via enabled = false and via the default constructor, no key, unavailable, environment). For environment, the opt-out variable is cleared before close(), so a close() that looked at the environment again would be caught.
  • The report("after-close") call in closeIsPromptAndIdempotent was never checked against what the server received. The new test checks that reports made after close() (both overloads, on enabled and disabled clients) never reach the stub server, and that a second close() is still a no-op.

No tracking issue. The gap was found during triage. Both open issues were skipped because each needs an owner decision: #21 (version tag vs. the 32-tag cap, a wire-level choice shared with the sibling clients) and #1 (TRACE_CLIENT_CURL on Windows, which touches the do-not-auto-merge curl.exe lookup). A Stage A documentation sweep was run first. Every README number, opt-out value, disabled reason, curl option, the User-Agent string and the Building/CI description matched the code, so no docs PR was opened.

Test plan

  • make test (g++, C++11, -Werror): 76 tests, 0 failed checks (75 before; the one new test is registered in tests[])
  • make test with -std=c++17: 76 tests, 0 failed checks
  • Mutation check: a temporary reason_ = REASON_CONFIG; at the top of close() made the new test fail 4 times (the reporting client, no key, unavailable, environment). The existing test caught only the reporting-client case. The header was then restored.
  • CI: linux (g++/clang++ × c++11/17/20), linux-libcurl, linux-sanitizers, macos, windows

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

The README promises disabledReason() is unchanged by close(), but only a
client that was reporting had that asserted, and the report made after
close() in closeIsPromptAndIdempotent was never checked against what the
server received. Assert both, for each disabled reason too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (head 62929ed):

  • Scope: PASS. Only test/test_trace_client.cpp is modified: one new test function and its tests[] entry, with no churn elsewhere.
  • Tests-new: PASS (not applicable). No public method or function was added.
  • Tests-fix: not applicable. This is a characterization test with no production fix. In its place, a mutation check was run: a temporary reason_ = REASON_CONFIG; in close() made the new test fail 4 times, against 1 for the existing closeIsPromptAndIdempotent. The header was then restored.
  • Sibling structure: PASS. The test is a static void function named as a sentence and uses StubServer, setEnv/cleanEnvironment and CHECK/CHECK_EQ like its neighbours.
  • Sibling renames: not applicable. Nothing was renamed.
  • Docs: PASS. The test asserts an existing README promise ("disabledReason() is unchanged by close()"), and no doc changes are needed.
  • Issue resolution: not applicable. There is no Closes, and the PR body records the gap as found during triage.
  • CI: PASS. All 11 jobs are green on the head, including linux-sanitizers (thread; address,undefined), macos and windows.
  • Registered: PASS. closeLeavesTheReasonAsItWasAndSendsNothingMore occurs twice in the file, and the local run went from 75 to 76 tests with 0 failed checks.
  • C++11: PASS. make test (C++11, -Werror) built clean locally, and the linux c++11 legs are green.
  • No new dependency / Never throws / Curl argv fixed / Version triple: PASS. trace_client.hpp, Makefile and CMakeLists.txt are untouched.
  • Sanitizers: PASS. Both sanitizer jobs are green.

Judgment notes (not blocking):

  • test/test_trace_client.cpp:1285: the unnamed and nothing clients partly overlap with disabledClientSendsNothing. They were kept so that every REASON_* value, and both ways of getting config, are checked after close() in one place.
  • test/test_trace_client.cpp:1302: the 200 ms sleep before the final count matches disabledClientSendsNothing. The enabled client's sender thread has already been joined by close(), so the count does not depend on the sleep for that client.

All rubric items pass, which is suspicious on its face. The diff, however, is test-only, and the mutation check provides an external signal that the new assertions bite.

This review comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 1207e47 into main Nov 13, 2026
11 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/test-what-close-leaves-behind branch November 13, 2026 04:04
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.

1 participant