From a1b519eb89f972fbe0d47d8027097ccfa8a9ae74 Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Tue, 23 Apr 2024 08:49:36 -0700 Subject: [PATCH] Moved JSONSafeEncoding to v2.0 (#335) * Moved JSONSafeEncoding to v2.0 * Added time to iOS test until apple fixes it. * Added stub for autoreleasepool on linux. --- Package.resolved | 4 ++-- Package.swift | 2 +- Sources/Segment/Utilities/Utils.swift | 6 +++++- Tests/Segment-Tests/Analytics_Tests.swift | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Package.resolved b/Package.resolved index 14d8e57..413ef64 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/segmentio/jsonsafeencoding-swift.git", "state" : { - "revision" : "13449de3474c97ca6b7a25b3288f188b7417b34a", - "version" : "1.0.2" + "revision" : "af6a8b360984085e36c6341b21ecb35c12f47ebd", + "version" : "2.0.0" } }, { diff --git a/Package.swift b/Package.swift index c020fa1..173bdb9 100644 --- a/Package.swift +++ b/Package.swift @@ -22,7 +22,7 @@ let package = Package( // Dependencies declare other packages that this package depends on. // .package(url: /* package url */, from: "1.0.0"), .package(url: "https://github.com/segmentio/sovran-swift.git", from: "1.1.1"), - .package(url: "https://github.com/segmentio/jsonsafeencoding-swift.git", from: "1.0.2") + .package(url: "https://github.com/segmentio/jsonsafeencoding-swift.git", from: "2.0.0") ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. diff --git a/Sources/Segment/Utilities/Utils.swift b/Sources/Segment/Utilities/Utils.swift index 27914c1..423f938 100644 --- a/Sources/Segment/Utilities/Utils.swift +++ b/Sources/Segment/Utilities/Utils.swift @@ -16,6 +16,11 @@ extension DispatchQueue { workItem.wait() } } + +// Linux doesn't have autoreleasepool. +func autoreleasepool(closure: () -> Void) { + closure() +} #endif /// Inquire as to whether we are within a Unit Testing environment. @@ -84,4 +89,3 @@ internal func eventStorageDirectory(writeKey: String) -> URL { try? FileManager.default.createDirectory(at: segmentURL, withIntermediateDirectories: true, attributes: nil) return segmentURL } - diff --git a/Tests/Segment-Tests/Analytics_Tests.swift b/Tests/Segment-Tests/Analytics_Tests.swift index a7cba46..a1405d1 100644 --- a/Tests/Segment-Tests/Analytics_Tests.swift +++ b/Tests/Segment-Tests/Analytics_Tests.swift @@ -771,7 +771,7 @@ final class Analytics_Tests: XCTestCase { expectation.fulfill() } - wait(for: [expectation], timeout: 10) + wait(for: [expectation], timeout: 60) XCTAssertNil(analytics.pendingUploads) }