Skip to content

Commit 3732a89

Browse files
vatsalghelani-csarestyled-commitsandy31415
authoredOct 11, 2024
Restyler Fixes for reverted PR #34785 (#36022)
* Refactoring of the matter testing infrastructure * Restyled by shfmt * Manually fix restyle * Manually fix restyle * Manually restyle * Manually fix restyle * Manually fix restyle * Renamed testing_support to matter_testing _support * Fixed the support scripts from matter_testing_support * Fixed TC_OVENOPSTATE_2_6.py for import command * replace all os.path.join and such (using _file_) with their own method * Fixed paths.py for import * Fixed imports for TC_DeviceConformace.py * Fixed the broken import for matter_testing * Make sure modules match master * Debug the data model files for spec_parsing * Try to guess data model root * Restyle * Moving Test* from python_testing to matter_testing_support * Removed the tests moved from glob python scripts * Restyled by isort * Added taglist_and_topology_test.py to the support tests list * Restyled by isort * Fixed the structure for accessing example_pics_xml_basic_info.xml * Fixing the TC_RVCCLEANM_2_2.py script according to master changes * Changes according to master * Fixing structuring of TestMatterTestingSupport.py and TestSpecParsingSupport.py * Restyled by isort * Fixed typo on src/python_testing/matter_testing_infrastructure/BUILD.gn tests section * Fixed import for TC_ICDM_3_2.py * Fix Import for TC_RVCCLEANM_2_2.py * Restyled by autopep8 * Update line formatting in TestSpecParsingSupport.py * Fixed comment on execute_python_tests.py * tests.yaml test * Test to fix src/python_testing/test_testing directory imports * Restyled by isort * Fixed code lints * Fix imports for test_testing directory * Fixed imports on test_TC_ICDM_2_1.py * Restyled by autopep8 * Restyled by isort * Updated imported fixes on test_TC_ICDM_2_1.py * Restyled by autopep8 * Restyled by isort * Import fixes for parent directory test imports * Fixing try-except imports for test_testing directory scripts * Remove unwanted import os from 2 scripts * Restyled by isort * Restyled by isort * Restyled by autopep8 * Restyled by isort * Updated paths and spec_xml scripts * Fixed unused imports * Restyled by isort * Try to guess data model root * Fixed wrong string via GUI that was set in vscode * Fix matter_testing imports * Comment * Remove comment * Fixed import and improved logging via flush of stdout * Fixed matter support import for test scripts * Restyled by isort * Fixed "os.environ is not callable, it is a dictionary" Co-authored-by: Andrei Litvin <andy314@gmail.com> * Import fixed for TC_CCTRL_2_3.py * Update logic to match master * Fixed multiple executions of the same tests * Fixed test_testing scripts with master * Restyled by isort * Fixing code lints * Restyled by autopep8 * Fix formate changes happened with autosave on TestSpecParsingSupport.py * Fixed module import in MockTestRunner script * Restructured the tasks.py scripts in matter_testing_support * Fixed formatting * Restyled by shfmt * Restyled by isort * Fixed code lints * Fixed imports for the new scripts added * Fixed k1_4 for the test script * Restyled by autopep8 * Fixed import for new scripts added * Added support for v1_4 * Update TestSpecParsingSupport.py * Added the missed part of the code after hard reset from commit d0e3690 * Print statements to test * Update TestSpecParsingSupport.py * Added in_progress for DEFAULT_OUTPUT_DIR_IN_PROGRESS * Added support for conformance_support in atomic attributes * Removing test prints statements * Restyled by isort * Checking in Thermostat's Revision * Check and Verified Cluster Thermostats's Revision * Restyled by isort * Fixed improts with news supports apps.py * Restyled by isort * Fixed imports for ECOINFO scripts * Restyled by isort * Renamed matter_testing_support to chip.testing * Update TestSpecParsingSupport.py * Restyled by shfmt * Restyled by isort * Fixed imports and correct wheel errors * Fixed chip_testing wheel * Update build_python.sh * Fixed the restyler added f-strings breaks * Restyled by autopep8 * Restyled by isort --------- Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Andrei Litvin <andy314@gmail.com>
1 parent 907caa6 commit 3732a89

File tree

203 files changed

+474
-380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

203 files changed

+474
-380
lines changed
 

