mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-30 14:30:02 +00:00
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:
@@ -48,10 +48,24 @@ class FlatBuffersMonsterWriterTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testReadFromOtherLanguages() {
|
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")
|
.appendingPathComponent("monsterdata_test")
|
||||||
.appendingPathExtension("mon")
|
.appendingPathExtension("mon")
|
||||||
let data = try! Data(contentsOf: url)
|
|
||||||
|
let data = FileManager.default.contents(atPath: url.path)!
|
||||||
let _data = ByteBuffer(data: data)
|
let _data = ByteBuffer(data: data)
|
||||||
|
|
||||||
readVerifiedMonster(fb: _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() {
|
func testContiguousBytes() {
|
||||||
let byteArray: [UInt8] = [3, 1, 4, 1, 5, 9]
|
let byteArray: [UInt8] = [3, 1, 4, 1, 5, 9]
|
||||||
var fbb = FlatBufferBuilder(initialSize: 1)
|
var fbb = FlatBufferBuilder(initialSize: 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user