mirror of
https://github.com/apple/swift-collections
synced 2026-11-27 04:54:21 +00:00
Merge pull request #102 from lorentey/release-prep
1.0 release preparations
This commit is contained in:
57 files changed
+414
-267
No files matched your search
@@ -48,62 +48,6 @@
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "swift-collections-benchmark"
|
||||
BuildableName = "swift-collections-benchmark"
|
||||
BlueprintName = "swift-collections-benchmark"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "CollectionsTestSupport"
|
||||
BuildableName = "CollectionsTestSupport"
|
||||
BlueprintName = "CollectionsTestSupport"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "Benchmarks"
|
||||
BuildableName = "Benchmarks"
|
||||
BlueprintName = "Benchmarks"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "CppBenchmarks"
|
||||
BuildableName = "CppBenchmarks"
|
||||
BlueprintName = "CppBenchmarks"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "NO"
|
||||
@@ -132,6 +76,20 @@
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "NO"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "_CollectionsTestSupport"
|
||||
BuildableName = "_CollectionsTestSupport"
|
||||
BlueprintName = "_CollectionsTestSupport"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
@@ -182,16 +140,6 @@
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "swift-collections-benchmark"
|
||||
BuildableName = "swift-collections-benchmark"
|
||||
BlueprintName = "swift-collections-benchmark"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
@@ -199,16 +147,15 @@
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "swift-collections-benchmark"
|
||||
BuildableName = "swift-collections-benchmark"
|
||||
BlueprintName = "swift-collections-benchmark"
|
||||
BlueprintIdentifier = "Collections"
|
||||
BuildableName = "Collections"
|
||||
BlueprintName = "Collections"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
# Package Internals
|
||||
|
||||
## Benchmarks
|
||||
|
||||
The package includes an extensive library of benchmarks in the [Benchmarks](./Benchmarks) directory, driven by a command-line executable target, called `benchmark`. These benchmarks, the executable target, and its command-line interface are not considered part of the public interface of the package. As such, new releases may break them without any special ceremony. We do expect the benchmarks will stabilize with time.
|
||||
|
||||
For more information on our benchmarking tool, please see its dedicated package, [**Swift Collections Benchmark**][swift-collections-benchmark].
|
||||
|
||||
[swift-collections-benchmark]: https://github.com/apple/swift-collections-benchmark
|
||||
|
||||
## Test Support Library
|
||||
|
||||
The package comes with a rich test support library in the [Sources/_CollectionsTestSupport](./Sources/_CollectionsTestSupport) directory. These were loosely adapted from the contents of the `StdlibUnittest*` modules in the [Swift compiler repository](https://github.com/apple/swift/tree/main/stdlib/private), with some custom additions.
|
||||
|
||||
These components would likely be of interest to the wider Swift community, but they aren't yet stable enough (or documented enough) to publish them. Accordingly, these testing helpers are currently considered implementation details of this package, and are subject to change at whim.
|
||||
|
||||
The test support library currently provides the following functionality:
|
||||
|
||||
- [`AssertionContexts`](./Sources/CollectionsTestSupport/AssertionContexts): Custom test assertions with support for keeping track of nested context information, including stopping execution when the current context matches a particular value. (Useful for debugging combinatorial tests.)
|
||||
|
||||
<details>
|
||||
<summary><strong>Click here for a short demonstration</strong></summary>
|
||||
|
||||
```swift
|
||||
import XCTest
|
||||
import _CollectionsTestSupport
|
||||
|
||||
final class DequeTests: CollectionTestCase {
|
||||
func test_demo() {
|
||||
let values = [0, 10, 20, 30, 42, 50, 60]
|
||||
for i in values.indices {
|
||||
context.withTrace("i: \(i)") {
|
||||
expectEqual(values[i], 10 * i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
DemoTests.swift:21: error: -[DemoTests.DemoTests test_demo] : XCTAssertEqual failed: ("42") is not equal to ("40") -
|
||||
Trace:
|
||||
- i: 4
|
||||
```
|
||||
|
||||
To debug issues, copy the trace message into a `context.failIfTraceMatches(_:)` invocation and set a breakpoint on test failures.
|
||||
|
||||
```swift
|
||||
let values = [0, 10, 20, 30, 42, 50, 60]
|
||||
for i in values.indices {
|
||||
context.withTrace("i: \(i)") {
|
||||
// This will report a test failure before executing the `i == 4` case,
|
||||
// letting us investigate what's going on.
|
||||
context.failIfTraceMatches("""
|
||||
Trace:
|
||||
- i: 4
|
||||
""")
|
||||
expectEqual(values[i], 10 * i)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
- [`Combinatorics`](./Sources/CollectionsTestSupport/AssertionContexts/Combinatorics.swift): Basic support for exhaustive combinatorial testing. This allows us to easily verify that a collection operation works correctly on all possible instances up to a certain size, including behavioral variations such as unique/shared storage.
|
||||
|
||||
<details>
|
||||
<summary><strong>Click here for an example</strong></summary>
|
||||
|
||||
```swift
|
||||
func test_popFirst() {
|
||||
withEveryDeque("deque", ofCapacities: [0, 1, 2, 3, 5, 10]) { layout in
|
||||
withEvery("isShared", in: [false, true]) { isShared in
|
||||
withLifetimeTracking { tracker in
|
||||
var (deque, contents) = tracker.deque(with: layout)
|
||||
withHiddenCopies(if: isShared, of: &deque) { deque in
|
||||
let expected = contents[...].popFirst()
|
||||
let actual = deque.popFirst()
|
||||
expectEqual(actual, expected)
|
||||
expectEqualElements(deque, contents)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
- [`ConformanceCheckers`](./Sources/CollectionsTestSupport/ConformanceCheckers): A set of generic, semi-automated protocol conformance tests for some Standard Library protocols. These can be used to easily validate the custom protocol conformances provided by this package. These checks aren't (can't be) complete -- but when used correctly, they are able to detect most accidental mistakes.
|
||||
|
||||
We currently have conformance checkers for the following protocols:
|
||||
|
||||
- [`Sequence`](./Sources/CollectionsTestSupport/ConformanceCheckers/CheckSequence.swift)
|
||||
- [`Collection`](./Sources/CollectionsTestSupport/ConformanceCheckers/CheckCollection.swift)
|
||||
- [`BidirectionalCollection`](./Sources/CollectionsTestSupport/ConformanceCheckers/CheckBidirectionalCollection.swift)
|
||||
- [`Equatable`](./Sources/CollectionsTestSupport/ConformanceCheckers/CheckEquatable.swift)
|
||||
- [`Hashable`](./Sources/CollectionsTestSupport/ConformanceCheckers/CheckHashable.swift)
|
||||
- [`Comparable`](./Sources/CollectionsTestSupport/ConformanceCheckers/CheckComparable.swift)
|
||||
|
||||
- [`MinimalTypes`](./Sources/CollectionsTestSupport/MinimalTypes): Minimally conforming implementations for standard protocols. These types conform to various standard protocols by implementing the requirements in as narrow-minded way as possible -- sometimes going to extreme lengths to, say, implement collection index invalidation logic in the most unhelpful way possible.
|
||||
|
||||
- [`MinimalSequence`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalSequence.swift)
|
||||
- [`MinimalCollection`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalCollection.swift)
|
||||
- [`MinimalBidirectionalCollection`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalBidirectionalCollection.swift)
|
||||
- [`MinimalRandomAccessCollection`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalRandomAccessCollection.swift)
|
||||
- [`MinimalMutableRandomAccessCollection`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalMutableRandomAccessCollection.swift)
|
||||
- [`MinimalRangeReplaceableRandomAccessCollection`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalRangeReplaceableRandomAccessCollection.swift)
|
||||
- [`MinimalMutableRangeReplaceableRandomAccessCollection`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalMutableRangeReplaceableRandomAccessCollection.swift)
|
||||
- [`MinimalIterator`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalIterator.swift)
|
||||
- [`MinimalIndex`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalIndex.swift)
|
||||
- [`MinimalEncoder`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalEncoder.swift)
|
||||
- [`MinimalDecoder`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalDecoder.swift)
|
||||
|
||||
- [`Utilities`](./Sources/CollectionsTestSupport/Utilities): Utility types. Wrapper types for boxed values, a simple deterministic random number generator, and a lifetime tracker for catching simple memory management issues such as memory leaks. (The [Address Sanitizer][asan] can be used to catch more serious problems.)
|
||||
|
||||
[asan]: https://developer.apple.com/documentation/xcode/diagnosing_memory_thread_and_crash_issues_early?language=objc
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
# Swift Collections Release Checklist
|
||||
|
||||
1. Create a milestone for the new version (if one doesn't exist yet).
|
||||
2. Collect all issues & PRs that are going to be included in the new tag under the new milestone.
|
||||
3. If the new release moves code between source files or adds new API that has the potential to cause mutual dependencies between source files, then run the [shuffle-sources.sh](./Utils/shuffle-sources.sh) script for at least a few hundred iterations on the affected module to help catch [nondeterministic build issues with the compiler's MergeModules phase](https://github.com/apple/swift-collections/issues/7). (Note: it's best to do this on a fresh clone. We can stop doing this when MergeModules is no longer used to build debug configurations in SPM.)
|
||||
4. Run the [full tests script](./Utils/run-full-tests.sh) on the commit that you intend to tag, with all supported (major) toolchain releases, and on as many supported platforms as are practical. (At minimum, run the script with the latest stable toolchain releases on macOS and one Linux distribution.)
|
||||
The script exercises a tiny subset of the environments this package can be built and run on.
|
||||
|
||||
The full matrix includes the following axes:
|
||||
|
||||
- Toolchains
|
||||
- All major Swift releases supported by the package, plus a recent toolchain snapshot from swift.org.
|
||||
E.g., for the Swift Collection 1.0 release, this included:
|
||||
- Swift 5.3 (from swift.org and Xcode 12)
|
||||
- Swift 5.4 (from swift.org and Xcode 12.5)
|
||||
- Prerelease builds of Swift 5.5 (using the latest swift.org snapshot and the latest Xcode 13 beta)
|
||||
- The latest `main` development snapshot from swift.org.
|
||||
- Platforms & architectures
|
||||
- macOS (using SPM, xcodebuild, cmake)
|
||||
- Intel, Apple Silicon
|
||||
- Deploying on any macOS release starting from macOS 10.10
|
||||
- Mac Catalyst (using xcodebuild)
|
||||
- Intel, Apple Silicon
|
||||
- Deploying on any macOS release starting from macOS 10.15
|
||||
- iOS (using xcodebuild)
|
||||
- Device (arm64, armv7), simulator (x86_64, i386, arm64)
|
||||
- Deploying on any iOS release starting from iOS 8
|
||||
- watchOS (using xcodebuild)
|
||||
- Device (arm64_32, arm7k), simulator (x86_64, i386, arm64)
|
||||
- Deploying on any watchOS release starting from watchOS 2
|
||||
- tvOS (using xcodebuild)
|
||||
- Device (arm64), simulator (x86_64, arm64)
|
||||
- Deploying on any tvOS 9 release starting from tvOS 10
|
||||
- Linux (using SPM, cmake)
|
||||
- All supported distributions
|
||||
- Build systems
|
||||
- Swift Package Manager
|
||||
- xcodebuild
|
||||
- cmake & ninja (note: this support isn't source stable)
|
||||
- Configurations
|
||||
- Debug
|
||||
- Release
|
||||
- Build settings
|
||||
- `COLLECTIONS_INTERNAL_CHECKS`
|
||||
- `COLLECTIONS_DETERMINISTIC_HASHING`
|
||||
- `BUILD_LIBRARY_FOR_DISTRIBUTION=YES` with xcodebuild (this is unsupported, but why break it)
|
||||
- `-warnings-as-errors`
|
||||
- Any combination of the above
|
||||
- Components
|
||||
- The swift-collections package
|
||||
- The private `benchmark` executable under `Benchmarks/`
|
||||
|
||||
5. Submit PRs to fix any issues that pop up, then try again until no issues are found.
|
||||
6. Update the README if necessary.
|
||||
7. Draft a new release on GitHub, following the template established by [previous releases](https://github.com/apple/swift-collections/releases/tag/0.0.7).
|
||||
8. As a final chance to catch issues, generate a diff between the last tagged release and the release candidate commit. Review it in case we landed something that isn't appropriate to include; watch out for potential issues such as source compatibility problems, or new public API without adequate documentation.
|
||||
9. Double check that the new tag will have the right version number and it will be on the correct branch.
|
||||
10. Hit publish.
|
||||
+4
-4
@@ -68,7 +68,7 @@ let package = Package(
|
||||
|
||||
// Testing support module
|
||||
.target(
|
||||
name: "CollectionsTestSupport",
|
||||
name: "_CollectionsTestSupport",
|
||||
dependencies: [],
|
||||
swiftSettings: settings,
|
||||
linkerSettings: [
|
||||
@@ -79,7 +79,7 @@ let package = Package(
|
||||
),
|
||||
.testTarget(
|
||||
name: "CollectionsTestSupportTests",
|
||||
dependencies: ["CollectionsTestSupport"],
|
||||
dependencies: ["_CollectionsTestSupport"],
|
||||
swiftSettings: settings),
|
||||
|
||||
// Deque<Element>
|
||||
@@ -89,7 +89,7 @@ let package = Package(
|
||||
swiftSettings: settings),
|
||||
.testTarget(
|
||||
name: "DequeTests",
|
||||
dependencies: ["DequeModule", "CollectionsTestSupport"],
|
||||
dependencies: ["DequeModule", "_CollectionsTestSupport"],
|
||||
swiftSettings: settings),
|
||||
|
||||
// OrderedSet<Element>, OrderedDictionary<Key, Value>
|
||||
@@ -99,7 +99,7 @@ let package = Package(
|
||||
swiftSettings: settings),
|
||||
.testTarget(
|
||||
name: "OrderedCollectionsTests",
|
||||
dependencies: ["OrderedCollections", "CollectionsTestSupport"],
|
||||
dependencies: ["OrderedCollections", "_CollectionsTestSupport"],
|
||||
swiftSettings: settings),
|
||||
]
|
||||
)
|
||||
@@ -20,7 +20,7 @@ The package currently provides the following implementations:
|
||||
[OrderedSet]: Documentation/OrderedSet.md
|
||||
[OrderedDictionary]: Documentation/OrderedDictionary.md
|
||||
|
||||
Swift Collections uses the same modularization approach as [**Swift Numerics**](https://github.com/apple/swift-numerics): it provides a standalone module for each group of data structures it implements. For instance, if you only need a double-ended queue type, you can pull in only that by importing `DequeModule`. `OrderedSet` and `OrderedDictionary` share much of the same underlying implementation, so they are provided by a single module, called `OrderedCollections`. However, there is also a top-level `Collections` module that gives you all of the included modules with a single import statement.
|
||||
Swift Collections uses the same modularization approach as [**Swift Numerics**](https://github.com/apple/swift-numerics): it provides a standalone module for each thematic group of data structures it implements. For instance, if you only need a double-ended queue type, you can pull in only that by importing `DequeModule`. `OrderedSet` and `OrderedDictionary` share much of the same underlying implementation, so they are provided by a single module, called `OrderedCollections`. However, there is also a top-level `Collections` module that gives you every collection type with a single import statement:
|
||||
|
||||
``` swift
|
||||
import Collections
|
||||
@@ -33,156 +33,70 @@ print(deque) // ["Keeley", "Ted", "Rebecca", "Nathan"]
|
||||
|
||||
## Project Status
|
||||
|
||||
We think the implementations in this package are robust, but the interfaces provided have not had time to stabilize. Accordingly, while the package is in its pre-1.0 state, from time to time new releases may sometimes include source-breaking changes. We'll try our best to keep such changes to a minimum, though, even during this chaotic initial period. Whenever feasible, we'll mitigate such changes with a multi-release deprecation period.
|
||||
The Swift Collections package is source stable. The version numbers follow [Semantic Versioning][semver] -- source breaking changes to public API can only land in a new major version.
|
||||
|
||||
Before the 1.0 release, releases containing potentially source-breaking changes will increase the middle version number. The release notes will explain what changed, and how to update your code to work with the new version.
|
||||
[semver]: https://semver.org
|
||||
|
||||
The implementations in this package have gone through an initial performance optimization pass, but there are lots of work still to be done. Still, we think these implementations are already quite fast enough for production use -- sometimes matching or exceeding the performance of similar constructs in popular prexisting implementations in other languages.
|
||||
The public API of version 1.0 of the `swift-collections` package consists of non-underscored declarations that are marked `public` in the `Collections`, `DequeModule` and `OrderedCollections` modules.
|
||||
|
||||
### Underscored Interfaces
|
||||
Interfaces that aren't part of the public API may continue to change in any release, including patch releases.
|
||||
If you have a use case that requires using underscored APIs, please [submit a Feature Request][enhancement] describing it! We'd like the public interface to be as useful as possible -- although preferably without compromising safety or limiting future evolution.
|
||||
|
||||
As customary in Swift, interfaces that are technically declared `public` but begin with an underscore are not considered part of the public interface of this package. We may remove or change them in any release without notice, including minor point releases. (If you have a use case that requires using them, please [submit a Feature Request][feature-request] describing it! We'd like the public interface to be as useful as possible -- preferably without compromising safety or limiting future evolution.)
|
||||
By "underscored declarations" we mean declarations that have a leading underscore anywhere in their fully qualified name. For instance, here are some names that wouldn't be considered part of the public API, even if they were technically marked public:
|
||||
|
||||
[feature-request]: https://github.com/apple/swift-collections/issues/new?assignees=&labels=enhancement&template=FEATURE_REQUEST.md
|
||||
- `FooModule.Bar._someMember(value:)` (underscored member)
|
||||
- `FooModule._Bar.someMember` (underscored type)
|
||||
- `_FooModule.Bar` (underscored module)
|
||||
- `FooModule.Bar.init(_value:)` (underscored initializer)
|
||||
|
||||
### Benchmarks
|
||||
Note that contents of the `Tests`, `Utils` and `Benchmarks` subdirectories aren't public API. We don't make any source compatibility promises about them -- they may change at whim, and code may be removed in any new release. Do not rely on anything about them.
|
||||
|
||||
The package includes an extensive library of benchmarks in the [Benchmarks](./Benchmarks) directory, driven by a command-line executable target, `swift-collections-benchmark`. These benchmarks, the executable target, and its command-line interface are not considered part of the public interface of the package. As such, new releases may break them without any special ceremony. We do expect the benchmarks will stabilize with time.
|
||||
|
||||
For more information on our benchmarking tool, please see its dedicated package, [**Swift Collections Benchmark**][swift-collections-benchmark].
|
||||
|
||||
[swift-collections-benchmark]: https://github.com/apple/swift-collections-benchmark
|
||||
|
||||
### Test Support Library
|
||||
|
||||
The package comes with a rich test support library in the [Sources/CollectionsTestSupport](./Sources/CollectionsTestSupport) directory. These were loosely adapted from the contents of the `StdlibUnittest*` modules in the [Swift compiler repository](https://github.com/apple/swift/tree/main/stdlib/private), with some custom additions.
|
||||
|
||||
These components would likely be of interest to the wider Swift community, but they aren't yet stable enough (or documented enough) to publish them. Accordingly, these testing helpers are currently considered implementation details of this package, and are subject to change at whim.
|
||||
|
||||
The test support library currently provides the following functionality:
|
||||
|
||||
- [`AssertionContexts`](./Sources/CollectionsTestSupport/AssertionContexts): Custom test assertions with support for keeping track of nested context information, including stopping execution when the current context matches a particular value. (Useful for debugging combinatorial tests.)
|
||||
|
||||
<details>
|
||||
<summary><strong>Click here for a short demonstration</strong></summary>
|
||||
|
||||
```swift
|
||||
import XCTest
|
||||
import CollectionsTestSupport
|
||||
|
||||
final class DequeTests: CollectionTestCase {
|
||||
func test_demo() {
|
||||
let values = [0, 10, 20, 30, 42, 50, 60]
|
||||
for i in values.indices {
|
||||
context.withTrace("i: \(i)") {
|
||||
expectEqual(values[i], 10 * i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
DemoTests.swift:21: error: -[DemoTests.DemoTests test_demo] : XCTAssertEqual failed: ("42") is not equal to ("40") -
|
||||
Trace:
|
||||
- i: 4
|
||||
```
|
||||
|
||||
To debug issues, copy the trace message into a `context.failIfTraceMatches(_:)` invocation and set a breakpoint on test failures.
|
||||
|
||||
```swift
|
||||
let values = [0, 10, 20, 30, 42, 50, 60]
|
||||
for i in values.indices {
|
||||
context.withTrace("i: \(i)") {
|
||||
// This will report a test failure before executing the `i == 4` case,
|
||||
// letting us investigate what's going on.
|
||||
context.failIfTraceMatches("""
|
||||
Trace:
|
||||
- i: 4
|
||||
""")
|
||||
expectEqual(values[i], 10 * i)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
- [`Combinatorics`](./Sources/CollectionsTestSupport/AssertionContexts/Combinatorics.swift): Basic support for exhaustive combinatorial testing. This allows us to easily verify that a collection operation works correctly on all possible instances up to a certain size, including behavioral variations such as unique/shared storage.
|
||||
|
||||
<details>
|
||||
<summary><strong>Click here for an example</strong></summary>
|
||||
|
||||
```swift
|
||||
func test_popFirst() {
|
||||
withEveryDeque("deque", ofCapacities: [0, 1, 2, 3, 5, 10]) { layout in
|
||||
withEvery("isShared", in: [false, true]) { isShared in
|
||||
withLifetimeTracking { tracker in
|
||||
var (deque, contents) = tracker.deque(with: layout)
|
||||
withHiddenCopies(if: isShared, of: &deque) { deque in
|
||||
let expected = contents[...].popFirst()
|
||||
let actual = deque.popFirst()
|
||||
expectEqual(actual, expected)
|
||||
expectEqualElements(deque, contents)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
- [`ConformanceCheckers`](./Sources/CollectionsTestSupport/ConformanceCheckers): A set of generic, semi-automated protocol conformance tests for some Standard Library protocols. These can be used to easily validate the custom protocol conformances provided by this package. These checks aren't (can't be) complete -- but when used correctly, they are able to detect most accidental mistakes.
|
||||
|
||||
We currently have conformance checkers for the following protocols:
|
||||
|
||||
- [`Sequence`](./Sources/CollectionsTestSupport/ConformanceCheckers/CheckSequence.swift)
|
||||
- [`Collection`](./Sources/CollectionsTestSupport/ConformanceCheckers/CheckCollection.swift)
|
||||
- [`BidirectionalCollection`](./Sources/CollectionsTestSupport/ConformanceCheckers/CheckBidirectionalCollection.swift)
|
||||
- [`Equatable`](./Sources/CollectionsTestSupport/ConformanceCheckers/CheckEquatable.swift)
|
||||
- [`Hashable`](./Sources/CollectionsTestSupport/ConformanceCheckers/CheckHashable.swift)
|
||||
- [`Comparable`](./Sources/CollectionsTestSupport/ConformanceCheckers/CheckComparable.swift)
|
||||
|
||||
- [`MinimalTypes`](./Sources/CollectionsTestSupport/MinimalTypes): Minimally conforming implementations for standard protocols. These types conform to various standard protocols by implementing the requirements in as narrow-minded way as possible -- sometimes going to extreme lengths to, say, implement collection index invalidation logic in the most unhelpful way possible.
|
||||
|
||||
- [`MinimalSequence`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalSequence.swift)
|
||||
- [`MinimalCollection`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalCollection.swift)
|
||||
- [`MinimalBidirectionalCollection`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalBidirectionalCollection.swift)
|
||||
- [`MinimalRandomAccessCollection`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalRandomAccessCollection.swift)
|
||||
- [`MinimalMutableRandomAccessCollection`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalMutableRandomAccessCollection.swift)
|
||||
- [`MinimalRangeReplaceableRandomAccessCollection`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalRangeReplaceableRandomAccessCollection.swift)
|
||||
- [`MinimalMutableRangeReplaceableRandomAccessCollection`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalMutableRangeReplaceableRandomAccessCollection.swift)
|
||||
- [`MinimalIterator`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalIterator.swift)
|
||||
- [`MinimalIndex`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalIndex.swift)
|
||||
- [`MinimalEncoder`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalEncoder.swift)
|
||||
- [`MinimalDecoder`](./Sources/CollectionsTestSupport/MinimalTypes/MinimalDecoder.swift)
|
||||
|
||||
- [`Utilities`](./Sources/CollectionsTestSupport/Utilities): Utility types. Wrapper types for boxed values, a simple deterministic random number generator, and a lifetime tracker for catching simple memory management issues such as memory leaks. (The [Address Sanitizer][asan] can be used to catch more serious problems.)
|
||||
|
||||
[asan]: https://developer.apple.com/documentation/xcode/diagnosing_memory_thread_and_crash_issues_early?language=objc
|
||||
Future minor versions of the package may update these rules as needed.
|
||||
|
||||
We'd like this package to quickly embrace Swift language and toolchain improvements that are relevant to its mandate. Accordingly, from time to time, we expect that new versions of this package will require clients to upgrade to a more recent Swift toolchain release. (This allows the package to make use of new language/stdlib features, build on compiler bug fixes, and adopt new package manager functionality as soon as they are available.) Requiring a new Swift release will only need a minor version bump.
|
||||
|
||||
## Using **Swift Collections** in your project
|
||||
|
||||
To use this package in a SwiftPM project, add the following line to the dependencies in your `Package.swift` file:
|
||||
To use this package in a SwiftPM project, you need to set it up as a package dependency:
|
||||
|
||||
```swift
|
||||
.package(url: "https://github.com/apple/swift-collections", from: "0.0.1"),
|
||||
// swift-tools-version:5.4
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "MyPackage",
|
||||
dependencies: [
|
||||
.package(
|
||||
url: "https://github.com/apple/swift-collections.git",
|
||||
.upToNextMajor(from: "1.0.0") // or `.upToNextMinor
|
||||
)
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "MyTarget",
|
||||
dependencies: [
|
||||
.product(name: "Collections", package: "swift-collections")
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
## Contributing to Swift Collections
|
||||
|
||||
### Asking questions
|
||||
|
||||
We have a dedicated [Swift Collections Forum][forum] where we can ask and answer questions on how to use or work on this package. It's also a great place to discuss its evolution.
|
||||
We have a dedicated [Swift Collections Forum][forum] where people can ask and answer questions on how to use or work on this package. It's also a great place to discuss its evolution.
|
||||
|
||||
[forum]: https://forums.swift.org/c/related-projects/collections
|
||||
|
||||
### Reporting a bug
|
||||
|
||||
If you find something that looks like a bug, please open a [Bug Report][bugreport]! Fill out as many details as you can.
|
||||
|
||||
### Fixing a bug or making a small improvement
|
||||
### Working on the package
|
||||
|
||||
We have some basic [documentation on package internals](./Documentation/Development/Internals/) that will help you get started.
|
||||
|
||||
By submitting a pull request, you represent that you have the right to license your contribution to Apple and the community, and agree by submitting the patch that your contributions are licensed under the [Swift License](https://swift.org/LICENSE.txt), a copy of which is [provided in this repository](LICENSE.txt).
|
||||
|
||||
#### Fixing a bug or making a small improvement
|
||||
|
||||
1. [Submit a PR][PR] with your change. If there is an [existing issue][issues] for the bug you're fixing, please include a reference to it.
|
||||
2. Make sure to add tests covering whatever changes you are making.
|
||||
@@ -192,7 +106,7 @@ If you find something that looks like a bug, please open a [Bug Report][bugrepor
|
||||
|
||||
[bugreport]: https://github.com/apple/swift-collections/issues/new?assignees=&labels=bug&template=BUG_REPORT.md
|
||||
|
||||
### Proposing a small enhancement
|
||||
#### Proposing a small enhancement
|
||||
|
||||
1. Raise a [Feature Request][enhancement]. Discuss why it would be important to implement it.
|
||||
2. Submit a PR with your implementation, participate in the review discussion.
|
||||
@@ -201,7 +115,7 @@ If you find something that looks like a bug, please open a [Bug Report][bugrepor
|
||||
|
||||
[enhancement]: https://github.com/apple/swift-collections/issues/new?assignees=&labels=enhancement&template=FEATURE_REQUEST.md
|
||||
|
||||
### Proposing the addition of a new data structure
|
||||
#### Proposing the addition of a new data structure
|
||||
|
||||
1. Start a topic on the [forum], explaining why you believe it would be important to implement the data structure. This way we can figure out if it would be right for the package, discuss implementation strategies, and plan to allocate capacity to help.
|
||||
2. When maintainers agreed to your implementation plan, start work on it, and submit a PR with your implementation as soon as you have something that's ready to show! We'd love to get involved as early as you like.
|
||||
@@ -209,17 +123,13 @@ If you find something that looks like a bug, please open a [Bug Report][bugrepor
|
||||
3. When there is a consensus that the feature is ready, and the implementation is fully tested and documented, the PR will be merged by a maintainer.
|
||||
4. Celebrate! You've achieved something great!
|
||||
|
||||
### Licensing
|
||||
|
||||
By submitting a pull request, you represent that you have the right to license your contribution to Apple and the community, and agree by submitting the patch that your contributions are licensed under the [Swift License](https://swift.org/LICENSE.txt), a copy of which is [provided in this repository](LICENSE.txt).
|
||||
|
||||
### Code of Conduct
|
||||
|
||||
Like all Swift.org projects, we would like the Swift Collections project to foster a diverse and friendly community. We expect contributors to adhere to the [Swift.org Code of Conduct](https://swift.org/code-of-conduct/). A copy of this document is [available in this repository][coc].
|
||||
|
||||
[coc]: CODE_OF_CONDUCT.md
|
||||
|
||||
### Contacting the maintainers
|
||||
### Contact information
|
||||
|
||||
The current code owner of this package is Karoy Lorentey ([@lorentey](https://github.com/lorentey)). You can contact him [on the Swift forums](https://forums.swift.org/u/lorentey/summary), or by writing an email to klorentey at apple dot com. (Please keep it related to this project.)
|
||||
|
||||
|
||||
@@ -17,30 +17,29 @@ extension OrderedDictionary {
|
||||
/// `0` and less than `count`.
|
||||
///
|
||||
/// - Complexity: O(1)
|
||||
@available(*, deprecated, // since 0.0.6
|
||||
message: "Please use `elements[offset]`")
|
||||
@available(*, unavailable, // deprecated in 0.0.6, obsoleted in 1.0.0
|
||||
message: "Please use `elements[offset]`")
|
||||
@inlinable
|
||||
@inline(__always)
|
||||
public subscript(offset offset: Int) -> Element {
|
||||
(_keys[offset], _values[offset])
|
||||
fatalError()
|
||||
}
|
||||
}
|
||||
|
||||
extension OrderedDictionary {
|
||||
// Deprecated since 0.0.6
|
||||
@available(*, deprecated, // since 0.0.6
|
||||
renamed: "updateValue(forKey:default:with:)")
|
||||
@available(*, unavailable, // deprecated in 0.0.6, obsoleted in 1.0.0
|
||||
renamed: "updateValue(forKey:default:with:)")
|
||||
@inlinable
|
||||
public mutating func modifyValue<R>(
|
||||
forKey key: Key,
|
||||
default defaultValue: @autoclosure () -> Value,
|
||||
_ body: (inout Value) throws -> R
|
||||
) rethrows -> R {
|
||||
try self.updateValue(forKey: key, default: defaultValue(), with: body)
|
||||
fatalError()
|
||||
}
|
||||
|
||||
@available(*, deprecated, // since 0.0.6
|
||||
renamed: "updateValue(forKey:insertingDefault:at:with:)")
|
||||
@available(*, unavailable, // deprecated in 0.0.6, obsoleted in 1.0.0
|
||||
renamed: "updateValue(forKey:insertingDefault:at:with:)")
|
||||
@inlinable
|
||||
public mutating func modifyValue<R>(
|
||||
forKey key: Key,
|
||||
@@ -48,10 +47,6 @@ extension OrderedDictionary {
|
||||
at index: Int,
|
||||
_ body: (inout Value) throws -> R
|
||||
) rethrows -> R {
|
||||
try self.updateValue(
|
||||
forKey: key,
|
||||
insertingDefault: defaultValue(),
|
||||
at: index,
|
||||
with: body)
|
||||
fatalError()
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -10,7 +10,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import XCTest
|
||||
import CollectionsTestSupport
|
||||
import _CollectionsTestSupport
|
||||
|
||||
final class DequeTests: CollectionTestCase {
|
||||
func testMinimalSequence() {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import CollectionsTestSupport
|
||||
import _CollectionsTestSupport
|
||||
@_spi(Testing) import DequeModule
|
||||
|
||||
internal struct DequeLayout: CustomStringConvertible {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import XCTest
|
||||
import CollectionsTestSupport
|
||||
import _CollectionsTestSupport
|
||||
@_spi(Testing) import DequeModule
|
||||
|
||||
final class DequeTests: CollectionTestCase {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import XCTest
|
||||
import CollectionsTestSupport
|
||||
import _CollectionsTestSupport
|
||||
@_spi(Testing) import DequeModule
|
||||
|
||||
final class MutableCollectiontests: CollectionTestCase {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import XCTest
|
||||
import CollectionsTestSupport
|
||||
import _CollectionsTestSupport
|
||||
@_spi(Testing) import DequeModule
|
||||
|
||||
/// Exhaustive tests for `Deque`'s implementations for `RangeReplaceableCollection`
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#if DEBUG // These unit tests need access to OrderedSet internals
|
||||
import XCTest
|
||||
import CollectionsTestSupport
|
||||
import _CollectionsTestSupport
|
||||
@_spi(Testing) @testable import OrderedCollections
|
||||
|
||||
class BitsetTests: CollectionTestCase {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#if DEBUG // These unit tests need access to OrderedSet internals
|
||||
import XCTest
|
||||
import CollectionsTestSupport
|
||||
import _CollectionsTestSupport
|
||||
@_spi(Testing) @testable import OrderedCollections
|
||||
|
||||
class HashTableTests: CollectionTestCase {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
import XCTest
|
||||
@_spi(Testing) import OrderedCollections
|
||||
|
||||
import CollectionsTestSupport
|
||||
import _CollectionsTestSupport
|
||||
|
||||
class OrderedDictionaryTests: CollectionTestCase {
|
||||
func test_empty() {
|
||||
@@ -213,19 +213,6 @@ class OrderedDictionaryTests: CollectionTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@available(*, deprecated)
|
||||
func test_subscript_offset() {
|
||||
withEvery("count", in: 0 ..< 30) { count in
|
||||
withLifetimeTracking { tracker in
|
||||
let (d, reference) = tracker.orderedDictionary(keys: 0 ..< count)
|
||||
withEvery("offset", in: 0 ..< count) { offset in
|
||||
let item = d[offset: offset]
|
||||
expectEqual(item, reference[offset])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func test_subscript_getter() {
|
||||
withEvery("count", in: 0 ..< 30) { count in
|
||||
withLifetimeTracking { tracker in
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import CollectionsTestSupport
|
||||
import _CollectionsTestSupport
|
||||
import OrderedCollections
|
||||
|
||||
extension LifetimeTracker {
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
import XCTest
|
||||
@_spi(Testing) import OrderedCollections
|
||||
|
||||
import CollectionsTestSupport
|
||||
import _CollectionsTestSupport
|
||||
|
||||
class OrderedDictionaryElementsTests: CollectionTestCase {
|
||||
func test_elements_getter() {
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
import XCTest
|
||||
@_spi(Testing) import OrderedCollections
|
||||
|
||||
import CollectionsTestSupport
|
||||
import _CollectionsTestSupport
|
||||
|
||||
class OrderedDictionaryValueTests: CollectionTestCase {
|
||||
func test_values_getter() {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
import XCTest
|
||||
import OrderedCollections
|
||||
import CollectionsTestSupport
|
||||
import _CollectionsTestSupport
|
||||
|
||||
class MeasuringHashable: Hashable {
|
||||
static var equalityChecks = 0
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
import XCTest
|
||||
@_spi(Testing) import OrderedCollections
|
||||
import CollectionsTestSupport
|
||||
import _CollectionsTestSupport
|
||||
|
||||
class OrderedSetUnorderedViewTests: CollectionTestCase {
|
||||
func test_unordered_insert() {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import CollectionsTestSupport
|
||||
import _CollectionsTestSupport
|
||||
@_spi(Testing) import OrderedCollections
|
||||
|
||||
struct OrderedSetLayout: Hashable, CustomStringConvertible {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
import XCTest
|
||||
@_spi(Testing) import OrderedCollections
|
||||
import CollectionsTestSupport
|
||||
import _CollectionsTestSupport
|
||||
|
||||
class OrderedSetTests: CollectionTestCase {
|
||||
func test_init_uncheckedUniqueElements_concrete() {
|
||||
|
||||
Executable
+131
@@ -0,0 +1,131 @@
|
||||
#!/bin/sh
|
||||
#===----------------------------------------------------------------------
|
||||
#
|
||||
# This source file is part of the Swift Collections open source project
|
||||
#
|
||||
# Copyright (c) 2021 Apple Inc. and the Swift project authors
|
||||
# Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
#
|
||||
# See https://swift.org/LICENSE.txt for license information
|
||||
#
|
||||
#===----------------------------------------------------------------------
|
||||
|
||||
# Build & test this package in as many configurations as possible.
|
||||
# It is a good idea to run this script before each release to uncover
|
||||
# potential problems not covered by the usual CI runs.
|
||||
#
|
||||
# Note that this is not a fully automated solution -- some manual editing will
|
||||
# sometimes be required when e.g. testing the package on older Xcode releases.
|
||||
|
||||
set -eu
|
||||
|
||||
cd "$(dirname $0)/.."
|
||||
|
||||
build_dir="$(mktemp -d "/tmp/$(basename $0).XXXXX")"
|
||||
bold_on="$(tput bold)"
|
||||
bold_off="$(tput sgr0)"
|
||||
|
||||
spm_flags=""
|
||||
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
swift="xcrun swift"
|
||||
else
|
||||
swift="swift"
|
||||
spm_flags="$spm_flags -j 1"
|
||||
fi
|
||||
|
||||
echo "Build output logs are saved in $bold_on$build_dir$bold_off"
|
||||
swift --version
|
||||
|
||||
report_failure() {
|
||||
logs="$1"
|
||||
echo " ${bold_on}Failed.${bold_off} See $logs for full console output."
|
||||
tail -10 "$logs"
|
||||
exit 1
|
||||
}
|
||||
|
||||
_count=0
|
||||
try() {
|
||||
label="$1"
|
||||
shift
|
||||
_count=$(($_count + 1))
|
||||
count="$(printf "%02d" $_count)"
|
||||
output="$build_dir/$count.$label.log"
|
||||
echo "$bold_on[$count $label]$bold_off $@"
|
||||
start="$(date +%s)"
|
||||
"$@" >"$output" 2>&1 || report_failure "$output"
|
||||
end="$(date +%s)"
|
||||
echo " Completed in $(($end - $start))s"
|
||||
}
|
||||
|
||||
# Build using SPM
|
||||
try "spm.debug" $swift test -c debug $spm_flags --build-path "$build_dir/spm.debug"
|
||||
try "spm.release" $swift test -c release $spm_flags --build-path "$build_dir/spm.release"
|
||||
|
||||
# Build with CMake
|
||||
cmake_build_dir="$build_dir/cmake"
|
||||
try "cmake.generate" cmake -S . -B "$cmake_build_dir" -G Ninja
|
||||
try "cmake.build-with-ninja" ninja -C "$cmake_build_dir"
|
||||
|
||||
if [ "$(uname)" = "Darwin" ]; then
|
||||
# Build using xcodebuild
|
||||
try "xcodebuild.build" \
|
||||
xcodebuild -scheme swift-collections-Package \
|
||||
-configuration Release \
|
||||
-destination "generic/platform=macOS" \
|
||||
-destination "generic/platform=macOS,variant=Mac Catalyst" \
|
||||
-destination "generic/platform=iOS" \
|
||||
-destination "generic/platform=iOS Simulator" \
|
||||
-destination "generic/platform=watchOS" \
|
||||
-destination "generic/platform=watchOS Simulator" \
|
||||
-destination "generic/platform=tvOS" \
|
||||
-destination "generic/platform=tvOS Simulator" \
|
||||
clean build
|
||||
try "xcodebuild.test" \
|
||||
xcodebuild -scheme swift-collections-Package \
|
||||
-configuration Release \
|
||||
-destination "platform=macOS" \
|
||||
-destination "platform=macOS,variant=Mac Catalyst" \
|
||||
-destination "platform=iOS Simulator,name=iPhone 12" \
|
||||
-destination "platform=watchOS Simulator,name=Apple Watch Series 6 - 44mm" \
|
||||
-destination "platform=tvOS Simulator,name=Apple TV 4K (at 1080p) (2nd generation)" \
|
||||
test
|
||||
fi
|
||||
|
||||
# Build benchmarks
|
||||
cd Benchmarks
|
||||
try "benchmarks.debug" $swift run -c debug $spm_flags --build-path "$build_dir/benchmarks.debug" benchmark --help
|
||||
try "benchmarks.release" $swift run -c release $spm_flags --build-path "$build_dir/benchmarks.release" benchmark --help
|
||||
cd ..
|
||||
if [ "$(uname)" = "Darwin" ]; then
|
||||
# FIXME: This should just work on Linux, too
|
||||
try "run-benchmarks" ./Utils/run-benchmarks.sh run --max-size 128 "$build_dir/benchmark.results" --cycles 3
|
||||
fi
|
||||
|
||||
# Build with custom configurations
|
||||
try "spm.internal-checks" $swift test -c debug -Xswiftc -DCOLLECTIONS_INTERNAL_CHECKS $spm_flags --build-path "$build_dir/spm.internal-checks"
|
||||
try "spm.deterministic-hashing" $swift test -c debug -Xswiftc -DCOLLECTIONS_DETERMINISTIC_HASHING $spm_flags --build-path "$build_dir/spm.deterministic-hashing"
|
||||
try "spm.internal-checks+deterministic-hashing" $swift test -c debug -Xswiftc -DCOLLECTIONS_INTERNAL_CHECKS -Xswiftc -DCOLLECTIONS_DETERMINISTIC_HASHING $spm_flags --build-path "$build_dir/spm.internal-checks+deterministic-hashing"
|
||||
|
||||
# Some people like to build their dependencies in warnings-as-errors mode.
|
||||
# (This won't work with tests on Linux as we have some tests for deprecated APIs that will produce a warning there.)
|
||||
try "spm.warnings-as-errors.debug" $swift build -c debug -Xswiftc -warnings-as-errors $spm_flags --build-path "$build_dir/spm.warnings-as-errors"
|
||||
try "spm.warnings-as-errors.release" $swift build -c release -Xswiftc -warnings-as-errors $spm_flags --build-path "$build_dir/spm.warnings-as-errors"
|
||||
|
||||
# Build with library evolution enabled. (This configuration is
|
||||
# unsupported, but let's make some effort not to break it.)
|
||||
if [ "$(uname)" = "Darwin" ]; then
|
||||
try "spm.library-evolution" \
|
||||
$swift build \
|
||||
-c release \
|
||||
$spm_flags \
|
||||
--build-path "$build_dir/spm.library-evolution" \
|
||||
-Xswiftc -enable-library-evolution
|
||||
try "xcodebuild.library-evolution" \
|
||||
xcodebuild -scheme swift-collections-Package \
|
||||
-destination "generic/platform=macOS" \
|
||||
-destination "generic/platform=iOS" \
|
||||
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
|
||||
fi
|
||||
|
||||
$swift package clean
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:../../swift-collections">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:../../swift-collections/Benchmarks">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:../../swift-collections-benchmark">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Benchmarks">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:../swift-collections-benchmark">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
Reference in new issue
Block a user