‎docs/testing/python.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Python tests located in src/python_testing
2525
section should include various parameters and their respective values,
2626
which will guide the test runner on how to execute the tests.
2727
- All test classes inherit from `MatterBaseTest` in
28-
[matter_testing_support.py](https://github.com/project-chip/connectedhomeip/blob/master/src/python_testing/matter_testing_support.py)
28+
[matter_testing.py](https://github.com/project-chip/connectedhomeip/blob/master/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py)
2929
- Support for commissioning using the python controller
3030
- Default controller (`self.default_controller`) of type `ChipDeviceCtrl`
3131
- `MatterBaseTest` inherits from the Mobly BaseTestClass
@@ -38,7 +38,7 @@ Python tests located in src/python_testing
3838
decorated with the @async_test_body decorator
3939
- Use `ChipDeviceCtrl` to interact with the DUT
4040
- Controller API is in `ChipDeviceCtrl.py` (see API doc in file)
41-
- Some support methods in `matter_testing_support.py`
41+
- Some support methods in `matter_testing.py`
4242
- Use Mobly assertions for failing tests
4343
- `self.step()` along with a `steps_*` method to mark test plan steps for cert
4444
tests
@@ -379,7 +379,7 @@ pai = await dev_ctrl.SendCommand(nodeid, 0, Clusters.OperationalCredentials.Comm
379379
## Mobly helpers
380380

381381
The test system is based on Mobly, and the
382-
[matter_testing_support.py](https://github.com/project-chip/connectedhomeip/blob/master/src/python_testing/matter_testing_support.py)
382+
[matter_testing.py](https://github.com/project-chip/connectedhomeip/blob/master/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py)
383383
class provides some helpers for Mobly integration.
384384

385385
- `default_matter_test_main`
@@ -561,11 +561,11 @@ these steps to set this up:
561561

562562
## Other support utilities
563563

564-
- `basic_composition_support`
564+
- `basic_composition`
565565
- wildcard read, whole device analysis
566566
- `CommissioningFlowBlocks`
567567
- various commissioning support for core tests
568-
- `spec_parsing_support`
568+
- `spec_parsing`
569569
- parsing data model XML into python readable format
570570

571571
# Running tests locally

‎scripts/spec_xml/generate_spec_xml.py

+22-38
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,17 @@
2424
from pathlib import Path
2525

2626
import click
27+
from paths import Branch, get_chip_root, get_data_model_path, get_documentation_file_path, get_in_progress_defines
2728

28-
DEFAULT_CHIP_ROOT = os.path.abspath(
29-
os.path.join(os.path.dirname(__file__), '..', '..'))
30-
DEFAULT_OUTPUT_DIR_1_3 = os.path.abspath(
31-
os.path.join(DEFAULT_CHIP_ROOT, 'data_model', '1.3'))
32-
DEFAULT_OUTPUT_DIR_IN_PROGRESS = os.path.abspath(
33-
os.path.join(DEFAULT_CHIP_ROOT, 'data_model', 'in_progress'))
34-
DEFAULT_OUTPUT_DIR_TOT = os.path.abspath(
35-
os.path.join(DEFAULT_CHIP_ROOT, 'data_model', 'master'))
36-
DEFAULT_DOCUMENTATION_FILE = os.path.abspath(
37-
os.path.join(DEFAULT_CHIP_ROOT, 'docs', 'spec_clusters.md'))
38-
39-
# questions
40-
# is energy-calendar still in?
41-
# is heat-pump out? wasn't in 0.7
42-
# location-cluster - is this define gone now?
43-
# queuedpreset - is this define gone now?
44-
CURRENT_IN_PROGRESS_DEFINES = ['aliro', 'atomicwrites', 'battery-storage', 'device-location', 'e2e-jf', 'energy-calendar', 'energy-drlc',
45-
'energy-management', 'heat-pump', 'hrap-1', 'hvac', 'matter-fabric-synchronization', 'metering', 'secondary-net',
46-
'service-area-cluster', 'solar-power', 'tcp', 'water-heater', 'wifiSetup']
29+
# Use the get_in_progress_defines() function to fetch the in-progress defines
30+
CURRENT_IN_PROGRESS_DEFINES = get_in_progress_defines()
31+
32+
# Replace hardcoded paths with dynamic paths using paths.py functions
33+
DEFAULT_CHIP_ROOT = get_chip_root()
34+
DEFAULT_OUTPUT_DIR_1_3 = get_data_model_path(Branch.V1_3)
35+
DEFAULT_OUTPUT_DIR_IN_PROGRESS = get_data_model_path(Branch.IN_PROGRESS)
36+
DEFAULT_OUTPUT_DIR_TOT = get_data_model_path(Branch.MASTER)
37+
DEFAULT_DOCUMENTATION_FILE = get_documentation_file_path()
4738

4839

4940
def get_xml_path(filename, output_dir):
@@ -90,7 +81,6 @@ def make_asciidoc(target: str, include_in_progress: str, spec_dir: str, dry_run:
9081
'--include-in-progress',
9182
type=click.Choice(['All', 'None', 'Current']), default='All')
9283
def main(scraper, spec_root, output_dir, dry_run, include_in_progress):
93-
# Clusters need to be scraped first because the cluster directory is passed to the device type directory
9484
if not output_dir:
9585
output_dir_map = {'All': DEFAULT_OUTPUT_DIR_TOT, 'None': DEFAULT_OUTPUT_DIR_1_3, 'Current': DEFAULT_OUTPUT_DIR_IN_PROGRESS}
9686
output_dir = output_dir_map[include_in_progress]
@@ -103,30 +93,28 @@ def main(scraper, spec_root, output_dir, dry_run, include_in_progress):
10393

10494
def scrape_clusters(scraper, spec_root, output_dir, dry_run, include_in_progress):
10595
src_dir = os.path.abspath(os.path.join(spec_root, 'src'))
106-
sdm_clusters_dir = os.path.abspath(
107-
os.path.join(src_dir, 'service_device_management'))
96+
sdm_clusters_dir = os.path.abspath(os.path.join(src_dir, 'service_device_management'))
10897
app_clusters_dir = os.path.abspath(os.path.join(src_dir, 'app_clusters'))
10998
dm_clusters_dir = os.path.abspath(os.path.join(src_dir, 'data_model'))
110-
media_clusters_dir = os.path.abspath(
111-
os.path.join(app_clusters_dir, 'media'))
112-
clusters_output_dir = os.path.abspath(os.path.join(output_dir, 'clusters'))
99+
media_clusters_dir = os.path.abspath(os.path.join(app_clusters_dir, 'media'))
100+
101+
clusters_output_dir = os.path.join(output_dir, 'clusters')
113102

114103
if not os.path.exists(clusters_output_dir):
115104
os.makedirs(clusters_output_dir)
116105

117-
print('Generating main spec to get file include list - this make take a few minutes')
106+
print('Generating main spec to get file include list - this may take a few minutes')
118107
main_out = make_asciidoc('pdf', include_in_progress, spec_root, dry_run)
119-
print('Generating cluster spec to get file include list - this make take a few minutes')
108+
print('Generating cluster spec to get file include list - this may take a few minutes')
120109
cluster_out = make_asciidoc('pdf-appclusters-book', include_in_progress, spec_root, dry_run)
121110

122111
def scrape_cluster(filename: str) -> None:
123112
base = Path(filename).stem
124113
if base not in main_out and base not in cluster_out:
125-
print(f'skipping file: {base} as it is not compiled into the asciidoc')
114+
print(f'Skipping file: {base} as it is not compiled into the asciidoc')
126115
return
127116
xml_path = get_xml_path(filename, clusters_output_dir)
128-
cmd = [scraper, 'cluster', '-i', filename, '-o',
129-
xml_path, '-nd']
117+
cmd = [scraper, 'cluster', '-i', filename, '-o', xml_path, '-nd']
130118
if include_in_progress == 'All':
131119
cmd.extend(['--define', 'in-progress'])
132120
elif include_in_progress == 'Current':
@@ -150,33 +138,29 @@ def scrape_all_clusters(dir: str, exclude_list: list[str] = []) -> None:
150138
tree = ElementTree.parse(f'{xml_path}')
151139
root = tree.getroot()
152140
cluster = next(root.iter('cluster'))
153-
# If there's no cluster ID table, this isn't a cluster
154141
try:
155142
next(cluster.iter('clusterIds'))
156143
except StopIteration:
157-
# If there's no cluster ID table, this isn't a cluster just some kind of intro adoc
158144
print(f'Removing file {xml_path} as it does not include any cluster definitions')
159145
os.remove(xml_path)
160146
continue
161147

162148

163149
def scrape_device_types(scraper, spec_root, output_dir, dry_run, include_in_progress):
164-
device_type_dir = os.path.abspath(
165-
os.path.join(spec_root, 'src', 'device_types'))
166-
device_types_output_dir = os.path.abspath(
167-
os.path.join(output_dir, 'device_types'))
150+
device_type_dir = os.path.abspath(os.path.join(spec_root, 'src', 'device_types'))
151+
device_types_output_dir = os.path.abspath(os.path.join(output_dir, 'device_types'))
168152
clusters_output_dir = os.path.abspath(os.path.join(output_dir, 'clusters'))
169153

170154
if not os.path.exists(device_types_output_dir):
171155
os.makedirs(device_types_output_dir)
172156

173-
print('Generating device type library to get file include list - this make take a few minutes')
157+
print('Generating device type library to get file include list - this may take a few minutes')
174158
device_type_output = make_asciidoc('pdf-devicelibrary-book', include_in_progress, spec_root, dry_run)
175159

176160
def scrape_device_type(filename: str) -> None:
177161
base = Path(filename).stem
178162
if base not in device_type_output:
179-
print(f'skipping file: {filename} as it is not compiled into the asciidoc')
163+
print(f'Skipping file: {filename} as it is not compiled into the asciidoc')
180164
return
181165
xml_path = get_xml_path(filename, device_types_output_dir)
182166
cmd = [scraper, 'devicetype', '-c', '-cls', clusters_output_dir,

0 commit comments

Comments
 (0)