Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFC] Refactor PetstoreConsumerTests to allow multiple versions #157

Merged
merged 2 commits into from
Aug 1, 2023

Conversation

czechboy0
Copy link
Contributor

Motivation

In upcoming features that contain breaking changes, but we'll stage them in behind a feature flag, we'd like to have multiple variants of the PetstoreConsumerTests test target, allowing us to test both the existing behavior and the new behavior once a feature flag is enabled. These additional variants would be temporary, and would be deleted again (or rather, the main test suite would be updated) once the feature flag is enabled unconditionally. So the steady state number of PetstoreConsumerTest variants would continue to be 1, just for short periods of time, it might be higher.

Modifications

This PR makes that possible by refactoring common functionality into a new internal target PetstoreConsumerTestCore. Note that all the variants of the test target share the same OpenAPI document, but generate different variants of the reference code.

Highlights:

  • new PetstoreConsumerTestCore target, depended on by the existing PetstoreConsumerTests
  • added an ability to not fail the test when specific diagnostics are emitted (through the new ignoredDiagnosticMessages: Set<String> parameter), which allows us to test both existing and new behavior on the same OpenAPI document. Other, non-allowlisted diagnostics, still continue to fail the test, so new ones won't sneak through undetected.
  • many test functions now optionally take featureFlags and ignoredDiagnosticMessages, again allowing us to test both existing and proposed behavior hidden behind a feature flag

Result

It will be a lot easier to temporarily introduce other variants of the PetstoreConsumerTests test target to allow for thoroughly testing features even before they are enabled by default, giving us more confidence in the accuracy of proposals and their associated implementations.

Test Plan

All tests continue to pass, this is an NFC, a pure refactoring, making the next PR much smaller. To see how this all fits together, check out the PR that has all the changes: #146. That said, these partial PRs are easier to review, as they're each focused on one task.

@czechboy0 czechboy0 requested a review from simonjbeaumont July 31, 2023 14:27
@czechboy0
Copy link
Contributor Author

@swift-server-bot test this please

@czechboy0 czechboy0 changed the title Refactor PetstoreConsumerTests to allow multiple versions [NFC] Refactor PetstoreConsumerTests to allow multiple versions Aug 1, 2023
@czechboy0 czechboy0 added the semver/none No version bump required. label Aug 1, 2023
Copy link
Contributor

@gjcairo gjcairo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one small question

Tests/PetstoreConsumerTests/Common.swift Show resolved Hide resolved
@czechboy0 czechboy0 merged commit 379b047 into apple:main Aug 1, 2023
@czechboy0 czechboy0 deleted the hd-refactor-petstore-consumer-tests branch August 1, 2023 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/none No version bump required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants