Repository: apple/swift-nio
File: Tests/NIOFileSystemIntegrationTests/FileHandleTests.swift (Swift)

Code before:

            try await handle.resize(to: .bytes(1025))
            let newSize2 = try await handle.info().size
            XCTAssertEqual(newSize2, 1025)

            try await handle.resize(to: .bytes(0))
            let newSize3 = try await handle.info().size
            XCTAssertEqual(newSize3, 0)
        }
    }

    func testResizeFileErrors() async throws {
        try await self.withTemporaryFile { handle in
            try await handle.write(
                contentsOf: Array(repeating: 0, count: 1024),
                toAbsoluteOffset: 0
            )

            await XCTAssertThrowsFileSystemErrorAsync {
                try await handle.resize(to: .bytes(-2))
            } onError: { error in
                XCTAssertEqual(error.code, .invalidArgument)
            }
        }
    }

    func testSetLastAccesTime() async throws {
        try await self.withTemporaryFile { handle in
            let originalLastDataModificationTime = try await handle.info().lastDataModificationTime
            let originalLastAccessTime = try await handle.info().lastAccessTime

            try await handle.setTimes(
                lastAccessTime: FileInfo.Timespec(seconds: 10, nanoseconds: 5),
                lastModificationTime: nil
            )

            let actualLastAccessTime = try await handle.info().lastAccessTime
            XCTAssertEqual(actualLastAccessTime, FileInfo.Timespec(seconds: 10, nanoseconds: 5))
            XCTAssertNotEqual(actualLastAccessTime, originalLastAccessTime)

            let actualLastDataModificationTime = try await handle.info().lastDataModificationTime
            XCTAssertEqual(actualLastDataModificationTime, originalLastDataModificationTime)
        }
    }

    func testSetLastDataModificationTime() async throws {
        try await self.withTemporaryFile { handle in
            let originalLastDataModificationTime = try await handle.info().lastDataModificationTime
            let originalLastAccessTime = try await handle.info().lastAccessTime

            try await handle.setTimes(

Review comment (suggestion):
Can you also add tests to:
- `FileSystemErrorTests` to check the mapping of `errno`s to error codes?
- `SyscallTests` after you've added the appropriate function to `Syscall`

Code after:

            try await handle.resize(to: .bytes(1025))
            let newSize2 = try await handle.info().size
            XCTAssertEqual(newSize2, 1025)

            try await handle.resize(to: .bytes(0))
            let newSize3 = try await handle.info().size
            XCTAssertEqual(newSize3, 0)
        }
    }

    func testResizeFileErrors() async throws {
        try await self.withTemporaryFile { handle in
            try await handle.write(
                contentsOf: Array(repeating: 0, count: 1024),
                toAbsoluteOffset: 0
            )

            await XCTAssertThrowsFileSystemErrorAsync {
                try await handle.resize(to: .bytes(-2))
            } onError: { error in
                XCTAssertEqual(error.code, .invalidArgument)
            }
        }
    }

    func testSetLastAccesTime() async throws {
        try await self.withTemporaryFile { handle in
            let originalLastDataModificationTime = try await handle.info().lastDataModificationTime
            let originalLastAccessTime = try await handle.info().lastAccessTime

            try await handle.setTimes(
                lastAccess: FileInfo.Timespec(seconds: 10, nanoseconds: 5),
                lastDataModification: nil
            )

            let actualLastAccessTime = try await handle.info().lastAccessTime
            XCTAssertEqual(actualLastAccessTime, FileInfo.Timespec(seconds: 10, nanoseconds: 5))
            XCTAssertNotEqual(actualLastAccessTime, originalLastAccessTime)

            let actualLastDataModificationTime = try await handle.info().lastDataModificationTime
            XCTAssertEqual(actualLastDataModificationTime, originalLastDataModificationTime)
        }
    }

    func testSetLastDataModificationTime() async throws {
        try await self.withTemporaryFile { handle in
            let originalLastDataModificationTime = try await handle.info().lastDataModificationTime
            let originalLastAccessTime = try await handle.info().lastAccessTime

            try await handle.setTimes(