mirror of
https://github.com/apple/swift-system
synced 2026-11-22 04:30:46 +00:00
This test was very dependent on details of the testing environment, and failed or succeeded according to details we don't seem to control in CI. In the end, this test was only reliable on macOS at desk. Accordingly, we delete it.
50 lines
1.3 KiB
Swift
50 lines
1.3 KiB
Swift
/*
|
|
This source file is part of the Swift System open source project
|
|
|
|
Copyright (c) 2024 Apple Inc. and the Swift System project authors
|
|
Licensed under Apache License v2.0 with Runtime Library Exception
|
|
|
|
See https://swift.org/LICENSE.txt for license information
|
|
*/
|
|
|
|
import XCTest
|
|
|
|
#if SYSTEM_PACKAGE
|
|
@testable import SystemPackage
|
|
#else
|
|
@testable import System
|
|
#endif
|
|
|
|
final class TemporaryPathTest: XCTestCase {
|
|
func testUnique() throws {
|
|
try withTemporaryFilePath(basename: "test") { path in
|
|
let strPath = String(decoding: path)
|
|
XCTAssert(strPath.contains("test"))
|
|
try withTemporaryFilePath(basename: "test") { path2 in
|
|
let strPath2 = String(decoding: path2)
|
|
XCTAssertNotEqual(strPath, strPath2)
|
|
}
|
|
}
|
|
}
|
|
|
|
func testCleanup() throws {
|
|
var thePath: FilePath? = nil
|
|
|
|
try withTemporaryFilePath(basename: "test") { path in
|
|
thePath = path.appending("foo.txt")
|
|
let fd = try FileDescriptor.open(thePath!, .readWrite,
|
|
options: [.create, .truncate],
|
|
permissions: .ownerReadWrite)
|
|
_ = try fd.closeAfter {
|
|
try fd.writeAll("Hello World".utf8)
|
|
}
|
|
}
|
|
|
|
XCTAssertThrowsError(try FileDescriptor.open(thePath!, .readOnly)) {
|
|
error in
|
|
|
|
XCTAssertEqual(error as! Errno, Errno.noSuchFileOrDirectory)
|
|
}
|
|
}
|
|
}
|