Skip to content

Various VersionNumber changes of merit. #1246

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Jul 30, 2025

This PR does things to ABI.VersionNumber:

  • Renames it to VersionNumber as we do have some use cases that aren't related to JSON schema versioning. I initially didn't want to make this type a general version number type, but it's just too useful not to do so. Alas.

  • Changes the type of the swiftStandardLibraryVersion global variable to VersionNumber?.

  • Changes the type of the glibcVersion global variable to VersionNumber.

  • Adds swiftCompilerVersion representing the version of the Swift compiler used to compile Swift Testing. We need this value when computing the JSON schema version (see next bullet.)

  • Clamps the range of supported JSON schema versions to the Swift compiler version unless we've explicitly defined a schema version higher than it:

    Compiler Highest Defined Schema Requested Result
    1.0 1.0 1.0 1.0
    1.0 1.0 2.0 nil
    2.0 2.0 1.0 1.0
    2.0 1.0 2.0 1.0
    1.0 2.0 2.0 2.0
    2.0 2.0 2.0 2.0

    The reasoning here is that, when we're built with a given compiler version, we presumably know about all JSON schema versions up to and including the one aligned with that compiler, so if you ask for the schema version aligned with the compiler, it's equivalent to whatever we support that's less than or equal to the compiler version. But if you ask for something greater than the compiler version, and we haven't defined it, we don't know anything about it and can't provide it.

    This reasoning breaks down somewhat if you build an old version of the Swift Testing package with a new compiler, but in general we don't support that sort of configuration for very long (and we can't predict the future anyway.)

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR does things to `ABI.VersionNumber`:

- Renames it to `VersionNumber` as we do have some use cases that aren't related
  to JSON schema versioning. I initially didn't want to make this type a general
  version number type, but it's just too useful not to do so. Alas.
- Changes the type of the `swiftStandardLibraryVersion` global variable to
  `VersionNumber?`.
- Adds `swiftCompilerVersion` representing the version of the Swift compiler
  used to compile Swift Testing. We need this value when computing the JSON
  schema version (see next bullet.)
- Clamps the range of supported JSON schema versions to the Swift compiler
  version _unless_ we've explicitly defined a schema version higher than it:

  | Compiler | Highest Defined Schema | Requested | Result |
  |-|-|-|-|
  | 1.0 | 1.0 | 1.0 | 1.0 |
  | 2.0 | 1.0 | 1.0 | 1.0 |
  | 1.0 | 2.0 | 1.0 | 1.0 |
  | 1.0 | 1.0 | 2.0 | `nil` |
  | 2.0 | 2.0 | 1.0 | 1.0 |
  | 2.0 | 1.0 | 2.0 | 1.0 |
  | 1.0 | 2.0 | 2.0 | 2.0 |
  | 2.0 | 2.0 | 2.0 | 2.0 |

  The reasoning here is that, when we're built with a given compiler version, we
  presumably know about all JSON schema versions up to and including the one
  aligned with that compiler, so if you ask for the schema version aligned with
  the compiler, it's equivalent to whatever we support that's less than or equal
  to the compiler version. But if you ask for something greater than the
  compiler version, and we haven't defined it, we don't know anything about it
  and can't provide it.

  This reasoning breaks down somewhat if you build an old version of the Swift
  Testing package with a new compiler, but in general we don't support that sort
  of configuration for very long (and we can't predict the future anyway.)
@grynspan grynspan added this to the Swift 6.x (main) milestone Jul 30, 2025
@grynspan grynspan self-assigned this Jul 30, 2025
@grynspan grynspan added enhancement New feature or request tools integration 🛠️ Integration of swift-testing into tools/IDEs build 🧱 Affects the project's build configuration or process labels Jul 30, 2025
@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test Linux

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test macOS

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test

@@ -16,6 +16,14 @@

SWT_ASSUME_NONNULL_BEGIN

static inline uint64_t swt_getSwiftCompilerVersion(void) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be documented, for example to show what format the number is expected to be in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build 🧱 Affects the project's build configuration or process enhancement New feature or request tools integration 🛠️ Integration of swift-testing into tools/IDEs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants