Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1435: ContentBlockerTests failing intermittently. #1436

Merged
merged 1 commit into from Sep 3, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Fix #1435: ContentBlockerTests failing intermittently.

  • Loading branch information
iccub committed Aug 27, 2019
commit 01831e181aca622d912b2bcbc3d040e3a6ca1eb0
@@ -20,38 +20,44 @@ class ContentBlockerTests: XCTestCase {
let bundleURL = testBundle.bundleURL
store = WKContentRuleListStore(url: bundleURL)!

let cleanStoreExpectation = expectation(description: "rule list setup")
cleanStoreExpectation.isInverted = true

contentBlocker = BlocklistName(filename: contentBlockerName)

store.getAvailableContentRuleListIdentifiers { ids in
if ids != nil && !ids!.isEmpty {
XCTAssert(false)
return
if ids?.isEmpty == false {
cleanStoreExpectation.fulfill()
}
}

wait(for: [cleanStoreExpectation], timeout: 1)
}

override func tearDown() {
let ruleListsRemoved = XCTestExpectation(description: "rule lists removed")

var removedRuleLists: [XCTestExpectation] = []

store.getAvailableContentRuleListIdentifiers { ids in
guard let ids = ids else { return }

var idsWithCompletions = [String: Deferred<()>]()

ids.forEach { id in
idsWithCompletions[id] = Deferred<()>()
let idExpectation = self.expectation(description: "id: \(id)")

removedRuleLists.append(idExpectation)

self.store.removeContentRuleList(forIdentifier: id) { error in
if error != nil { return }
idsWithCompletions[id]?.fill(())
idExpectation.fulfill()

}
}

all(Array(idsWithCompletions.values)).upon { _ in
ruleListsRemoved.fulfill()
}
ruleListsRemoved.fulfill()
}

wait(for: [ruleListsRemoved], timeout: 1)
wait(for: [ruleListsRemoved] + removedRuleLists, timeout: 2)

super.tearDown()
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.