Skip to content

Commit f0b3529

Browse files
committed
Merge remote-tracking branch 'origin/main' into merge-main-to-6.2
2 parents e720318 + 2d48848 commit f0b3529

File tree

185 files changed

+4105
-4625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+4105
-4625
lines changed

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
xcode_trim_whitespace_on_empty_lines = true
11+
12+
[*.{yml,yaml}]
13+
indent_size = 2

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ $> swift --version
8888
Apple Swift version 5.3
8989
```
9090

91-
Note: Alternatively use tools like [swiftenv](https://github.com/kylef/swiftenv) that help manage toolchains versions.
91+
Note: Alternatively use tools like [swiftly](https://www.swift.org/swiftly/documentation/swiftlydocs/) that help manage toolchains versions.
9292

9393
## Local Development
9494

Documentation/Usage.md

+17-9
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ This feature is intended for use in the following scenarios:
497497

498498
It is *not* expected that the packages would ever use this feature unless absolutely
499499
necessary to support existing clients. Specifically, packages *should not*
500-
adopt this syntax for tagging versions supporting the _latest GM_ Swift
500+
adopt this syntax for tagging versions supporting the _latest released_ Swift
501501
version.
502502

503503
The package manager supports looking for any of the following marked tags, in
@@ -511,7 +511,7 @@ order of preference:
511511

512512
The package manager will additionally look for a version-specific marked
513513
manifest version when loading the particular version of a package, by searching
514-
for a manifest in the form of `Package@swift-3.swift`. The set of markers
514+
for a manifest in the form of `Package@swift-6.swift`. The set of markers
515515
looked for is the same as for version-specific tag selection.
516516

517517
This feature is intended for use in cases where a package wishes to maintain
@@ -521,20 +521,28 @@ changes in the manifest API).
521521

522522
It is *not* expected the packages would ever use this feature unless absolutely
523523
necessary to support existing clients. Specifically, packages *should not*
524-
adopt this syntax for tagging versions supporting the _latest GM_ Swift
524+
adopt this syntax for tagging versions supporting the _latest released_ Swift
525525
version.
526526

527527
In case the current Swift version doesn't match any version-specific manifest,
528528
the package manager will pick the manifest with the most compatible tools
529529
version. For example, if there are three manifests:
530530

531-
`Package.swift` (tools version 3.0)
532-
`Package@swift-4.swift` (tools version 4.0)
533-
`Package@swift-4.2.swift` (tools version 4.2)
531+
- `Package.swift` (tools version 6.0)
532+
- `Package@swift-5.10.swift` (tools version 5.10)
533+
- `Package@swift-5.9.swift` (tools version 5.9)
534534

535-
The package manager will pick `Package.swift` on Swift 3, `[email protected]` on
536-
Swift 4, and `[email protected]` on Swift 4.2 and above because its tools
537-
version will be most compatible with future version of the package manager.
535+
The package manager will pick `Package.swift` on Swift 6 and above, because its
536+
tools version will be most compatible with future version of the package manager.
537+
When using Swift 5.10, it will pick `[email protected]`. Otherwise, when
538+
using Swift 5.9 it will pick `[email protected]`, and this is the minimum
539+
tools version this package may be used with.
540+
541+
A package may have versioned manifest files which specify newer tools versions
542+
than its unversioned `Package.swift` file[^1]. In this scenario, the manifest
543+
corresponding to the newest-compatible tools version will be used.
544+
545+
[^1]: Support for having a versioned manifest file with a _newer_ tools version was required when the feature was first introduced, because prior versions of the package manager were not aware of the concept and only knew to look for the unversioned `Package.swift`. This is still supported, but there have been many Swift releases since the feature was introduced and it is now considered best practice to have `Package.swift` declare the newest-supported tools version and for versioned manifest files to only specifer older versions.
538546

539547
## Editing a Package
540548

IntegrationTests/Sources/IntegrationTestSupport/Helpers.swift

+8-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import TSCBasic
1414
import TSCTestSupport
1515
import enum TSCUtility.Git
1616

17+
public typealias ShReturnType = (stdout: String, stderr: String, returnCode: ProcessResult.ExitStatus)
18+
1719
public let sdkRoot: AbsolutePath? = {
1820
if let environmentPath = ProcessInfo.processInfo.environment["SDK_ROOT"] {
1921
return try! AbsolutePath(validating: environmentPath)
@@ -106,7 +108,7 @@ public let lldb: AbsolutePath = {
106108
}()
107109

108110
public let swiftpmBinaryDirectory: AbsolutePath = {
109-
if let environmentPath = ProcessInfo.processInfo.environment["SWIFTPM_BIN_DIR"] {
111+
if let environmentPath = ProcessInfo.processInfo.environment["SWIFTPM_CUSTOM_BIN_DIR"] {
110112
return try! AbsolutePath(validating: environmentPath)
111113
}
112114

@@ -131,7 +133,7 @@ public func sh(
131133
env: [String: String] = [:],
132134
file: StaticString = #file,
133135
line: UInt = #line
134-
) throws -> (stdout: String, stderr: String) {
136+
) throws -> ShReturnType {
135137
let result = try _sh(arguments, env: env, file: file, line: line)
136138
let stdout = try result.utf8Output()
137139
let stderr = try result.utf8stderrOutput()
@@ -145,7 +147,7 @@ public func sh(
145147
)
146148
}
147149

148-
return (stdout, stderr)
150+
return (stdout, stderr, result.exitStatus)
149151
}
150152

151153
@discardableResult
@@ -154,7 +156,7 @@ public func shFails(
154156
env: [String: String] = [:],
155157
file: StaticString = #file,
156158
line: UInt = #line
157-
) throws -> (stdout: String, stderr: String) {
159+
) throws -> ShReturnType {
158160
let result = try _sh(arguments, env: env, file: file, line: line)
159161
let stdout = try result.utf8Output()
160162
let stderr = try result.utf8stderrOutput()
@@ -168,7 +170,7 @@ public func shFails(
168170
)
169171
}
170172

171-
return (stdout, stderr)
173+
return (stdout, stderr, result.exitStatus)
172174
}
173175

174176
@discardableResult
@@ -385,4 +387,4 @@ extension ProcessResult {
385387
\((try? utf8stderrOutput()) ?? "")
386388
"""
387389
}
388-
}
390+
}

IntegrationTests/Tests/IntegrationTests/BasicTests.swift

+47-45
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private struct BasicTests {
9494
}
9595

9696
@Test(
97-
.skipHostOS(.windows, "'try!' expression unexpectedly raised an error: TSCBasic.Process.Error.missingExecutableProgram(program: \"which\")"),
97+
.skipHostOS(.windows, "'try!' expression unexpectedly raised an error: TSCBasic.Process.Error.missingExecutableProgram(program: \"which\")")
9898
)
9999
func testSwiftCompiler() throws {
100100
try withTemporaryDirectory { tempDir in
@@ -124,22 +124,22 @@ private struct BasicTests {
124124
let packagePath = tempDir.appending(component: "Project")
125125
try localFileSystem.createDirectory(packagePath)
126126
try sh(swiftPackage, "--package-path", packagePath, "init", "--type", "executable")
127-
let buildOutput = try sh(swiftBuild, "--package-path", packagePath).stdout
127+
let packageOutput = try sh(swiftBuild, "--package-path", packagePath)
128128

129129
// Check the build log.
130-
let checker = StringChecker(string: buildOutput)
131-
#expect(checker.check(.regex("Compiling .*Project.*")))
132-
#expect(checker.check(.regex("Linking .*Project")))
133-
#expect(checker.check(.contains("Build complete")))
130+
let checker = StringChecker(string: packageOutput.stdout)
131+
#expect(checker.check(.regex("Compiling .*Project.*")), "stdout: '\(packageOutput.stdout)'\n stderr:'\(packageOutput.stderr)'")
132+
#expect(checker.check(.regex("Linking .*Project")), "stdout: '\(packageOutput.stdout)'\n stderr:'\(packageOutput.stderr)'")
133+
#expect(checker.check(.contains("Build complete")), "stdout: '\(packageOutput.stdout)'\n stderr:'\(packageOutput.stderr)'")
134134

135135
// Verify that the tool was built and works.
136136
let toolOutput = try sh(packagePath.appending(components: ".build", "debug", "Project"))
137137
.stdout
138138
#expect(toolOutput.lowercased().contains("hello, world!"))
139139

140140
// Check there were no compile errors or warnings.
141-
#expect(buildOutput.contains("error") == false)
142-
#expect(buildOutput.contains("warning") == false)
141+
#expect(packageOutput.stdout.contains("error") == false)
142+
#expect(packageOutput.stdout.contains("warning") == false)
143143
}
144144
}
145145

@@ -151,17 +151,19 @@ private struct BasicTests {
151151
try localFileSystem.createDirectory(packagePath)
152152
withKnownIssue("error: no tests found; create a target in the 'Tests' directory") {
153153
try sh(swiftPackage, "--package-path", packagePath, "init", "--type", "executable")
154-
let testOutput = try sh(swiftTest, "--package-path", packagePath).stdout
154+
let packageOutput = try sh(swiftTest, "--package-path", packagePath, "--vv")
155155

156156
// Check the test log.
157-
let checker = StringChecker(string: testOutput)
158-
#expect(checker.check(.regex("Compiling .*ProjectTests.*")))
159-
#expect(checker.check("Test Suite 'All tests' passed"))
160-
#expect(checker.checkNext("Executed 1 test"))
157+
let checker = StringChecker(string: packageOutput.stdout)
158+
#expect(checker.check(.regex("Compiling .*ProjectTests.*")), "stdout: '\(packageOutput.stdout)'\n stderr:'\(packageOutput.stderr)'")
159+
#expect(checker.checkNext("Executed 1 test"), "stdout: '\(packageOutput.stdout)'\n stderr:'\(packageOutput.stderr)'")
160+
161+
// Check the return code
162+
#expect(packageOutput.returnCode == .terminated(code: 0))
161163

162164
// Check there were no compile errors or warnings.
163-
#expect(testOutput.contains("error") == false)
164-
#expect(testOutput.contains("warning") == false)
165+
#expect(packageOutput.stdout.contains("error") == false)
166+
#expect(packageOutput.stdout.contains("warning") == false)
165167
}
166168
}
167169
}
@@ -192,17 +194,14 @@ private struct BasicTests {
192194
let packagePath = tempDir.appending(component: "Project")
193195
try localFileSystem.createDirectory(packagePath)
194196
try sh(swiftPackage, "--package-path", packagePath, "init", "--type", "library")
195-
let testOutput = try sh(swiftTest, "--package-path", packagePath).stdout
197+
let shOutput = try sh(swiftTest, "--package-path", packagePath)
196198

197-
// Check the test log.
198-
let checker = StringChecker(string: testOutput)
199-
#expect(checker.check(.contains("Test Suite 'All tests' started")))
200-
#expect(checker.check(.contains("Test example() passed after")))
201-
#expect(checker.checkNext(.contains("Test run with 1 test passed after")))
199+
// Check the return code
200+
#expect(shOutput.returnCode == .terminated(code: 0))
202201

203202
// Check there were no compile errors or warnings.
204-
#expect(testOutput.contains("error") == false)
205-
#expect(testOutput.contains("warning") == false)
203+
#expect(shOutput.stdout.contains("error") == false)
204+
#expect(shOutput.stdout.contains("warning") == false)
206205
}
207206
}
208207

@@ -248,11 +247,11 @@ private struct BasicTests {
248247
#expect(buildOutput.contains("Build complete"))
249248

250249
// Verify that the tool exists and works.
251-
let toolOutput = try sh(
250+
let shOutput = try sh(
252251
packagePath.appending(components: ".build", "debug", "special tool")
253252
).stdout
254253

255-
#expect(toolOutput == "HI\(ProcessInfo.EOL)")
254+
#expect(shOutput == "HI\(ProcessInfo.EOL)")
256255
}
257256
}
258257

@@ -281,17 +280,20 @@ private struct BasicTests {
281280
"""
282281
)
283282
)
284-
let (runOutput, runError) = try sh(
283+
let shOutput = try sh(
285284
swiftRun, "--package-path", packagePath, "secho", "1", #""two""#
286285
)
287286

288287
// Check the run log.
289-
let checker = StringChecker(string: runError)
290-
#expect(checker.check(.regex("Compiling .*secho.*")))
291-
#expect(checker.check(.regex("Linking .*secho")))
292-
#expect(checker.check(.contains("Build of product 'secho' complete")))
288+
let checker = StringChecker(string: shOutput.stderr)
289+
#expect(checker.check(.regex("Compiling .*secho.*")), "stdout: '\(shOutput.stdout)'\n stderr:'\(shOutput.stderr)'")
290+
#expect(checker.check(.regex("Linking .*secho")), "stdout: '\(shOutput.stdout)'\n stderr:'\(shOutput.stderr)'")
291+
#expect(checker.check(.contains("Build of product 'secho' complete")), "stdout: '\(shOutput.stdout)'\n stderr:'\(shOutput.stderr)'")
292+
293+
#expect(shOutput.stdout == "1 \"two\"\(ProcessInfo.EOL)")
293294

294-
#expect(runOutput == "1 \"two\"\(ProcessInfo.EOL)")
295+
// Check the return code
296+
#expect(shOutput.returnCode == .terminated(code: 0))
295297
}
296298
}
297299

@@ -318,16 +320,16 @@ private struct BasicTests {
318320
"""
319321
)
320322
)
321-
let testOutput = try sh(
323+
let shOutput = try sh(
322324
swiftTest, "--package-path", packagePath, "--filter", "MyTests.*", "--skip",
323-
"testBaz"
324-
).stderr
325+
"testBaz", "--vv"
326+
)
325327

326328
// Check the test log.
327-
let checker = StringChecker(string: testOutput)
328-
#expect(checker.check(.contains("Test Suite 'MyTests' started")))
329-
#expect(checker.check(.contains("Test Suite 'MyTests' passed")))
330-
#expect(checker.check(.contains("Executed 2 tests, with 0 failures")))
329+
let checker = StringChecker(string: shOutput.stderr)
330+
#expect(checker.check(.contains("Test Suite 'MyTests' started")), "stdout: '\(shOutput.stdout)'\n stderr:'\(shOutput.stderr)'")
331+
#expect(checker.check(.contains("Test Suite 'MyTests' passed")), "stdout: '\(shOutput.stdout)'\n stderr:'\(shOutput.stderr)'")
332+
#expect(checker.check(.contains("Executed 2 tests, with 0 failures")), "stdout: '\(shOutput.stdout)'\n stderr:'\(shOutput.stderr)'")
331333
}
332334
}
333335

@@ -410,15 +412,15 @@ private struct BasicTests {
410412
)
411413
)
412414

413-
let testOutput = try sh(
414-
swiftTest, "--package-path", packagePath, "--filter", "MyTests.*"
415-
).stdout
415+
let shOutput = try sh(
416+
swiftTest, "--package-path", packagePath, "--filter", "MyTests.*", "--vv"
417+
)
416418

417419
// Check the test log.
418-
let checker = StringChecker(string: testOutput)
419-
#expect(checker.check(.contains("Test Suite 'MyTests' started")))
420-
#expect(checker.check(.contains("Test Suite 'MyTests' passed")))
421-
#expect(checker.check(.contains("Executed 2 tests, with 0 failures")))
420+
let checker = StringChecker(string: shOutput.stdout)
421+
#expect(checker.check(.contains("Test Suite 'MyTests' started")), "stdout: '\(shOutput.stdout)'\n stderr:'\(shOutput.stderr)'")
422+
#expect(checker.check(.contains("Test Suite 'MyTests' passed")), "stdout: '\(shOutput.stdout)'\n stderr:'\(shOutput.stderr)'")
423+
#expect(checker.check(.contains("Executed 2 tests, with 0 failures")), "stdout: '\(shOutput.stdout)'\n stderr:'\(shOutput.stderr)'")
422424
}
423425
}
424426
}

0 commit comments

Comments
 (0)