Deprecated methods in the FileHandle class

Howdy,

It appears that a few methods of the FileHandle class used in the example test cases for executable targets are going to be deprecated in the upcoming releases for MacOS and iOS. Specifically, the readDataToEndOfFile() method and the seek(toFileOffset offset: UInt64) functions.

There are two files with readDataToEndOfFile:
/Sources/Basic/Process.swift
/Sources/Workspace/InitPackage.swift

Dealing with these is trivial: they can be replaced with the availableData property, which likewise returns a Data struct with the output of the application. In my own testing, making this substitution works as expected in the generated test cases for new executable packages (the usage in InitPackage.swift). The other examples are within #if os(Windows), and I don't have a way to test that.

The other examples are in /Tests/BasicTests/TemporaryFileTests.swift', where they are used to generate the content of a temporary file. The use of this method could be circumvented by using another method to create the content, such as the use of literals, orData. However, the currently used method, which uses theBufferedOutputByteStreamclass and the<<<operator may be preferred, as those methods are being implicitly tested as well. The upcoming API includes a similarseek(toOffset offset: UInt64)` method, which could be used, although then the issue has to be handled such that there are conditions to see which OS is being used, either through versioning or preprocessor directives.

Is there are preferred method to handle this? I would tend to prefer rewriting the tests in TemporaryFileTests.swift so that they avoid the versioning issues and preprocessor directives, which seems to me to be the easiest, as there would seemingly be fewer issues by using more general code. There are other tests that use the BufferedOutputByteStream class, so I imagine the code coverage would be the same either way.

Terms of Service

Privacy Policy

Cookie Policy