|
1 | 1 | # Constrain the granularity of test time limit durations
|
2 | 2 |
|
3 | 3 | * Proposal:
|
4 |
| -[SWT-NNNN](NNNN-constrain-the-granularity-of-test-time-limit-durations.md) |
| 4 | +[SWT-0004](0004-constrain-the-granularity-of-test-time-limit-durations.md) |
5 | 5 | * Authors: [Dennis Weissmann](https://github.com/dennisweissmann)
|
6 |
| -* Status: **Awaiting review** |
| 6 | +* Status: **Accepted** |
7 | 7 | * Implementation:
|
8 |
| -[apple/swift-testing#NNNNN](https://github.com/apple/swift-testing/pull/NNNNN) |
| 8 | +[apple/swift-testing#534](https://github.com/apple/swift-testing/pull/534) |
9 | 9 | * Review:
|
10 |
| -([pitch](https://forums.swift.org/t/pitch-constrain-the-granularity-of-test-time |
11 |
| --limit-durations/73146)) |
| 10 | +([pitch](https://forums.swift.org/t/pitch-constrain-the-granularity-of-test-time-limit-durations/73146)) |
12 | 11 |
|
13 | 12 | ## Introduction
|
14 | 13 |
|
|
66 | 65 |
|
67 | 66 | ## Detailed Design
|
68 | 67 |
|
69 |
| -The `TimeLimitTrait.Duration` struct only has one factory method: `public |
70 |
| -static func minutes(_ minutes: some BinaryInteger) -> Self`. |
| 68 | +The `TimeLimitTrait.Duration` struct only has one factory method: |
| 69 | +```swift |
| 70 | +public static func minutes(_ minutes: some BinaryInteger) -> Self` |
| 71 | +``` |
71 | 72 |
|
72 | 73 | That ensures 2 things:
|
73 | 74 | 1. It's impossible to create short time limits (under a minute).
|
@@ -114,7 +115,7 @@ public struct TimeLimitTrait: TestTrait, SuiteTrait {
|
114 | 115 | The extension on `Trait` that allows for `.timeLimit(...)` to work is defined
|
115 | 116 | like this:
|
116 | 117 |
|
117 |
| -``` |
| 118 | +```swift |
118 | 119 | /// Construct a time limit trait that causes a test to time out if it runs for
|
119 | 120 | /// too long.
|
120 | 121 | ///
|
@@ -160,11 +161,11 @@ func serve100CustomersInOneHour() async {
|
160 | 161 | }
|
161 | 162 | ```
|
162 | 163 |
|
163 |
| -The `TimeLimitTrait.Duration` struct has various `unavailable` overloads that |
164 |
| -are included for diagnostic purposes only. They are all documented and |
| 164 | +The `TimeLimitTrait.Duration` struct has various `unavailable` overloads that |
| 165 | +are included for diagnostic purposes only. They are all documented and |
165 | 166 | annotated like this:
|
166 | 167 |
|
167 |
| -``` |
| 168 | +```swift |
168 | 169 | /// Construct a time limit duration given a number of <unit>.
|
169 | 170 | ///
|
170 | 171 | /// This function is unavailable and is provided for diagnostic purposes only.
|
|
181 | 182 |
|
182 | 183 | ## Future Directions
|
183 | 184 |
|
184 |
| -N/A. |
| 185 | +We could allow more finegrained time limits but this was not considered. |
| 186 | +different tiime limits for different environments (CI vs desks). |
185 | 187 |
|
186 | 188 | ## Alternatives Considered
|
187 | 189 |
|
|
0 commit comments