From 4553c7ff0b78cc7d3c3cee1132956e0cd3365957 Mon Sep 17 00:00:00 2001 From: tid Date: Sun, 8 Aug 2021 03:45:17 +0900 Subject: [PATCH] Fixed to support macOS 10.9 --- Tests/KannaTests/KannaCSSTests.swift | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Tests/KannaTests/KannaCSSTests.swift b/Tests/KannaTests/KannaCSSTests.swift index 237ce84..c9e2c16 100644 --- a/Tests/KannaTests/KannaCSSTests.swift +++ b/Tests/KannaTests/KannaCSSTests.swift @@ -121,19 +121,23 @@ class KannaCSSTests: XCTestCase { let allCheckCount = 100 * css2xpath.count (0..<100).forEach { _ in for testCase in css2xpath { - DispatchQueue.global().async { - do { - let xpath = try CSS.toXPath(testCase.css) - XCTAssert(xpath == testCase.xpath, "Create XPath = [\(xpath)] != [\(testCase.xpath)]") - } catch { - XCTAssert(false, error.localizedDescription) + if #available(macOS 10.10, *) { + DispatchQueue.global().async { + do { + let xpath = try CSS.toXPath(testCase.css) + XCTAssert(xpath == testCase.xpath, "Create XPath = [\(xpath)] != [\(testCase.xpath)]") + } catch { + XCTAssert(false, error.localizedDescription) + } + lock.lock() + checkedCount += 1 + if checkedCount == allCheckCount { + exp.fulfill() + } + lock.unlock() } - lock.lock() - checkedCount += 1 - if checkedCount == allCheckCount { - exp.fulfill() - } - lock.unlock() + } else { + // Fallback on earlier versions } } }