Copilot commented on code in PR #13862:
URL: https://github.com/apache/trafficserver/pull/13862#discussion_r4335013208


##########
include/tscore/ArgParser.h:
##########
@@ -364,6 +394,14 @@ class ArgParser
   // Enable test mode - makes do_exit() throw instead of calling exit() for 
unit testing
   static void set_test_mode(bool test = true);
 
+  /** Clear the parser-wide state held at file scope in ArgParser.cc.
+
+      Test-only. A program builds one parser and never reuses the state, but a 
unit test binary
+      runs many parsers in sequence, and set_default_command() or 
Command::set_default() would
+      otherwise leak default_command into every later test.
+  */
+  static void reset_global_state();

Review Comment:
   `reset_global_state()` is described as “Test-only” but is added to the 
public API surface in a widely included header. If this is strictly for unit 
tests (as the docstring indicates), consider keeping it non-public (e.g., 
`protected` + a test-only derived “Access” helper as already done in 
`test_ArgParser.cc`), or gating its declaration/definition behind a test build 
macro. This avoids unintentionally supporting a production dependency on a 
function that mutates global parser state and reduces the risk of external 
callers relying on it long-term.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to