codecraftai-testbase 1.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. ccai/factories/py.typed +0 -0
  2. ccai/factories/testbasedefaulttypefactory.py +25 -0
  3. ccai/testbase/__init__.py +63 -0
  4. ccai/testbase/breakpoints.py +110 -0
  5. ccai/testbase/cli/__init__.py +13 -0
  6. ccai/testbase/cli/cmdtree/agents/__init__.py +28 -0
  7. ccai/testbase/cli/cmdtree/agents/config/__init__.py +24 -0
  8. ccai/testbase/cli/cmdtree/agents/config/extract.py +94 -0
  9. ccai/testbase/cli/cmdtree/agents/formatting.py +71 -0
  10. ccai/testbase/cli/cmdtree/agents/jsosparser.py +119 -0
  11. ccai/testbase/cli/cmdtree/agents/pathresolver.py +34 -0
  12. ccai/testbase/cli/cmdtree/agents/summary/__init__.py +26 -0
  13. ccai/testbase/cli/cmdtree/agents/summary/compare.py +128 -0
  14. ccai/testbase/cli/cmdtree/agents/summary/extract.py +91 -0
  15. ccai/testbase/cli/cmdtree/agents/testresult/__init__.py +28 -0
  16. ccai/testbase/cli/cmdtree/agents/testresult/extract.py +77 -0
  17. ccai/testbase/cli/cmdtree/agents/testresult/failures.py +73 -0
  18. ccai/testbase/cli/cmdtree/agents/testresult/list.py +63 -0
  19. ccai/testbase/cli/cmdtree/services/__init__.py +27 -0
  20. ccai/testbase/cli/cmdtree/services/results.py +66 -0
  21. ccai/testbase/cli/cmdtree/testing/__init__.py +30 -0
  22. ccai/testbase/cli/cmdtree/testing/jobs.py +175 -0
  23. ccai/testbase/cli/cmdtree/testing/query.py +131 -0
  24. ccai/testbase/cli/cmdtree/testing/run.py +263 -0
  25. ccai/testbase/cli/cmdtree/utilities/__init__.py +28 -0
  26. ccai/testbase/cli/cmdtree/utilities/timestamp.py +33 -0
  27. ccai/testbase/cli/options.py +370 -0
  28. ccai/testbase/cli/testbase_command.py +64 -0
  29. ccai/testbase/cli/utilities.py +31 -0
  30. ccai/testbase/configuration.py +324 -0
  31. ccai/testbase/constraints.py +998 -0
  32. ccai/testbase/coupling/__init__.py +569 -0
  33. ccai/testbase/coupling/basecoupling.py +69 -0
  34. ccai/testbase/coupling/configurationcoupling.py +138 -0
  35. ccai/testbase/coupling/integrationcoupling.py +842 -0
  36. ccai/testbase/coupling/validatorcoupling.py +127 -0
  37. ccai/testbase/debuggingext.py +281 -0
  38. ccai/testbase/debuglogging.py +407 -0
  39. ccai/testbase/debugports.py +469 -0
  40. ccai/testbase/declaration/__init__.py +13 -0
  41. ccai/testbase/declaration/attachments.py +222 -0
  42. ccai/testbase/declaration/originations.py +217 -0
  43. ccai/testbase/declaration/parameterization.py +160 -0
  44. ccai/testbase/declaration/registrations.py +476 -0
  45. ccai/testbase/diagnostic_level.py +197 -0
  46. ccai/testbase/diagnostic_streaming.py +1534 -0
  47. ccai/testbase/diagnostics.py +1685 -0
  48. ccai/testbase/entrypoints.py +485 -0
  49. ccai/testbase/environment.py +162 -0
  50. ccai/testbase/errors/testruntimeouterror.py +50 -0
  51. ccai/testbase/expressions.py +355 -0
  52. ccai/testbase/factories.py +277 -0
  53. ccai/testbase/factoryprotocols.py +35 -0
  54. ccai/testbase/features.py +913 -0
  55. ccai/testbase/initialize.py +210 -0
  56. ccai/testbase/injection/__init__.py +25 -0
  57. ccai/testbase/injection/injectiongroup.py +493 -0
  58. ccai/testbase/injection/injectionmoment.py +155 -0
  59. ccai/testbase/injection/injectionregistry.py +823 -0
  60. ccai/testbase/injection/injectionscope.py +2589 -0
  61. ccai/testbase/injection/introspection.py +514 -0
  62. ccai/testbase/markers.py +665 -0
  63. ccai/testbase/mocking.py +4856 -0
  64. ccai/testbase/origins/__init__.py +13 -0
  65. ccai/testbase/origins/resourceorigin.py +110 -0
  66. ccai/testbase/origins/validatororigin.py +111 -0
  67. ccai/testbase/output/__init__.py +17 -0
  68. ccai/testbase/output/outputcontext.py +201 -0
  69. ccai/testbase/output/runmetadata.py +184 -0
  70. ccai/testbase/properties/__init__.py +40 -0
  71. ccai/testbase/properties/assumptions.py +56 -0
  72. ccai/testbase/properties/decorators.py +173 -0
  73. ccai/testbase/properties/propertyrunner.py +449 -0
  74. ccai/testbase/properties/strategies.py +1592 -0
  75. ccai/testbase/properties/unittestsupport.py +87 -0
  76. ccai/testbase/py.typed +0 -0
  77. ccai/testbase/queries.py +95 -0
  78. ccai/testbase/resourcelifespan.py +24 -0
  79. ccai/testbase/results/__init__.py +35 -0
  80. ccai/testbase/results/exceptions.py +60 -0
  81. ccai/testbase/results/filtering/__init__.py +26 -0
  82. ccai/testbase/results/filtering/resultfilter.py +570 -0
  83. ccai/testbase/results/model/__init__.py +32 -0
  84. ccai/testbase/results/model/buildinfo.py +54 -0
  85. ccai/testbase/results/model/checkresult.py +183 -0
  86. ccai/testbase/results/model/forwardinginfo.py +30 -0
  87. ccai/testbase/results/model/jobcontainer.py +32 -0
  88. ccai/testbase/results/model/jobinfo.py +91 -0
  89. ccai/testbase/results/model/nestedprogressinfo.py +211 -0
  90. ccai/testbase/results/model/pipelineinfo.py +51 -0
  91. ccai/testbase/results/model/progressaggregator.py +551 -0
  92. ccai/testbase/results/model/progresscode.py +29 -0
  93. ccai/testbase/results/model/progressdelivery.py +51 -0
  94. ccai/testbase/results/model/progressinfo.py +84 -0
  95. ccai/testbase/results/model/progresstype.py +24 -0
  96. ccai/testbase/results/model/renderinfo.py +30 -0
  97. ccai/testbase/results/model/resultcode.py +28 -0
  98. ccai/testbase/results/model/resultcontainer.py +95 -0
  99. ccai/testbase/results/model/resultnode.py +258 -0
  100. ccai/testbase/results/model/resulttype.py +34 -0
  101. ccai/testbase/results/model/streaminginfo.py +111 -0
  102. ccai/testbase/results/model/taskinggroup.py +85 -0
  103. ccai/testbase/results/model/taskingresult.py +297 -0
  104. ccai/testbase/results/model/testcontainer.py +35 -0
  105. ccai/testbase/results/model/testresult.py +170 -0
  106. ccai/testbase/results/recorders/__init__.py +31 -0
  107. ccai/testbase/results/recorders/csvresultrecorder.py +414 -0
  108. ccai/testbase/results/recorders/jsonresultrecorder.py +467 -0
  109. ccai/testbase/results/recorders/resultrecorder.py +1472 -0
  110. ccai/testbase/results/recorders/stdoutresultrecorder.py +70 -0
  111. ccai/testbase/results/recorders/xmlresultrecorder.py +305 -0
  112. ccai/testbase/results/utilities.py +141 -0
  113. ccai/testbase/sequencing/__init__.py +13 -0
  114. ccai/testbase/sequencing/sequencermodulescope.py +96 -0
  115. ccai/testbase/sequencing/sequencerscopebase.py +91 -0
  116. ccai/testbase/sequencing/sequencersessionscope.py +84 -0
  117. ccai/testbase/sequencing/sequencertestscope.py +249 -0
  118. ccai/testbase/sequencing/sequencertestsetupscope.py +86 -0
  119. ccai/testbase/sequencing/testactivity.py +111 -0
  120. ccai/testbase/sequencing/testsequencer.py +3072 -0
  121. ccai/testbase/server/__init__.py +13 -0
  122. ccai/testbase/server/resultserver.py +599 -0
  123. ccai/testbase/sources/__init__.py +13 -0
  124. ccai/testbase/sources/configurationsource.py +32 -0
  125. ccai/testbase/sources/integrationsource.py +29 -0
  126. ccai/testbase/sources/resourcesource.py +27 -0
  127. ccai/testbase/sources/sourcebase.py +71 -0
  128. ccai/testbase/sources/unknownsource.py +30 -0
  129. ccai/testbase/sources/validatorsource.py +28 -0
  130. ccai/testbase/tandem/__init__.py +13 -0
  131. ccai/testbase/tandem/validators.py +286 -0
  132. ccai/testbase/testcollector.py +230 -0
  133. ccai/testbase/testgroup.py +54 -0
  134. ccai/testbase/testjob.py +600 -0
  135. ccai/testbase/testref.py +64 -0
  136. ccai/testbase/utilities.py +472 -0
  137. ccai/testbase/verification.py +768 -0
  138. codecraftai_testbase-1.3.0.dist-info/METADATA +99 -0
  139. codecraftai_testbase-1.3.0.dist-info/RECORD +142 -0
  140. codecraftai_testbase-1.3.0.dist-info/WHEEL +4 -0
  141. codecraftai_testbase-1.3.0.dist-info/entry_points.txt +3 -0
  142. codecraftai_testbase-1.3.0.dist-info/licenses/LICENSE.md +204 -0
