Allow mandatory tests to be sideloaded - #346
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the SDK Python test parsing logic by replacing the boolean mandatory flag with a new CollectionType enum, allowing for more granular control over test suite selection. Feedback on the changes points out that the CollectionType enum values are defined inconsistently, using single-element tuples for some members and a plain integer for another, and suggests standardizing them as simple integers.
|
LGTM @greens, Just need to point out one correction: please change the base of the PR to the target TH version. We usually just pull done releases to the main AFAIK. |
|
Tick the box to add this pull request to the merge queue (same as
|
030e171
into
project-chip:v2.15.1-develop
PR #346 ("Allow mandatory tests to be sideloaded") replaced the mandatory: bool flag in __parse_python_tests() with a 3-valued CollectionType enum, but the LEGACY-suite fallback branch lost its python_test_type != MANDATORY guard in the process: elif collection_type != CollectionType.MANDATORY: suites[SuiteType.LEGACY].add_test_case(test_case) This only checks the target collection, not the test's own type, so when building the NON_MANDATORY ("SDK Python Tests") collection, any test case whose type is MANDATORY falls through the COMMISSIONING/NO_COMMISSIONING branches and lands in the LEGACY ("Old script format") suite anyway. The same test case is also correctly added to SuiteType.MANDATORY when the MANDATORY collection is built, so it ends up listed - and executed - in both collections. Restore the type guard so mandatory tests are excluded from the LEGACY suite when populating the NON_MANDATORY collection, while still landing in SuiteType.MANDATORY for CollectionType.ALL (sideload) per PR #346's intent. Adds a dedicated fixture file (mandatory_tests_info.json) with a mandatory-shaped test case, so the new regression test doesn't perturb the existing python_tests_info.json fixture shared with test_python_parser.py's hardcoded test-count assertion. Fixes project-chip/certification-tool#1087
) PR #346 ("Allow mandatory tests to be sideloaded") replaced the mandatory: bool flag in __parse_python_tests() with a 3-valued CollectionType enum, but the LEGACY-suite fallback branch lost its python_test_type != MANDATORY guard in the process: elif collection_type != CollectionType.MANDATORY: suites[SuiteType.LEGACY].add_test_case(test_case) This only checks the target collection, not the test's own type, so when building the NON_MANDATORY ("SDK Python Tests") collection, any test case whose type is MANDATORY falls through the COMMISSIONING/NO_COMMISSIONING branches and lands in the LEGACY ("Old script format") suite anyway. The same test case is also correctly added to SuiteType.MANDATORY when the MANDATORY collection is built, so it ends up listed - and executed - in both collections. Restore the type guard so mandatory tests are excluded from the LEGACY suite when populating the NON_MANDATORY collection, while still landing in SuiteType.MANDATORY for CollectionType.ALL (sideload) per PR #346's intent. Adds a dedicated fixture file (mandatory_tests_info.json) with a mandatory-shaped test case, so the new regression test doesn't perturb the existing python_tests_info.json fixture shared with test_python_parser.py's hardcoded test-count assertion. Fixes project-chip/certification-tool#1087
…fix (#360) * Allow mandatory tests to be sideloaded (#346) Cherry-picked from v2.15.1-develop. There was/is a small quirk in the logic that would prevent mandatory tests from the list in python_test_parser.py from being added when custom tests were collated. * Fix mandatory Python tests duplicated into Old Script Format suite (#358) Cherry-picked from v2.15.1-develop. PR #346 ("Allow mandatory tests to be sideloaded", cherry-picked in the prior commit) replaced the mandatory: bool flag in __parse_python_tests() with a 3-valued CollectionType enum, but the LEGACY-suite fallback branch lost its python_test_type != MANDATORY guard in the process: elif collection_type != CollectionType.MANDATORY: suites[SuiteType.LEGACY].add_test_case(test_case) This only checks the target collection, not the test's own type, so when building the NON_MANDATORY ("SDK Python Tests") collection, any test case whose type is MANDATORY falls through the COMMISSIONING/NO_COMMISSIONING branches and lands in the LEGACY ("Old script format") suite anyway. The same test case is also correctly added to SuiteType.MANDATORY when the MANDATORY collection is built, so it ends up listed - and executed - in both collections. Restore the type guard so mandatory tests are excluded from the LEGACY suite when populating the NON_MANDATORY collection, while still landing in SuiteType.MANDATORY for CollectionType.ALL (sideload) per PR #346's intent. Fixes project-chip/certification-tool#1087
Fixes project-chip/certification-tool#1073
There was/is a small quirk in the logic that would prevent mandatory tests from this list: https://github.com/project-chip/certification-tool-backend/blob/main/test_collections/matter/sdk_tests/support/python_testing/models/python_test_parser.py#L36 from being added when custom tests were collated.
This is the lightest-touch fix. I think possibly there could be a total re-evaluation of the mandatory field that shows up in so many places, but for now this will fix the issue.