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.
- ccai/factories/py.typed +0 -0
- ccai/factories/testbasedefaulttypefactory.py +25 -0
- ccai/testbase/__init__.py +63 -0
- ccai/testbase/breakpoints.py +110 -0
- ccai/testbase/cli/__init__.py +13 -0
- ccai/testbase/cli/cmdtree/agents/__init__.py +28 -0
- ccai/testbase/cli/cmdtree/agents/config/__init__.py +24 -0
- ccai/testbase/cli/cmdtree/agents/config/extract.py +94 -0
- ccai/testbase/cli/cmdtree/agents/formatting.py +71 -0
- ccai/testbase/cli/cmdtree/agents/jsosparser.py +119 -0
- ccai/testbase/cli/cmdtree/agents/pathresolver.py +34 -0
- ccai/testbase/cli/cmdtree/agents/summary/__init__.py +26 -0
- ccai/testbase/cli/cmdtree/agents/summary/compare.py +128 -0
- ccai/testbase/cli/cmdtree/agents/summary/extract.py +91 -0
- ccai/testbase/cli/cmdtree/agents/testresult/__init__.py +28 -0
- ccai/testbase/cli/cmdtree/agents/testresult/extract.py +77 -0
- ccai/testbase/cli/cmdtree/agents/testresult/failures.py +73 -0
- ccai/testbase/cli/cmdtree/agents/testresult/list.py +63 -0
- ccai/testbase/cli/cmdtree/services/__init__.py +27 -0
- ccai/testbase/cli/cmdtree/services/results.py +66 -0
- ccai/testbase/cli/cmdtree/testing/__init__.py +30 -0
- ccai/testbase/cli/cmdtree/testing/jobs.py +175 -0
- ccai/testbase/cli/cmdtree/testing/query.py +131 -0
- ccai/testbase/cli/cmdtree/testing/run.py +263 -0
- ccai/testbase/cli/cmdtree/utilities/__init__.py +28 -0
- ccai/testbase/cli/cmdtree/utilities/timestamp.py +33 -0
- ccai/testbase/cli/options.py +370 -0
- ccai/testbase/cli/testbase_command.py +64 -0
- ccai/testbase/cli/utilities.py +31 -0
- ccai/testbase/configuration.py +324 -0
- ccai/testbase/constraints.py +998 -0
- ccai/testbase/coupling/__init__.py +569 -0
- ccai/testbase/coupling/basecoupling.py +69 -0
- ccai/testbase/coupling/configurationcoupling.py +138 -0
- ccai/testbase/coupling/integrationcoupling.py +842 -0
- ccai/testbase/coupling/validatorcoupling.py +127 -0
- ccai/testbase/debuggingext.py +281 -0
- ccai/testbase/debuglogging.py +407 -0
- ccai/testbase/debugports.py +469 -0
- ccai/testbase/declaration/__init__.py +13 -0
- ccai/testbase/declaration/attachments.py +222 -0
- ccai/testbase/declaration/originations.py +217 -0
- ccai/testbase/declaration/parameterization.py +160 -0
- ccai/testbase/declaration/registrations.py +476 -0
- ccai/testbase/diagnostic_level.py +197 -0
- ccai/testbase/diagnostic_streaming.py +1534 -0
- ccai/testbase/diagnostics.py +1685 -0
- ccai/testbase/entrypoints.py +485 -0
- ccai/testbase/environment.py +162 -0
- ccai/testbase/errors/testruntimeouterror.py +50 -0
- ccai/testbase/expressions.py +355 -0
- ccai/testbase/factories.py +277 -0
- ccai/testbase/factoryprotocols.py +35 -0
- ccai/testbase/features.py +913 -0
- ccai/testbase/initialize.py +210 -0
- ccai/testbase/injection/__init__.py +25 -0
- ccai/testbase/injection/injectiongroup.py +493 -0
- ccai/testbase/injection/injectionmoment.py +155 -0
- ccai/testbase/injection/injectionregistry.py +823 -0
- ccai/testbase/injection/injectionscope.py +2589 -0
- ccai/testbase/injection/introspection.py +514 -0
- ccai/testbase/markers.py +665 -0
- ccai/testbase/mocking.py +4856 -0
- ccai/testbase/origins/__init__.py +13 -0
- ccai/testbase/origins/resourceorigin.py +110 -0
- ccai/testbase/origins/validatororigin.py +111 -0
- ccai/testbase/output/__init__.py +17 -0
- ccai/testbase/output/outputcontext.py +201 -0
- ccai/testbase/output/runmetadata.py +184 -0
- ccai/testbase/properties/__init__.py +40 -0
- ccai/testbase/properties/assumptions.py +56 -0
- ccai/testbase/properties/decorators.py +173 -0
- ccai/testbase/properties/propertyrunner.py +449 -0
- ccai/testbase/properties/strategies.py +1592 -0
- ccai/testbase/properties/unittestsupport.py +87 -0
- ccai/testbase/py.typed +0 -0
- ccai/testbase/queries.py +95 -0
- ccai/testbase/resourcelifespan.py +24 -0
- ccai/testbase/results/__init__.py +35 -0
- ccai/testbase/results/exceptions.py +60 -0
- ccai/testbase/results/filtering/__init__.py +26 -0
- ccai/testbase/results/filtering/resultfilter.py +570 -0
- ccai/testbase/results/model/__init__.py +32 -0
- ccai/testbase/results/model/buildinfo.py +54 -0
- ccai/testbase/results/model/checkresult.py +183 -0
- ccai/testbase/results/model/forwardinginfo.py +30 -0
- ccai/testbase/results/model/jobcontainer.py +32 -0
- ccai/testbase/results/model/jobinfo.py +91 -0
- ccai/testbase/results/model/nestedprogressinfo.py +211 -0
- ccai/testbase/results/model/pipelineinfo.py +51 -0
- ccai/testbase/results/model/progressaggregator.py +551 -0
- ccai/testbase/results/model/progresscode.py +29 -0
- ccai/testbase/results/model/progressdelivery.py +51 -0
- ccai/testbase/results/model/progressinfo.py +84 -0
- ccai/testbase/results/model/progresstype.py +24 -0
- ccai/testbase/results/model/renderinfo.py +30 -0
- ccai/testbase/results/model/resultcode.py +28 -0
- ccai/testbase/results/model/resultcontainer.py +95 -0
- ccai/testbase/results/model/resultnode.py +258 -0
- ccai/testbase/results/model/resulttype.py +34 -0
- ccai/testbase/results/model/streaminginfo.py +111 -0
- ccai/testbase/results/model/taskinggroup.py +85 -0
- ccai/testbase/results/model/taskingresult.py +297 -0
- ccai/testbase/results/model/testcontainer.py +35 -0
- ccai/testbase/results/model/testresult.py +170 -0
- ccai/testbase/results/recorders/__init__.py +31 -0
- ccai/testbase/results/recorders/csvresultrecorder.py +414 -0
- ccai/testbase/results/recorders/jsonresultrecorder.py +467 -0
- ccai/testbase/results/recorders/resultrecorder.py +1472 -0
- ccai/testbase/results/recorders/stdoutresultrecorder.py +70 -0
- ccai/testbase/results/recorders/xmlresultrecorder.py +305 -0
- ccai/testbase/results/utilities.py +141 -0
- ccai/testbase/sequencing/__init__.py +13 -0
- ccai/testbase/sequencing/sequencermodulescope.py +96 -0
- ccai/testbase/sequencing/sequencerscopebase.py +91 -0
- ccai/testbase/sequencing/sequencersessionscope.py +84 -0
- ccai/testbase/sequencing/sequencertestscope.py +249 -0
- ccai/testbase/sequencing/sequencertestsetupscope.py +86 -0
- ccai/testbase/sequencing/testactivity.py +111 -0
- ccai/testbase/sequencing/testsequencer.py +3072 -0
- ccai/testbase/server/__init__.py +13 -0
- ccai/testbase/server/resultserver.py +599 -0
- ccai/testbase/sources/__init__.py +13 -0
- ccai/testbase/sources/configurationsource.py +32 -0
- ccai/testbase/sources/integrationsource.py +29 -0
- ccai/testbase/sources/resourcesource.py +27 -0
- ccai/testbase/sources/sourcebase.py +71 -0
- ccai/testbase/sources/unknownsource.py +30 -0
- ccai/testbase/sources/validatorsource.py +28 -0
- ccai/testbase/tandem/__init__.py +13 -0
- ccai/testbase/tandem/validators.py +286 -0
- ccai/testbase/testcollector.py +230 -0
- ccai/testbase/testgroup.py +54 -0
- ccai/testbase/testjob.py +600 -0
- ccai/testbase/testref.py +64 -0
- ccai/testbase/utilities.py +472 -0
- ccai/testbase/verification.py +768 -0
- codecraftai_testbase-1.3.0.dist-info/METADATA +99 -0
- codecraftai_testbase-1.3.0.dist-info/RECORD +142 -0
- codecraftai_testbase-1.3.0.dist-info/WHEEL +4 -0
- codecraftai_testbase-1.3.0.dist-info/entry_points.txt +3 -0
- codecraftai_testbase-1.3.0.dist-info/licenses/LICENSE.md +204 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.cli.cmdtree.testing.jobs
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for jobs.
|
|
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 typing import Optional
|
|
14
|
+
|
|
15
|
+
import argparse
|
|
16
|
+
import os
|
|
17
|
+
import sys
|
|
18
|
+
|
|
19
|
+
from ccai.arcli import decorators as arcli
|
|
20
|
+
|
|
21
|
+
from ccai.testbase.cli.options import (
|
|
22
|
+
RootOptionGroup,
|
|
23
|
+
OutputOptionGroup,
|
|
24
|
+
BuildOptionGroup,
|
|
25
|
+
LoggingOptionGroup,
|
|
26
|
+
DebugOptionGroup,
|
|
27
|
+
TimeoutOptionGroup,
|
|
28
|
+
HELP_FILTER,
|
|
29
|
+
HELP_JOB,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
@arcli.group("jobs")
|
|
33
|
+
def group_testbase_testing_jobs():
|
|
34
|
+
"""
|
|
35
|
+
Contains commands for working with test jobs.
|
|
36
|
+
"""
|
|
37
|
+
return
|
|
38
|
+
|
|
39
|
+
@arcli.option("--filter", "-f", required=False, help=HELP_FILTER)
|
|
40
|
+
@RootOptionGroup.attach(help_fill={"action": "list"})
|
|
41
|
+
@DebugOptionGroup.attach()
|
|
42
|
+
@arcli.command("list")
|
|
43
|
+
def command_testing_jobs_list(root: Optional[str], filter: Optional[str], debug: bool):
|
|
44
|
+
raise NotImplementedError("The 'jobs list' command is not yet implemented.")
|
|
45
|
+
|
|
46
|
+
@arcli.option("--job", "-j", required=True, help=HELP_JOB.format(action="show"))
|
|
47
|
+
@RootOptionGroup.attach(help_fill={"action": "show"})
|
|
48
|
+
@DebugOptionGroup.attach()
|
|
49
|
+
@arcli.command("show")
|
|
50
|
+
def command_testbase_testing_jobs_show(root: Optional[str], job: str, debug: bool):
|
|
51
|
+
raise NotImplementedError("The 'jobs show' command is not yet implemented.")
|
|
52
|
+
|
|
53
|
+
@arcli.option("--job", "-j", required=True, help=HELP_JOB.format(action="run"))
|
|
54
|
+
@RootOptionGroup.attach(help_fill={"action": "run"})
|
|
55
|
+
@OutputOptionGroup.attach()
|
|
56
|
+
@BuildOptionGroup.attach()
|
|
57
|
+
@LoggingOptionGroup.attach()
|
|
58
|
+
@TimeoutOptionGroup.attach()
|
|
59
|
+
@arcli.command("run")
|
|
60
|
+
def command_testbase_testing_jobs_run(root: Optional[str], job: str, output: Optional[str], start: Optional[str], runid: Optional[str],
|
|
61
|
+
branch: Optional[str], build: Optional[str], flavor: Optional[str],
|
|
62
|
+
console_level: Optional[str], logfile_level: Optional[str],
|
|
63
|
+
timeout: Optional[str]):
|
|
64
|
+
|
|
65
|
+
# pylint: disable=unused-import,import-outside-toplevel
|
|
66
|
+
|
|
67
|
+
# We do the imports of the automation framework code inside the action functions because
|
|
68
|
+
# we don't want to startup loggin and the processing of inputs and environment variables
|
|
69
|
+
# until we have entered an action method. Thats way we know how to setup the environment.
|
|
70
|
+
|
|
71
|
+
# IMPORTANT: We need to load the context first because it will trigger the loading
|
|
72
|
+
# of the default user configuration
|
|
73
|
+
|
|
74
|
+
from ccai.xmodules.ximport import import_by_name
|
|
75
|
+
from ccai.xmodules.xpython import prepend_python_path
|
|
76
|
+
|
|
77
|
+
try:
|
|
78
|
+
from ccai.testbase.cli.utilities import resolve_test_root
|
|
79
|
+
test_root = resolve_test_root(root)
|
|
80
|
+
|
|
81
|
+
# Make sure we extend PATH to include the test root parent folder
|
|
82
|
+
test_root_parent = os.path.dirname(test_root)
|
|
83
|
+
prepend_python_path(test_root_parent)
|
|
84
|
+
|
|
85
|
+
# We perform activation a little later in the testrunner.py file so we can
|
|
86
|
+
# handle exceptions in the context of testrunner_main function
|
|
87
|
+
from ccai.thisapp.activation import activate_profile_console
|
|
88
|
+
activate_profile_console()
|
|
89
|
+
|
|
90
|
+
from ccai.runtime.optionoverrides import AM_RUNTIME_OPTION_OVERRIDES
|
|
91
|
+
|
|
92
|
+
if branch is not None:
|
|
93
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_build_branch(branch)
|
|
94
|
+
if build is not None:
|
|
95
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_build_name(build)
|
|
96
|
+
if flavor is not None:
|
|
97
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_build_flavor(flavor)
|
|
98
|
+
if console_level is not None:
|
|
99
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_loglevel_console(console_level)
|
|
100
|
+
if logfile_level is not None:
|
|
101
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_loglevel_file(logfile_level)
|
|
102
|
+
if output is not None:
|
|
103
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_output_directory(output)
|
|
104
|
+
if start is not None:
|
|
105
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_starttime(start)
|
|
106
|
+
if runid is not None:
|
|
107
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_run_id(runid)
|
|
108
|
+
|
|
109
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_testroot(test_root)
|
|
110
|
+
|
|
111
|
+
if timeout is not None:
|
|
112
|
+
try:
|
|
113
|
+
timeout_value = int(timeout)
|
|
114
|
+
if timeout_value <= 0:
|
|
115
|
+
raise ValueError("Timeout must be a positive integer, got: %d" % timeout_value)
|
|
116
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_testrun_timeout(timeout_value)
|
|
117
|
+
except ValueError as e:
|
|
118
|
+
if "invalid literal" in str(e):
|
|
119
|
+
raise ValueError("Timeout must be a positive integer, got: %s" % timeout)
|
|
120
|
+
raise
|
|
121
|
+
|
|
122
|
+
from ccai.testbase.initialize import initialize_testbase_results
|
|
123
|
+
initialize_testbase_results()
|
|
124
|
+
|
|
125
|
+
# Initialize logging
|
|
126
|
+
from ccai.xmodules.xlogging.enhancedloggers import getEnhancedLogger
|
|
127
|
+
logger = getEnhancedLogger()
|
|
128
|
+
|
|
129
|
+
import ccai.testbase
|
|
130
|
+
tpmod = sys.modules["ccai.testbase"]
|
|
131
|
+
tpmod.logger = logger
|
|
132
|
+
|
|
133
|
+
from ccai.thisapp.wellknown import ConfiguredSuperFactorySingleton
|
|
134
|
+
from ccai.testbase.factoryprotocols import TestBaseExtensionProtocol
|
|
135
|
+
|
|
136
|
+
# At this point in the code, we either lookup an existing test job or we create a test job
|
|
137
|
+
# from the includes, excludes or test_module
|
|
138
|
+
sfactory = ConfiguredSuperFactorySingleton()
|
|
139
|
+
TestJobType = sfactory.get_override_types_by_order(TestBaseExtensionProtocol.get_testbase_default_job_type)
|
|
140
|
+
|
|
141
|
+
if job is not None:
|
|
142
|
+
job_parts = job.split("@")
|
|
143
|
+
if len(job_parts) != 2:
|
|
144
|
+
errmsg = "A --job parameter must be of the form 'package.module@JobClass'"
|
|
145
|
+
raise ValueError(errmsg)
|
|
146
|
+
|
|
147
|
+
job_package, job_class = job_parts
|
|
148
|
+
|
|
149
|
+
try:
|
|
150
|
+
job_mod = import_by_name(job_package)
|
|
151
|
+
except ImportError as imperr:
|
|
152
|
+
errmsg = "Failure while importing job package %r" % job_package
|
|
153
|
+
raise RuntimeError(errmsg) from imperr
|
|
154
|
+
|
|
155
|
+
if not hasattr(job_mod, job_class):
|
|
156
|
+
errmsg = "The job package %r does not have a job type %r." % (job_package, job_class)
|
|
157
|
+
raise argparse.ArgumentError(None, errmsg)
|
|
158
|
+
|
|
159
|
+
TestJobType = getattr(job_mod, job_class)
|
|
160
|
+
|
|
161
|
+
result_code = 0
|
|
162
|
+
with TestJobType(logger, test_root) as tjob:
|
|
163
|
+
result_code = tjob.execute()
|
|
164
|
+
|
|
165
|
+
sys.exit(result_code)
|
|
166
|
+
|
|
167
|
+
finally:
|
|
168
|
+
pass
|
|
169
|
+
|
|
170
|
+
return
|
|
171
|
+
|
|
172
|
+
# Only wire commands that are implemented. 'jobs list' and 'jobs show' remain
|
|
173
|
+
# unimplemented placeholders and are intentionally NOT registered so the CLI does
|
|
174
|
+
# not advertise subcommands that always raise NotImplementedError.
|
|
175
|
+
group_testbase_testing_jobs.add_command(command_testbase_testing_jobs_run)
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.cli.cmdtree.testing.query
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for query.
|
|
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
|
+
|
|
14
|
+
from typing import List, Optional
|
|
15
|
+
|
|
16
|
+
import os
|
|
17
|
+
import sys
|
|
18
|
+
|
|
19
|
+
from ccai.arcli import decorators as arcli
|
|
20
|
+
|
|
21
|
+
from ccai.testbase.cli.options import (
|
|
22
|
+
RootOptionGroup,
|
|
23
|
+
FilteringOptionGroup,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
@RootOptionGroup.attach(help_fill={"action": "query"})
|
|
27
|
+
@FilteringOptionGroup.attach(help_fill={"action": "query"})
|
|
28
|
+
@arcli.command("query")
|
|
29
|
+
def command_testbase_testing_query(root: Optional[str], includes: Optional[List[str]], excludes: Optional[List[str]],
|
|
30
|
+
include_marker_exp: Optional[List[str]], exclude_marker_exp: Optional[List[str]]):
|
|
31
|
+
"""
|
|
32
|
+
Command used to query information about tests.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
# pylint: disable=unused-import,import-outside-toplevel
|
|
36
|
+
|
|
37
|
+
# We do the imports of the automation framework code inside the action functions because
|
|
38
|
+
# we don't want to startup loggin and the processing of inputs and environment variables
|
|
39
|
+
# until we have entered an action method. Thats way we know how to setup the environment.
|
|
40
|
+
|
|
41
|
+
# IMPORTANT: We need to load the context first because it will trigger the loading
|
|
42
|
+
# of the default user configuration
|
|
43
|
+
|
|
44
|
+
from ccai.xmodules.xpython import prepend_python_path
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# Initialize lists if they are None
|
|
48
|
+
if includes is None: includes = []
|
|
49
|
+
if excludes is None: excludes = []
|
|
50
|
+
if include_marker_exp is None: include_marker_exp = []
|
|
51
|
+
if exclude_marker_exp is None: exclude_marker_exp = []
|
|
52
|
+
|
|
53
|
+
# STEP 2 - Resolve the configuration variables (performed by the root command)
|
|
54
|
+
|
|
55
|
+
# STEP 3 - Activate the runtime for the given activation class
|
|
56
|
+
|
|
57
|
+
# We perform activation a little later in the testrunner.py file so we can
|
|
58
|
+
# handle exceptions in the context of testrunner_main function
|
|
59
|
+
|
|
60
|
+
# STEP 4 - Apply any Option Overrides
|
|
61
|
+
|
|
62
|
+
from ccai.runtime.optionoverrides import AM_RUNTIME_OPTION_OVERRIDES
|
|
63
|
+
|
|
64
|
+
from ccai.testbase.markers import MetaFilter, parse_marker_expression
|
|
65
|
+
|
|
66
|
+
# Setup the Test Root
|
|
67
|
+
from ccai.testbase.cli.utilities import resolve_test_root
|
|
68
|
+
test_root = resolve_test_root(root)
|
|
69
|
+
|
|
70
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_testroot(test_root)
|
|
71
|
+
|
|
72
|
+
from ccai.testbase.initialize import initialize_testbase_results
|
|
73
|
+
|
|
74
|
+
initialize_testbase_results()
|
|
75
|
+
|
|
76
|
+
# Make sure we extend PATH to include the test roots parent folder so imports will
|
|
77
|
+
# work properly.
|
|
78
|
+
test_root_parent = os.path.dirname(test_root)
|
|
79
|
+
prepend_python_path(test_root_parent)
|
|
80
|
+
|
|
81
|
+
metafilters: List[MetaFilter] = []
|
|
82
|
+
for imexp in include_marker_exp:
|
|
83
|
+
imexp = imexp.strip("\"")
|
|
84
|
+
imexp = imexp.strip("'")
|
|
85
|
+
mfilter = parse_marker_expression("+" + imexp)
|
|
86
|
+
metafilters.append(mfilter)
|
|
87
|
+
|
|
88
|
+
for exmexp in exclude_marker_exp:
|
|
89
|
+
exmexp = exmexp.strip("\"")
|
|
90
|
+
exmexp = exmexp.strip("'")
|
|
91
|
+
mfilter = parse_marker_expression("-" + exmexp)
|
|
92
|
+
metafilters.append(mfilter)
|
|
93
|
+
|
|
94
|
+
from ccai.xmodules.xlogging.enhancedloggers import getEnhancedLogger
|
|
95
|
+
logger = getEnhancedLogger()
|
|
96
|
+
|
|
97
|
+
from ccai.thisapp.wellknown import ConfiguredSuperFactorySingleton
|
|
98
|
+
from ccai.testbase.factoryprotocols import TestBaseFactoryProtocol
|
|
99
|
+
|
|
100
|
+
sfactory = ConfiguredSuperFactorySingleton()
|
|
101
|
+
TestJobType = sfactory.get_override_types_by_order(TestBaseFactoryProtocol.get_testbase_default_job_type)
|
|
102
|
+
|
|
103
|
+
# At this point in the code, we either lookup an existing test job or we create a test job
|
|
104
|
+
# from the includes, excludes or test_module
|
|
105
|
+
with TestJobType(logger, test_root, includes=includes, excludes=excludes, metafilters=metafilters) as tjob:
|
|
106
|
+
query_results = tjob.query()
|
|
107
|
+
|
|
108
|
+
test_names = [tn for tn in query_results.keys()]
|
|
109
|
+
test_names.sort()
|
|
110
|
+
print()
|
|
111
|
+
print("Tests:")
|
|
112
|
+
for tname in test_names:
|
|
113
|
+
tref = query_results[tname]
|
|
114
|
+
print(" " + tname)
|
|
115
|
+
|
|
116
|
+
param_names = [pn for pn in tref.subscriptions.keys()]
|
|
117
|
+
param_names.sort()
|
|
118
|
+
for pname in param_names:
|
|
119
|
+
pinfo = tref.subscriptions[pname]
|
|
120
|
+
print (" {}: {}".format(pname, pinfo.describe_source()))
|
|
121
|
+
|
|
122
|
+
print()
|
|
123
|
+
|
|
124
|
+
if len(tjob.import_errors) > 0:
|
|
125
|
+
print("IMPORT ERRORS:", file=sys.stderr)
|
|
126
|
+
for ifilename in tjob.import_errors:
|
|
127
|
+
imperr_msg = ifilename
|
|
128
|
+
print(" " + imperr_msg, file=sys.stderr)
|
|
129
|
+
print("", file=sys.stderr)
|
|
130
|
+
|
|
131
|
+
return
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.cli.cmdtree.testing.run
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for run.
|
|
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 typing import List, Optional
|
|
14
|
+
|
|
15
|
+
import os
|
|
16
|
+
import sys
|
|
17
|
+
|
|
18
|
+
from ccai.arcli import decorators as arcli
|
|
19
|
+
|
|
20
|
+
from ccai.interfaces.itestjob import ITestJob
|
|
21
|
+
|
|
22
|
+
from ccai.testbase.cli.options import (
|
|
23
|
+
RootOptionGroup,
|
|
24
|
+
OutputOptionGroup,
|
|
25
|
+
BuildOptionGroup,
|
|
26
|
+
JobOptionGroup,
|
|
27
|
+
LoggingOptionGroup,
|
|
28
|
+
DiagnosticOptionGroup,
|
|
29
|
+
FilteringOptionGroup,
|
|
30
|
+
TimeoutOptionGroup,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
@RootOptionGroup.attach(help_fill={"action": "run"})
|
|
34
|
+
@FilteringOptionGroup.attach(help_fill={"action": "run"})
|
|
35
|
+
@OutputOptionGroup.attach()
|
|
36
|
+
@BuildOptionGroup.attach()
|
|
37
|
+
@JobOptionGroup.attach()
|
|
38
|
+
@LoggingOptionGroup.attach()
|
|
39
|
+
@DiagnosticOptionGroup.attach()
|
|
40
|
+
@TimeoutOptionGroup.attach()
|
|
41
|
+
@arcli.command("run")
|
|
42
|
+
def command_testbase_testing_run(root: Optional[str], includes: Optional[List[str]], excludes: Optional[List[str]], output: Optional[str],
|
|
43
|
+
start: Optional[str], runid: Optional[str], branch: Optional[str], build: Optional[str], flavor: Optional[str],
|
|
44
|
+
job_id: Optional[str], job_initiator: Optional[str], job_label: Optional[str], job_name: Optional[str],
|
|
45
|
+
job_owner: Optional[str], job_seed: Optional[str], job_tag: Optional[str],
|
|
46
|
+
console_level: Optional[str], logfile_level: Optional[str],
|
|
47
|
+
debugger: Optional[str], breakpoints: Optional[List[str]], debug_port: Optional[str],
|
|
48
|
+
debug_port_range: Optional[str], debug_log_level: Optional[str], prerun_diagnostic: bool, postrun_diagnostic: bool,
|
|
49
|
+
diagnostic_level: Optional[str], include_marker_exp: Optional[List[str]], exclude_marker_exp: Optional[List[str]],
|
|
50
|
+
timeout: Optional[str]):
|
|
51
|
+
"""
|
|
52
|
+
Command used to run collections of tests.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
# pylint: disable=unused-import,import-outside-toplevel
|
|
56
|
+
|
|
57
|
+
# We do the imports of the automation framework code inside the action functions because
|
|
58
|
+
# we don't want to startup loggin and the processing of inputs and environment variables
|
|
59
|
+
# until we have entered an action method. Thats way we know how to setup the environment.
|
|
60
|
+
|
|
61
|
+
# IMPORTANT: We need to load the context first because it will trigger the loading
|
|
62
|
+
# of the default user configuration
|
|
63
|
+
|
|
64
|
+
# Initialize lists
|
|
65
|
+
if includes is None: includes = []
|
|
66
|
+
if excludes is None: excludes = []
|
|
67
|
+
if breakpoints is None: breakpoints = []
|
|
68
|
+
if include_marker_exp is None: include_marker_exp = []
|
|
69
|
+
if exclude_marker_exp is None: exclude_marker_exp = []
|
|
70
|
+
|
|
71
|
+
from ccai.xmodules.xpython import prepend_python_path
|
|
72
|
+
|
|
73
|
+
from ccai.runtime.runtimevariables import RuntimeVariables
|
|
74
|
+
|
|
75
|
+
from ccai.runtime.optionoverrides import AM_RUNTIME_OPTION_OVERRIDES
|
|
76
|
+
|
|
77
|
+
# STEP 1 - Initialize the Runtime (Performed by the root command)
|
|
78
|
+
|
|
79
|
+
# STEP 2 - Resolve the configuration variables (Performed by the root command)
|
|
80
|
+
|
|
81
|
+
# STEP 3 - Apply any "Command Line" option overrides
|
|
82
|
+
|
|
83
|
+
from ccai.testbase.markers import MetaFilter, parse_marker_expression
|
|
84
|
+
|
|
85
|
+
if branch is not None:
|
|
86
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_build_branch(branch)
|
|
87
|
+
|
|
88
|
+
if build is not None:
|
|
89
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_build_name(build)
|
|
90
|
+
|
|
91
|
+
if flavor is not None:
|
|
92
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_build_flavor(flavor)
|
|
93
|
+
|
|
94
|
+
if job_id is not None:
|
|
95
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_job_id(job_id)
|
|
96
|
+
|
|
97
|
+
if job_initiator is not None:
|
|
98
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_job_initiator(job_initiator)
|
|
99
|
+
|
|
100
|
+
if job_label is not None:
|
|
101
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_job_label(job_label)
|
|
102
|
+
|
|
103
|
+
if job_name is not None:
|
|
104
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_job_name(job_name)
|
|
105
|
+
|
|
106
|
+
if job_owner is not None:
|
|
107
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_job_owner(job_owner)
|
|
108
|
+
|
|
109
|
+
if job_seed is not None:
|
|
110
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_job_seed(job_seed)
|
|
111
|
+
|
|
112
|
+
if job_tag is not None:
|
|
113
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_job_tag(job_tag)
|
|
114
|
+
|
|
115
|
+
if console_level is not None:
|
|
116
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_loglevel_console(console_level)
|
|
117
|
+
|
|
118
|
+
if logfile_level is not None:
|
|
119
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_loglevel_file(logfile_level)
|
|
120
|
+
|
|
121
|
+
if output is not None:
|
|
122
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_output_directory(output)
|
|
123
|
+
|
|
124
|
+
if start is not None:
|
|
125
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_starttime(start)
|
|
126
|
+
|
|
127
|
+
if runid is not None:
|
|
128
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_run_id(runid)
|
|
129
|
+
|
|
130
|
+
# STEP 4 - Applying runtime options must happen after we have resolved configuration
|
|
131
|
+
# maps because some of those settings will get overridden by the options. So the runtime
|
|
132
|
+
# needs to be loaded and set first before we apply runtime options
|
|
133
|
+
|
|
134
|
+
# Process the commandline args here and then set the variables on the environment
|
|
135
|
+
# as necessary. We need to do this before we import activate.
|
|
136
|
+
if breakpoints is not None and len(breakpoints) > 0:
|
|
137
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_debug_breakpoints(breakpoints)
|
|
138
|
+
|
|
139
|
+
# If a breakpoint was passed bug the debugger was not, use 'debugpy' for the
|
|
140
|
+
# default debugger.
|
|
141
|
+
if debugger is None:
|
|
142
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_debug_debugger('debugpy')
|
|
143
|
+
|
|
144
|
+
if debugger is not None:
|
|
145
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_debug_debugger('debugpy')
|
|
146
|
+
|
|
147
|
+
# Handle debug port configuration
|
|
148
|
+
# Port range takes precedence over specific port
|
|
149
|
+
if debug_port_range is not None or debug_port is not None:
|
|
150
|
+
from ccai.testbase.debugports import (
|
|
151
|
+
resolve_debug_port,
|
|
152
|
+
set_configured_debug_port,
|
|
153
|
+
PortConflictError,
|
|
154
|
+
PortRangeError
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
try:
|
|
158
|
+
# Convert debug_port to int if provided
|
|
159
|
+
port_value = int(debug_port) if debug_port is not None else None
|
|
160
|
+
resolved_port = resolve_debug_port(port=port_value, port_range=debug_port_range)
|
|
161
|
+
set_configured_debug_port(resolved_port)
|
|
162
|
+
except PortConflictError as e:
|
|
163
|
+
raise ValueError(str(e))
|
|
164
|
+
except PortRangeError as e:
|
|
165
|
+
raise ValueError(str(e))
|
|
166
|
+
|
|
167
|
+
# Handle debug log level configuration
|
|
168
|
+
if debug_log_level is not None:
|
|
169
|
+
from ccai.testbase.debuglogging import set_debug_log_level, DEBUG_LOG_LEVEL
|
|
170
|
+
|
|
171
|
+
level_map = {
|
|
172
|
+
'debug': DEBUG_LOG_LEVEL.DEBUG,
|
|
173
|
+
'info': DEBUG_LOG_LEVEL.INFO,
|
|
174
|
+
'warning': DEBUG_LOG_LEVEL.WARNING,
|
|
175
|
+
'error': DEBUG_LOG_LEVEL.ERROR,
|
|
176
|
+
'disabled': DEBUG_LOG_LEVEL.DISABLED
|
|
177
|
+
}
|
|
178
|
+
if debug_log_level.lower() in level_map:
|
|
179
|
+
set_debug_log_level(level_map[debug_log_level.lower()])
|
|
180
|
+
|
|
181
|
+
if prerun_diagnostic:
|
|
182
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_diagnostics_prerun({})
|
|
183
|
+
|
|
184
|
+
if postrun_diagnostic:
|
|
185
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_diagnostics_postrun({})
|
|
186
|
+
|
|
187
|
+
if diagnostic_level is not None:
|
|
188
|
+
# Validate and convert diagnostic level to integer
|
|
189
|
+
from ccai.testbase.diagnostic_level import set_diagnostic_level
|
|
190
|
+
try:
|
|
191
|
+
level_value = int(diagnostic_level)
|
|
192
|
+
if level_value < 1 or level_value > 9:
|
|
193
|
+
raise ValueError(f"Diagnostic level must be between 1 and 9, got: {level_value}")
|
|
194
|
+
set_diagnostic_level(level_value)
|
|
195
|
+
except ValueError as e:
|
|
196
|
+
if "invalid literal" in str(e):
|
|
197
|
+
raise ValueError(f"Diagnostic level must be an integer between 1 and 9, got: {diagnostic_level}")
|
|
198
|
+
raise
|
|
199
|
+
|
|
200
|
+
from ccai.testbase.cli.utilities import resolve_test_root
|
|
201
|
+
test_root = resolve_test_root(root)
|
|
202
|
+
|
|
203
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_testroot(test_root)
|
|
204
|
+
|
|
205
|
+
if timeout is not None:
|
|
206
|
+
try:
|
|
207
|
+
timeout_value = int(timeout)
|
|
208
|
+
if timeout_value <= 0:
|
|
209
|
+
raise ValueError("Timeout must be a positive integer, got: %d" % timeout_value)
|
|
210
|
+
AM_RUNTIME_OPTION_OVERRIDES.override_testrun_timeout(timeout_value)
|
|
211
|
+
except ValueError as e:
|
|
212
|
+
if "invalid literal" in str(e):
|
|
213
|
+
raise ValueError("Timeout must be a positive integer, got: %s" % timeout)
|
|
214
|
+
raise
|
|
215
|
+
|
|
216
|
+
# Make sure we extend PATH to include the test roots parent folder so imports will
|
|
217
|
+
# work properly.
|
|
218
|
+
test_root_parent = os.path.dirname(test_root)
|
|
219
|
+
prepend_python_path(test_root_parent)
|
|
220
|
+
|
|
221
|
+
metafilters: List[MetaFilter] = []
|
|
222
|
+
for imexp in include_marker_exp:
|
|
223
|
+
imexp = imexp.strip("\"")
|
|
224
|
+
imexp = imexp.strip("'")
|
|
225
|
+
mfilter = parse_marker_expression("+" + imexp)
|
|
226
|
+
metafilters.append(mfilter)
|
|
227
|
+
|
|
228
|
+
for exmexp in exclude_marker_exp:
|
|
229
|
+
exmexp = exmexp.strip("\"")
|
|
230
|
+
exmexp = exmexp.strip("'")
|
|
231
|
+
mfilter = parse_marker_expression("-" + exmexp)
|
|
232
|
+
metafilters.append(mfilter)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
# STEP 5 - Initialize the Results Output
|
|
236
|
+
|
|
237
|
+
# Initialize testbase results and logging
|
|
238
|
+
from ccai.testbase.initialize import initialize_testbase_results
|
|
239
|
+
from ccai.xmodules.xlogging.enhancedloggers import getEnhancedLogger
|
|
240
|
+
|
|
241
|
+
initialize_testbase_results()
|
|
242
|
+
|
|
243
|
+
logger = getEnhancedLogger()
|
|
244
|
+
|
|
245
|
+
# STEP 6 - Create and kick off the job
|
|
246
|
+
|
|
247
|
+
from ccai.thisapp.wellknown import ConfiguredSuperFactorySingleton
|
|
248
|
+
from ccai.testbase.factoryprotocols import TestBaseFactoryProtocol
|
|
249
|
+
|
|
250
|
+
# At this point in the code, we either lookup an existing test job or we create a test job
|
|
251
|
+
# from the includes, excludes or test_module
|
|
252
|
+
sfactory = ConfiguredSuperFactorySingleton()
|
|
253
|
+
TestJobType = sfactory.get_override_types_by_order(TestBaseFactoryProtocol.get_testbase_default_job_type)
|
|
254
|
+
|
|
255
|
+
result_code = 0
|
|
256
|
+
tjob: ITestJob
|
|
257
|
+
|
|
258
|
+
with TestJobType(logger, test_root, includes=includes, excludes=excludes, metafilters=metafilters) as tjob:
|
|
259
|
+
result_code = tjob.execute()
|
|
260
|
+
|
|
261
|
+
sys.exit(result_code)
|
|
262
|
+
|
|
263
|
+
return
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.cli.cmdtree.utilities
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for utilities.
|
|
5
|
+
|
|
6
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
__author__ = "Myron Walker"
|
|
12
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
13
|
+
__credits__ = []
|
|
14
|
+
__version__ = "1.0.0"
|
|
15
|
+
|
|
16
|
+
from ccai.arcli import decorators as arcli
|
|
17
|
+
|
|
18
|
+
from ccai.testbase.cli.cmdtree.utilities.timestamp import command_testbase_utilities_timestamp
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@arcli.group("utilities")
|
|
22
|
+
def group_testbase_utilities():
|
|
23
|
+
"""
|
|
24
|
+
Contains various automation pipeline utility commands.
|
|
25
|
+
"""
|
|
26
|
+
return
|
|
27
|
+
|
|
28
|
+
group_testbase_utilities.add_command(command_testbase_utilities_timestamp)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.cli.cmdtree.utilities.timestamp
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for timestamp.
|
|
5
|
+
|
|
6
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
__author__ = "Myron Walker"
|
|
12
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
13
|
+
__credits__ = []
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from datetime import datetime
|
|
17
|
+
|
|
18
|
+
from ccai.arcli import decorators as arcli
|
|
19
|
+
|
|
20
|
+
@arcli.command("timestamp")
|
|
21
|
+
def command_testbase_utilities_timestamp():
|
|
22
|
+
"""
|
|
23
|
+
Command that prints a timestamp.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from ccai.xmodules.xdatetime import DATETIME_FORMAT_FILESYSTEM
|
|
27
|
+
|
|
28
|
+
now = datetime.now()
|
|
29
|
+
timestamp = now.strftime(DATETIME_FORMAT_FILESYSTEM).replace(" ", "T")
|
|
30
|
+
|
|
31
|
+
print(timestamp)
|
|
32
|
+
|
|
33
|
+
return
|