Skip to content

Run negative library-style tests instead of skipping them - #152

Open
bryantaustin13 wants to merge 1 commit into
cqframework:mainfrom
bryantaustin13:negative-library-tests
Open

bryantaustin13 wants to merge 1 commit into
cqframework:mainfrom
bryantaustin13:negative-library-tests

Conversation

@bryantaustin13

@bryantaustin13 bryantaustin13 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #151.

Problem

A library-style test marked invalid, with no <output>, was always skipped with "Library-style test output has no 'name' attribute naming the define to evaluate". So a negative library test could never pass or fail. cqframework/cql-tests#142's AmbiguousOverload is one: an overload call that should fail to translate.

Change

src/shared/results-shared.ts:

  • Result constructor: a library test with no <output> no longer skips in the library branch. It falls through to the shared check after the branch, which already allows a missing <output> when invalid is true or semantic, and skips with "No output specified" otherwise. That's the same rule expression tests follow.
  • generateParametersResource: when no define is named, the expression parameter is left out, so Library/$evaluate evaluates the whole library.

Scoring is unchanged. run-test-core.ts already scores invalid true/semantic as pass only when the response indicates an error.

Tests

  • test/library-style-tests.test.ts:
    • a negative test with no output runs, with expression set to '';
    • a test with no output that doesn't expect an error still skips;
    • the parameters for a negative test contain only url.
  • test/run-tests.test.ts: a negative library test passes when Library/$evaluate returns an error, and fails when the library evaluates.

npx vitest run test/: 240 passed (235 on main). tsc --noEmit reports the same two errors in src/server/rest-routes.ts as on main, which #139 addresses. I left test/run-tests.test.ts in its existing two-space style, which isn't Prettier-clean on main either.

Live run

Using cqframework/cql-tests#142's CqlOverloadMatching.xml against a local HAPI FHIR 8.12.0 server, with conf/localhost-evaluate.json:

Test main this branch
AmbiguousOverload skip ("Library-style test output has no 'name' attribute…") pass: "Library AmbiguousOverload-1.0.0 loaded, but had errors: Call to operator A(System.Integer) is ambiguous with: …"
the other five overload tests pass pass

The server accepted the PUT of the untranslatable library and reported the translation error at $evaluate, which settles #151's open question for HAPI. The published library was removed afterwards. Other servers may behave differently.

cql-execution couldn't be checked. Its test server only provides POST /fhir/$cql for a single expression, with no Library/$evaluate and no Library upload. The runner skips every library-style test on a $cql server before sending a request ("Library-style tests require a server configured for the Library/$evaluate operation"), on main and on this branch alike.

Related

🤖 Generated with Claude Code

A library test marked invalid with no <output> names no define, so it
was always skipped. Let it through when invalid expects an error, and
omit the expression parameter so Library/$evaluate evaluates the whole
library. Fixes cqframework#151.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Negative library-style tests (invalid, no <output>) are always skipped

1 participant