@@ -0,0 +1,370 @@
1
+ """
2
+ .. module:: ccai.testbase.cli.options
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Module for reusable CLI option groups.
5
+
6
+ .. moduleauthor:: Myron Walker <myron.walker@gmail.com>
7
+
8
+ This module defines reusable CLI option groups for the TestBase framework.
9
+ Each option group encapsulates related command-line options that can be
10
+ composed into CLI commands.
11
+
12
+ The option groups include:
13
+
14
+ - **RootOptionGroup**: Options for specifying the test root directory
15
+ - **OutputOptionGroup**: Options for output directory and run identification
16
+ - **BuildOptionGroup**: Options for build metadata (branch, build, flavor)
17
+ - **JobOptionGroup**: Options for job identification and ownership
18
+ - **LoggingOptionGroup**: Options for console and file logging levels
19
+ - **DiagnosticOptionGroup**: Options for debugging and diagnostics
20
+ - **FilteringOptionGroup**: Options for test inclusion/exclusion filtering
21
+ - **DebugOptionGroup**: Options for debug output
22
+
23
+ Example Usage::
24
+
25
+ from ccai.testbase.cli.options import DiagnosticOptionGroup, RootOptionGroup
26
+
27
+ # Option groups are used in CLI command definitions
28
+ # to compose related options together
29
+
30
+ """
31
+
32
+ __author__ = "Myron Walker"
33
+ __copyright__ = "Copyright 2025, Code Craft AI LLC"
34
+ __credits__ = []
35
+
36
+ from ccai.arcli.model.optiongroup import OptionGroup
37
+ from ccai.arcli.model.fields.optionfield import OptionField, OptionMode
38
+ from ccai.arcli.model.parameters.validators import Choice
39
+ from ccai.arcli.model.parameters.booleanparameter import BooleanParameter
40
+ from ccai.xmodules.xlogging.levels import LOG_LEVEL_NAMES
41
+
42
+ HELP_ROOT = "The root directory to use when scanning for tests to {action}."
43
+ HELP_EXCLUDES = "Add a test exclusion expression for the {action}."
44
+ HELP_INCLUDES = "Add a test inclusion expression for the {action}."
45
+ HELP_OUTPUT = "The output directory where results and artifacts are collected."
46
+ HELP_START = r"A time stamp to associate with the start of the run. Example: 2020-10-17T15:30:11.989120 Bash: date +%Y-%m-%dT%H:%M:%S.%N"
47
+ HELP_BRANCH = "The name of the branch to associate with the test run results."
48
+ HELP_BUILD = "The name of the build to associate with the test run results."
49
+ HELP_FLAVOR = "The name of the flavor to associate with the test run results."
50
+ HELP_JOB_ID = "A unique identifier for the job with respect to the job runner."
51
+ HELP_JOB_INITIATOR = "The name of the initiator of the job."
52
+ HELP_JOB_LABEL = "The label associated with the job."
53
+ HELP_JOB_NAME = "The name of the job."
54
+ HELP_JOB_OWNER = "The ownerid and possibly appended ';(display name)' of the test run result owner."
55
+ HELP_JOB_SEED = "A seed value to associate with the job for reproducibility."
56
+ HELP_JOB_TAG = "A correlation tag to associate with the job."
57
+ HELP_RUNID = "A uuid to use for the run id for the testrun."
58
+ HELP_CONSOLE_LOG_LEVEL = "The logging level for console output."
59
+ HELP_FILE_LOG_LEVEL = "The logging level for logfile output."
60
+ HELP_DEBUG = "Output debug information to the console."
61
+ HELP_DEBUGGER = "Debugger to active during the test run."
62
+ HELP_BREAKPOINT = "The breakpoint to activate for the test run."
63
+ HELP_DEBUG_PORT = "The port to use for debugpy remote debugging. Default is 5678."
64
+ HELP_DEBUG_PORT_RANGE = "A port range for multiple debug sessions (e.g., '5678-5688'). When specified, the system will find an available port within the range."
65
+ HELP_DEBUG_LOG_LEVEL = "The logging level for debug events (debug, info, warning, error, disabled). Default is 'info'."
66
+ HELP_PRERUN_DIAGNOSTIC = "Flag indicating that a pre run diagnostic should be performed."
67
+ HELP_POSTRUN_DIAGNOSTIC = "Flag indicating that a post run diagnostic should be performed."
68
+ HELP_DIAGNOSTIC_LEVEL = "The diagnostic level (1-9) controlling verbosity. Levels 1-3: basic, 4-6: standard, 7-9: detailed. Default is 9."
69
+ HELP_INCLUDE_MARKER_EXP = "Allows the specification of a marker expression that if matched will include a test."
70
+ HELP_EXCLUDE_MARKER_EXP = "Allows the specification of a marker expression that if matched will exclude a test."
71
+ HELP_FILTER = "Add a job filter expression."
72
+ HELP_JOB = "The identifier of the job to {action}."
73
+ HELP_TIMEOUT = "The maximum duration in seconds for the test execution phase. When exceeded, the test run is terminated and remaining tests are marked as errored."
74
+
75
+
76
+ class RootOptionGroup(OptionGroup):
77
+ """
78
+ Option group for specifying the test root directory.
79
+
80
+ This group provides the ``--root`` option for specifying the directory
81
+ to scan for tests.
82
+
83
+ Attributes:
84
+ name (str): Group identifier, set to ``"root"``.
85
+ root (OptionField): The ``--root`` option for test directory specification.
86
+ """
87
+ name = "root"
88
+ root = OptionField("--root", default=None, required=False, help=HELP_ROOT)
89
+
90
+
91
+ class OutputOptionGroup(OptionGroup):
92
+ """
93
+ Option group for output directory and run identification.
94
+
95
+ This group provides options for specifying where test results and
96
+ artifacts are collected, along with run identification metadata.
97
+
98
+ Attributes:
99
+ name (str): Group identifier, set to ``"output"``.
100
+ output (OptionField): The ``-o``/``--output`` option for output directory.
101
+ start (OptionField): The ``--start`` option for run start timestamp.
102
+ runid (OptionField): The ``--runid`` option for unique run identifier.
103
+ """
104
+ name = "output"
105
+ output = OptionField("-o", "--output", default=None, required=False, help=HELP_OUTPUT)
106
+ start = OptionField("--start", default=None, required=False, help=HELP_START)
107
+ runid = OptionField("--runid", default=None, required=False, help=HELP_RUNID)
108
+
109
+
110
+ class BuildOptionGroup(OptionGroup):
111
+ """
112
+ Option group for build metadata.
113
+
114
+ This group provides options for associating build information with
115
+ test run results, useful for CI/CD integration.
116
+
117
+ Attributes:
118
+ name (str): Group identifier, set to ``"build"``.
119
+ branch (OptionField): The ``--branch`` option for source branch name.
120
+ build (OptionField): The ``--build`` option for build identifier.
121
+ flavor (OptionField): The ``--flavor`` option for build flavor/variant.
122
+ """
123
+ name = "build"
124
+ branch = OptionField("--branch", default=None, required=False, help=HELP_BRANCH)
125
+ build = OptionField("--build", default=None, required=False, help=HELP_BUILD)
126
+ flavor = OptionField("--flavor", default=None, required=False, help=HELP_FLAVOR)
127
+
128
+
129
+ class JobOptionGroup(OptionGroup):
130
+ """
131
+ Option group for job identification and ownership.
132
+
133
+ This group provides options for identifying and tracking test jobs,
134
+ including job ownership and labeling for organizational purposes.
135
+
136
+ Attributes:
137
+ name (str): Group identifier, set to ``"job"``.
138
+ job_id (OptionField): The ``--job-id`` option for unique job identifier.
139
+ job_initiator (OptionField): The ``--job-initiator`` option for who started the job.
140
+ job_label (OptionField): The ``--job-label`` option for job categorization.
141
+ job_name (OptionField): The ``--job-name`` option for human-readable job name.
142
+ job_owner (OptionField): The ``--job-owner`` option for job ownership.
143
+ job_seed (OptionField): The ``--job-seed`` option for job reproducibility seed.
144
+ job_tag (OptionField): The ``--job-tag`` option for job correlation tag.
145
+ """
146
+ name = "job"
147
+ job_id = OptionField("--job-id", default=None, required=False, help=HELP_JOB_ID)
148
+ job_initiator = OptionField("--job-initiator", default=None, required=False, help=HELP_JOB_INITIATOR)
149
+ job_label = OptionField("--job-label", default=None, required=False, help=HELP_JOB_LABEL)
150
+ job_name = OptionField("--job-name", default=None, required=False, help=HELP_JOB_NAME)
151
+ job_owner = OptionField("--job-owner", default=None, required=False, help=HELP_JOB_OWNER)
152
+ job_seed = OptionField("--job-seed", default=None, required=False, help=HELP_JOB_SEED)
153
+ job_tag = OptionField("--job-tag", default=None, required=False, help=HELP_JOB_TAG)
154
+
155
+
156
+ class LoggingOptionGroup(OptionGroup):
157
+ """
158
+ Option group for logging configuration.
159
+
160
+ This group provides options for controlling the verbosity of console
161
+ and file logging output during test execution.
162
+
163
+ Attributes:
164
+ name (str): Group identifier, set to ``"logging"``.
165
+ console_level (OptionField): The ``--console-level`` option for console log verbosity.
166
+ logfile_level (OptionField): The ``--logfile-level`` option for file log verbosity.
167
+ """
168
+ name = "logging"
169
+ console_level = OptionField("--console-level", default=None, required=False,
170
+ ptype=Choice(LOG_LEVEL_NAMES, case_sensitive=False), help=HELP_CONSOLE_LOG_LEVEL)
171
+ logfile_level = OptionField("--logfile-level", default=None, required=False,
172
+ ptype=Choice(LOG_LEVEL_NAMES, case_sensitive=False), help=HELP_FILE_LOG_LEVEL)
173
+
174
+
175
+ class DiagnosticOptionGroup(OptionGroup):
176
+ """
177
+ Option group for debugging and diagnostic options.
178
+
179
+ This group provides CLI options for controlling debugger behavior and
180
+ breakpoint activation during test execution. It enables developers to
181
+ pause test execution at well-known breakpoints using either the built-in
182
+ Python debugger (pdb) or the remote debugging protocol (debugpy) for
183
+ IDE integration.
184
+
185
+ When the ``--debugger`` option is specified, the system sets the
186
+ ``AM_DEBUG_DEBUGGER`` runtime variable. When ``--breakpoint`` is specified,
187
+ the system sets the ``AM_DEBUG_BREAKPOINTS`` runtime variable.
188
+
189
+ Attributes:
190
+ name (str): Group identifier, set to ``"diagnostic"``.
191
+ debugger (OptionField): The ``--debugger`` option for selecting the debugger backend.
192
+ Choices: ``'pdb'`` (local terminal debugging) or ``'debugpy'`` (remote/IDE debugging).
193
+ breakpoints (OptionField): The ``--breakpoint`` option for specifying breakpoints to activate.
194
+ Choices: ``'test-discovery'`` or ``'testrun-start'``. Supports multiple values.
195
+ debug_port (OptionField): The ``--debug-port`` option for specifying the debugpy port.
196
+ Default is 5678. Allows custom port configuration for remote debugging.
197
+ debug_port_range (OptionField): The ``--debug-port-range`` option for specifying a port range.
198
+ Format: 'start-end' (e.g., '5678-5688'). The system will find an available port.
199
+ debug_log_level (OptionField): The ``--debug-log-level`` option for controlling debug event logging.
200
+ Choices: ``'debug'``, ``'info'``, ``'warning'``, ``'error'``, ``'disabled'``. Default is 'info'.
201
+ prerun_diagnostic (OptionField): The ``--prerun-diagnostic`` flag for pre-run diagnostics.
202
+ postrun_diagnostic (OptionField): The ``--postrun-diagnostic`` flag for post-run diagnostics.
203
+ diagnostic_level (OptionField): The ``--diagnostic-level`` option for controlling diagnostic verbosity.
204
+ Integer value from 1-9. Levels 1-3: basic, 4-6: standard, 7-9: detailed. Default is 9.
205
+
206
+ Example CLI Usage::
207
+
208
+ # Enable testrun-start breakpoint with pdb (terminal debugging)
209
+ testbase testing run --root ./tests --debugger pdb --breakpoint testrun-start
210
+
211
+ # Enable testrun-start breakpoint with debugpy (remote/IDE debugging)
212
+ testbase testing run --root ./tests --debugger debugpy --breakpoint testrun-start
213
+
214
+ # Enable debugpy with custom port
215
+ testbase testing run --root ./tests --debugger debugpy --breakpoint testrun-start --debug-port 5680
216
+
217
+ # Enable debugpy with port range (auto-select available port)
218
+ testbase testing run --root ./tests --debugger debugpy --breakpoint testrun-start --debug-port-range 5678-5688
219
+
220
+ # Enable verbose debug logging
221
+ testbase testing run --root ./tests --debugger debugpy --breakpoint testrun-start --debug-log-level debug
222
+
223
+ # Disable debug logging
224
+ testbase testing run --root ./tests --debugger debugpy --breakpoint testrun-start --debug-log-level disabled
225
+
226
+ # Enable test-discovery breakpoint with debugpy
227
+ testbase testing run --root ./tests --debugger debugpy --breakpoint test-discovery
228
+
229
+ # Enable multiple breakpoints
230
+ testbase testing run --root ./tests --debugger debugpy \\
231
+ --breakpoint test-discovery \\
232
+ --breakpoint testrun-start
233
+
234
+ # Enable diagnostics with specific level
235
+ testbase testing run --root ./tests --prerun-diagnostic --diagnostic-level 5
236
+
237
+ # Enable both pre and post diagnostics with basic level
238
+ testbase testing run --root ./tests --prerun-diagnostic --postrun-diagnostic --diagnostic-level 3
239
+
240
+ Debugger Options:
241
+ - **pdb**: The built-in Python debugger. Provides local terminal debugging
242
+ with no additional setup required. When a breakpoint is hit, execution
243
+ pauses and the pdb prompt appears in the terminal.
244
+
245
+ - **debugpy**: The remote debugging protocol library. Enables IDE integration
246
+ and remote debugging. When a breakpoint is hit, the process waits for a
247
+ debugger client (e.g., VS Code) to attach before continuing.
248
+
249
+ Breakpoint Options:
250
+ - **test-discovery**: Pauses execution during the test discovery phase,
251
+ before test collection begins. Useful for debugging test collection issues.
252
+
253
+ - **testrun-start**: Pauses execution at the start of test execution,
254
+ at the entry point of the session() method in the sequence document.
255
+ Useful for debugging test setup and initialization.
256
+
257
+ Port Configuration:
258
+ - **--debug-port**: Specify a single port for debugpy to listen on.
259
+ Default is 5678. Use this when you know a specific port is available.
260
+
261
+ - **--debug-port-range**: Specify a range of ports (e.g., '5678-5688').
262
+ The system will automatically find an available port within the range.
263
+ Useful when running multiple debug sessions or when the default port
264
+ may be in use.
265
+
266
+ Debug Logging:
267
+ - **--debug-log-level**: Control the verbosity of debug event logging.
268
+ - ``debug``: Most verbose, logs all debug events including session start/end.
269
+ - ``info``: Standard level, logs breakpoint triggers and connection events.
270
+ - ``warning``: Logs only warning-level debug events.
271
+ - ``error``: Logs only error-level debug events.
272
+ - ``disabled``: Disables all debug event logging.
273
+
274
+ Diagnostic Level:
275
+ - **--diagnostic-level**: Control the verbosity of diagnostic capture.
276
+ - Levels 1-3: Basic diagnostic information (quick status checks)
277
+ - Levels 4-6: Standard diagnostic information (normal debugging)
278
+ - Levels 7-9: Detailed diagnostic information (deep investigation)
279
+ - Default is 9 (maximum detail) when not specified.
280
+
281
+ VS Code Integration:
282
+ When using debugpy, configure VS Code to attach to the debug session::
283
+
284
+ {
285
+ "name": "TestBase: Attach",
286
+ "type": "debugpy",
287
+ "request": "attach",
288
+ "connect": {
289
+ "host": "localhost",
290
+ "port": 5678
291
+ }
292
+ }
293
+
294
+ See Also:
295
+ - :class:`ccai.testbase.breakpoints.WELLKNOWN_BREAKPOINTS`: Breakpoint enumeration
296
+ - :mod:`ccai.xmodules.debugging`: Core debugging infrastructure
297
+ - :mod:`ccai.testbase.debugports`: Port utilities for conflict detection
298
+ - :mod:`ccai.testbase.debuglogging`: Debug event logging infrastructure
299
+ """
300
+ name = "diagnostic"
301
+ debugger = OptionField("--debugger", default=None, required=False,
302
+ ptype=Choice(['pdb', 'debugpy']), help=HELP_DEBUGGER)
303
+ breakpoints = OptionField("--breakpoint", alias="breakpoints", default=None, required=False,
304
+ mode=OptionMode.Multiple, ptype=Choice(['test-discovery', 'testrun-start']), help=HELP_BREAKPOINT)
305
+ debug_port = OptionField("--debug-port", default=None, required=False, help=HELP_DEBUG_PORT)
306
+ debug_port_range = OptionField("--debug-port-range", default=None, required=False, help=HELP_DEBUG_PORT_RANGE)
307
+ debug_log_level = OptionField("--debug-log-level", default=None, required=False,
308
+ ptype=Choice(['debug', 'info', 'warning', 'error', 'disabled']), help=HELP_DEBUG_LOG_LEVEL)
309
+ prerun_diagnostic = OptionField("--prerun-diagnostic", default=False, required=False, ptype=BooleanParameter, help=HELP_PRERUN_DIAGNOSTIC)
310
+ postrun_diagnostic = OptionField("--postrun-diagnostic", default=False, required=False, ptype=BooleanParameter, help=HELP_POSTRUN_DIAGNOSTIC)
311
+ diagnostic_level = OptionField("--diagnostic-level", default=None, required=False, help=HELP_DIAGNOSTIC_LEVEL)
312
+
313
+
314
+ class FilteringOptionGroup(OptionGroup):
315
+ """
316
+ Option group for test filtering options.
317
+
318
+ This group provides options for including or excluding tests based on
319
+ patterns and marker expressions.
320
+
321
+ Attributes:
322
+ name (str): Group identifier, set to ``"filtering"``.
323
+ includes (OptionField): The ``-i``/``--includes`` option for test inclusion patterns.
324
+ excludes (OptionField): The ``-x``/``--excludes`` option for test exclusion patterns.
325
+ include_marker_exp (OptionField): The ``--include-marker-exp`` option for marker-based inclusion.
326
+ exclude_marker_exp (OptionField): The ``--exclude-marker-exp`` option for marker-based exclusion.
327
+ """
328
+ name = "filtering"
329
+ includes = OptionField("-i", "--includes", default=None, required=False, mode=OptionMode.Multiple, help=HELP_INCLUDES)
330
+ excludes = OptionField("-x", "--excludes", default=None, required=False, mode=OptionMode.Multiple, help=HELP_EXCLUDES)
331
+ include_marker_exp = OptionField("--include-marker-exp", default=None, required=False, mode=OptionMode.Multiple, help=HELP_INCLUDE_MARKER_EXP)
332
+ exclude_marker_exp = OptionField("--exclude-marker-exp", default=None, required=False, mode=OptionMode.Multiple, help=HELP_EXCLUDE_MARKER_EXP)
333
+
334
+
335
+ class DebugOptionGroup(OptionGroup):
336
+ """
337
+ Option group for debug output control.
338
+
339
+ This group provides a simple flag for enabling debug output to the console.
340
+
341
+ Attributes:
342
+ name (str): Group identifier, set to ``"debug"``.
343
+ debug (OptionField): The ``--debug`` flag for enabling debug output.
344
+ """
345
+ name = "debug"
346
+ debug = OptionField("--debug", default=False, ptype=BooleanParameter, help=HELP_DEBUG)
347
+
348
+
349
+ class TimeoutOptionGroup(OptionGroup):
350
+ """
351
+ Option group for test run timeout configuration.
352
+
353
+ This group provides the ``--timeout`` option for specifying the maximum
354
+ allowed duration of the test execution phase. When the timeout is exceeded,
355
+ the test run is terminated gracefully and remaining tests are marked as errored.
356
+
357
+ Attributes:
358
+ name (str): Group identifier, set to ``"timeout"``.
359
+ timeout (OptionField): The ``--timeout`` option for maximum run duration in seconds.
360
+
361
+ Example CLI Usage::
362
+
363
+ # Set a 5-minute timeout for the test run
364
+ testbase testing run --root ./tests --timeout 300
365
+
366
+ # Set a 1-hour timeout
367
+ testbase testing run --root ./tests --timeout 3600
368
+ """
369
+ name = "timeout"
370
+ timeout = OptionField("--timeout", default=None, required=False, help=HELP_TIMEOUT)
@@ -0,0 +1,64 @@
1
+ """
2
+ .. module:: testbase_command
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: The script entrypoint for the 'testbase' command.
5
+
6
+ .. moduleauthor:: Myron Walker <myron.walker@gmail.com>
7
+ """
8
+
9
+ __author__ = "Myron Walker"
10
+ __copyright__ = "Copyright 2025, Code Craft AI LLC"
11
+ __credits__ = []
12
+
13
+ from ccai.arcli import decorators as arcli
14
+ from ccai.arcli.model.fields.optionfield import OptionMode
15
+
16
+ from ccai.thisapp.wellknown import ThisApplicationSingleton
17
+
18
+ from ccai.runtime.runtimevariables import RuntimeVariablesDesc
19
+
20
+ from ccai.testbase.initialize import initialize_testbase_runtime
21
+
22
+ from ccai.testbase.cli.cmdtree.agents import group_testbase_agents
23
+ from ccai.testbase.cli.cmdtree.services import group_testbase_services
24
+ from ccai.testbase.cli.cmdtree.testing import group_testbase_testing
25
+ from ccai.testbase.cli.cmdtree.utilities import group_testbase_utilities
26
+
27
+
28
+ @arcli.option('-v', '--verbose', default=0, mode=OptionMode.Counter, help="Set the verbosity level.")
29
+ @arcli.entry("testbase")
30
+ def testbase_root_command(verbose: int):
31
+
32
+ initialize_testbase_runtime()
33
+
34
+ interactive_console = False
35
+ log_level_console = "WARNING"
36
+
37
+ if verbose == 0:
38
+ interactive_console = True
39
+ else:
40
+ interactive_console = False
41
+
42
+ if verbose == 1:
43
+ log_level_console = "INFO"
44
+ elif verbose == 2:
45
+ log_level_console = "DEBUG"
46
+ elif verbose > 2:
47
+ log_level_console = "NOTSET"
48
+
49
+ this_app = ThisApplicationSingleton()
50
+
51
+ this_app.override_variable_value(RuntimeVariablesDesc.AM_INTERACTIVE_CONSOLE, interactive_console)
52
+ this_app.override_variable_value(RuntimeVariablesDesc.AM_LOG_LEVEL_CONSOLE, log_level_console)
53
+
54
+ return
55
+
56
+
57
+ testbase_root_command.add_command(group_testbase_agents)
58
+ testbase_root_command.add_command(group_testbase_services)
59
+ testbase_root_command.add_command(group_testbase_testing)
60
+ testbase_root_command.add_command(group_testbase_utilities)
61
+
62
+
63
+ if __name__ == '__main__':
64
+ testbase_root_command()
@@ -0,0 +1,31 @@
1
+ """
2
+ .. module:: ccai.testbase.cli.utilities
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Utility functions for the CLI.
5
+
6
+ .. moduleauthor:: Myron Walker <myron.walker@gmail.com>
7
+ """
8
+
9
+ import os
10
+ from typing import Optional
11
+
12
+ def resolve_test_root(root: Optional[str]) -> str:
13
+ """
14
+ Resolves the test root directory, falling back to RuntimeVariables or '.' if not provided.
15
+ Raises ValueError if the directory does not exist.
16
+ """
17
+ if root is None:
18
+ import ccai.runtime.runtimevariables as rv
19
+ if rv.RuntimeVariables.AM_TESTROOT is not None:
20
+ root = rv.RuntimeVariables.AM_TESTROOT
21
+ else:
22
+ root = "."
23
+
24
+ test_root = os.path.abspath(os.path.expandvars(os.path.expanduser(root)))
25
+ if not os.path.isdir(test_root):
26
+ errmsg = "The specified root folder does not exist. root=%s" % root
27
+ if test_root != root:
28
+ errmsg += " expanded=%s" % test_root
29
+ raise ValueError(errmsg)
30
+
31
+ return test_root