Skip to content

Define custom availability domain for Testing symbols - #1992

Open
jerryjrchen wants to merge 2 commits into
swiftlang:mainfrom
jerryjrchen:custom-availability-domain
Open

jerryjrchen wants to merge 2 commits into
swiftlang:mainfrom
jerryjrchen:custom-availability-domain

Conversation

@jerryjrchen

@jerryjrchen jerryjrchen commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Define custom availability domain for Testing symbols

Motivation:

This domain (currently named TestingExperimentalDevelopmentOnly) can
be applied to test library symbols to selectively include/exclude them
at build time.

Once the domain is enabled, import Testing should give you access:

import Testing

@available(TestingExperimentalDevelopmentOnly) func developmentOnly() {}

The domain is experimental and final name TBD.

Modifications:

Define custom availability header for Swift Testing.

Resolves rdar://191149379

Checklist:

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

@jerryjrchen jerryjrchen added this to the Swift 6.4.2 milestone Oct 28, 2026
@jerryjrchen jerryjrchen self-assigned this Oct 28, 2026
@jerryjrchen jerryjrchen added the enhancement New feature or request label Oct 28, 2026
Comment thread Sources/Testing/Testing.h Resolved
Comment thread Sources/Testing/module.modulemap Resolved
Comment thread Sources/Testing/Testing.h Resolved
Comment thread Sources/Testing/Testing.h Resolved
@jerryjrchen
jerryjrchen force-pushed the custom-availability-domain branch from bc69ea8 to d411e60 Compare October 28, 2026 23:05
@jerryjrchen
jerryjrchen force-pushed the custom-availability-domain branch from d411e60 to 075ac94 Compare October 28, 2026 23:14
@jerryjrchen
jerryjrchen force-pushed the custom-availability-domain branch from 075ac94 to bd25773 Compare October 29, 2026 18:56
### Motivation:

This domain (currently named `TestingExperimentalDevelopmentOnly`) can
be applied to test library symbols to selectively include/exclude them
at build time.

Once the domain is enabled, `import Testing` should give you access:

```swift
import Testing

@available(ExperimentalDevelopmentOnly) func developmentOnly() {}
```

The domain is experimental and final name TBD.

### Modifications:

Define custom availability header for Swift Testing.

Resolves rdar://191149379

### Checklist:

- [ ] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [ ] If public symbols are renamed or modified, DocC references should be updated.
@jerryjrchen
jerryjrchen force-pushed the custom-availability-domain branch from bd25773 to 898073e Compare October 29, 2026 20:44
#define _SWIFT_TESTING_EXPERIMENTAL_DEVELOPMENT_AVAILABILITY_enabled 1
#define _SWIFT_TESTING_EXPERIMENTAL_DEVELOPMENT_AVAILABILITY_disabled 2

#define _SWT_MODE SWT_CONCAT(_SWIFT_TESTING_EXPERIMENTAL_DEVELOPMENT_AVAILABILITY_, _SWIFT_TESTING_EXPERIMENTAL_DEVELOPMENT_AVAILABILITY)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where is SWT_CONCAT defined?

#if !defined(SWT_AVAILABILITY_H)
#define SWT_AVAILABILITY_H

#include "Defines.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is Defines.h being used for?


#include "Defines.h"

#include <availability_domain.h>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To avoid issues like the one causing you to need to disable this for Android, we might want to inline the pieces of availability_domain.h we're referencing so this header can be completely standalone

@stmontgomery
stmontgomery self-requested a review October 30, 2026 20:26
// Any other value is an error.

#ifndef _SWIFT_TESTING_EXPERIMENTAL_DEVELOPMENT_AVAILABILITY
CLANG_ALWAYS_ENABLED_AVAILABILITY_DOMAIN(TestingExperimentalDevelopmentOnly);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm used to seeing the word "Experimental" at the beginning of experimental symbol names. Should/could this be ExperimentalTestingDevelopmentOnly?

@jerryjrchen
jerryjrchen force-pushed the custom-availability-domain branch from ea2efdb to d3d3802 Compare October 30, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants