Skip to content

Commit 6ef275b

Browse files
committed
Minor fixes
1 parent b58558f commit 6ef275b

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

Sources/Overlays/_Testing_Foundation/Attachments/Test.Attachment+URL.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ extension URL {
1919
#if os(Windows)
2020
// BUG: `path` includes a leading slash which makes it invalid on Windows.
2121
// SEE: https://github.com/swiftlang/swift-foundation/pull/964
22-
let utf8 = path.utf8
23-
let array = Array(utf8)
24-
if array.count > 4, array[0] == UInt8(ascii: "/"), Character(UnicodeScalar(array[1])).isLetter, array[2] == UInt8(ascii: ":"), array[3] == UInt8(ascii: "/") {
25-
return String(Substring(utf8.dropFirst()))
22+
let path = path
23+
if path.starts(with: /\/[A-Za-z]:\//) {
24+
return String(path.dropFirst())
2625
}
2726
#endif
2827
return path
@@ -118,12 +117,15 @@ private struct _DirectoryContentAttachableProxy: Test.Attachable {
118117
#endif
119118
let sourcePath = url.fileSystemPath
120119
let destinationPath = temporaryURL.fileSystemPath
120+
defer {
121+
remove(destinationPath)
122+
}
121123

122124
try await withCheckedThrowingContinuation { continuation in
123125
do {
124126
_ = try Process.run(
125127
URL(fileURLWithPath: tarPath, isDirectory: false),
126-
arguments: ["--create", "--gzip", "--file", destinationPath, sourcePath]
128+
arguments: ["--create", "--gzip", "--directory", sourcePath, "--file", destinationPath, "."]
127129
) { process in
128130
let terminationReason = process.terminationReason
129131
let terminationStatus = process.terminationStatus

Sources/Testing/Running/Configuration.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
private import _TestingInternals
12-
1311
/// A type containing settings for preparing and running tests.
1412
@_spi(ForToolsIntegrationOnly)
1513
public struct Configuration: Sendable {

Tests/TestingTests/AttachmentTests.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,19 +262,22 @@ struct AttachmentTests {
262262

263263
#if !SWT_NO_PROCESS_SPAWNING
264264
@Test func attachContentsOfDirectoryURL() async throws {
265-
let temporaryFileName = UUID().uuidString
266-
let temporaryPath = try appendPathComponent(temporaryFileName, to: temporaryDirectory())
265+
let temporaryDirectoryName = UUID().uuidString
266+
let temporaryPath = try appendPathComponent(temporaryDirectoryName, to: temporaryDirectory())
267267
let temporaryURL = URL(fileURLWithPath: temporaryPath, isDirectory: false)
268268
try FileManager.default.createDirectory(at: temporaryURL, withIntermediateDirectories: true)
269269

270+
let fileData = try #require("Hello world".data(using: .utf8))
271+
try fileData.write(to: temporaryURL.appendingPathComponent("loremipsum.txt"), options: [.atomic])
272+
270273
await confirmation("Attachment detected") { valueAttached in
271274
var configuration = Configuration()
272275
configuration.eventHandler = { event, _ in
273276
guard case let .valueAttached(attachment) = event.kind else {
274277
return
275278
}
276279

277-
#expect(attachment.preferredName == "\(temporaryFileName).tar.gz")
280+
#expect(attachment.preferredName == "\(temporaryDirectoryName).tar.gz")
278281
valueAttached()
279282
}
280283

0 commit comments

Comments
 (0)