Skip to content

Carry group-level <capability> onto each test result - #122

Open
bryantaustin13 wants to merge 1 commit into
mainfrom
group-capabilities
Open

Carry group-level <capability> onto each test result#122
bryantaustin13 wants to merge 1 commit into
mainfrom
group-capabilities

Conversation

@bryantaustin13

Copy link
Copy Markdown
Contributor

A <capability> on a <group> applies to every test inside it, but Result only ever read the test's own, so group declarations were dropped entirely. In the suite:

  • 996 of 1,016 groups declare their own <capability>
  • 1,670 tests declare none of their own — for those, the group's declaration was the only source, so they reported no capabilities at all

Measured against cql-tests/tests/connectathonTests (2,035 tests loaded), tests reporting no capability drop from 469 to 39.

Changes

  • results-shared.ts — reported capabilities are now the union of the test's own and its group's, deduplicated by code with the test's entry winning, since it is the more specific declaration. Most tests restate their group's capability, so for them the union is identical to what was reported before; the gain is for the tests declaring none.
  • The single-vs-array normalization already needed for test capabilities applies equally to group ones, so it is factored out into normalizeCapabilities and shared rather than duplicated.
  • test-types.tsTestGroup.capability typed CapabilityKV | CapabilityKV[] to match what the XML parser produces, consistent with Test.capability.
  • The group is passed at all three Result call sites — the loader plus both server entry points — so the CLI and server paths report the same capabilities.
  • Five tests added covering inheritance, merging, the same-code override, single-vs-array equivalence, and the no-group case.

tsc --noEmit clean, 194 tests passing. No schema change needed — this populates the existing capabilities field rather than adding one.

Split out of #119

#119 carried a groupCapability field for this, but nothing ever emitted it, so as written it collected data that never reached the results file. This reports the capabilities through the existing field instead, and is independent of #119's timezone work.

A <capability> on a <group> applies to every test in it, but Result only ever
read the test's own, so group declarations were dropped. 996 of the 1,016
groups in the suite declare one, and 1,670 tests declare none of their own —
those tests reported no capabilities at all.

The reported capabilities are now the union of the test's own and its group's,
deduplicated by code with the test's entry winning, since it is the more
specific declaration. Most tests restate their group's capability, so for them
the union is unchanged; the gain is for the tests that declare none.

Measured against cql-tests/tests/connectathonTests, 2,035 tests loaded:
tests reporting no capability drop from 469 to 39.

The single-vs-array normalization already needed for test capabilities applies
equally to group ones, so it is factored into normalizeCapabilities and shared.
TestGroup.capability is typed CapabilityKV | CapabilityKV[] to match, and the
group is passed at all three Result call sites — the loader and both server
entry points — so the CLI and server paths agree.
bryantaustin13 added a commit that referenced this pull request Aug 18, 2026
Ports the timezone-offset policy feature onto the deduped runner and drops the
parts main has since covered.

Dropped, both entirely superseded:
  test-types.ts, results-shared.ts   this branch's groupCapability work. Nothing
                                     emitted the field, so it collected data that
                                     never reached the results file; #122 reports
                                     group capabilities through the existing
                                     capabilities field instead. Took main's
                                     versions of both files.
  test-runner.ts                     #117 moved the per-test logic into
                                     shared/run-test-core.ts, so the 260 lines
                                     this branch added there are ported rather
                                     than restored. Took main's version.

Ported into run-test-core.ts, so the CLI and server paths share it:
  - policy resolution (metadata -> env/config -> probe -> default), run once per
    execution context rather than per test
  - a skip arm for tests declaring a timezone-offset-policy capability that does
    not match the server's
  - {{SERVER_OFFSET_ISO}} substitution, applied to result.expression before the
    request is built so the expression sent and the expression reported match

Two changes from the original while porting:

Resolution is gated on the loaded suite actually containing a policy-dependent
test. It costs a metadata request and possibly a probe expression, and almost no
suite consults it; doing it unconditionally also broke tests that stub CQLEngine
or sequence fetch mocks.

The required policy is read from result.capability rather than test.capability.
In CQLTimeZoneOffsetTest.xml the policy is declared on the <group>, and one of
the three groups does not restate it on its tests — reading only the test level
silently never gated those. This depends on #122 to see group capabilities;
until that merges, group-level declarations still are not visible.

The probe now uses fetch only, since the dedupe removed the axios path, and
CQLEngine gains a serverMetadata getter so the resolution can read the
CapabilityStatement without reaching into a private field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants