Fixes failing tests on macOS due to file loading (#8742)

Fixes failing tests due to the usage of URL(fileURLWithPath:isDirectory:) instead of URL(string:)
This commit is contained in:
mustiikhalil
2025-10-29 19:36:47 +01:00
committed by GitHub
parent 95053e6a47
commit de25052c72

View File

@@ -48,10 +48,24 @@ class FlatBuffersMonsterWriterTests: XCTestCase {
}
func testReadFromOtherLanguages() {
let url = URL(fileURLWithPath: path, isDirectory: true)
let path = {
#if os(macOS)
// Gets the current path of this test file then
// strips out the nested directories.
let filePath = URL(filePath: #file)
.deletingLastPathComponent()
return filePath.absoluteString
#else
return FileManager.default.currentDirectoryPath
.appending("/tests/swift/Tests/Flatbuffers")
#endif
}()
let url = URL(string: path)!
.appendingPathComponent("monsterdata_test")
.appendingPathExtension("mon")
let data = try! Data(contentsOf: url)
let data = FileManager.default.contents(atPath: url.path)!
let _data = ByteBuffer(data: data)
readVerifiedMonster(fb: _data)
@@ -646,19 +660,6 @@ class FlatBuffersMonsterWriterTests: XCTestCase {
"""
}
private var path: String {
#if os(macOS)
// Gets the current path of this test file then
// strips out the nested directories.
let filePath = URL(filePath: #file)
.deletingLastPathComponent()
return filePath.absoluteString
#else
return FileManager.default.currentDirectoryPath
.appending("/tests/swift/Tests/Flatbuffers")
#endif
}
func testContiguousBytes() {
let byteArray: [UInt8] = [3, 1, 4, 1, 5, 9]
var fbb = FlatBufferBuilder(initialSize: 1)