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

Add parallel test processing #334

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions Sources/XCTestHTMLReportCore/Classes/Models/Run.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,36 @@ struct Run: HTML {
Logger.warning("Can't find test reference for action \(action.title ?? "")")
logContent = .none
}
testSummaries = testPlanSummaries.summaries

let cpuCount = ProcessInfo.processInfo.processorCount
let operationQueue = OperationQueue()
operationQueue.maxConcurrentOperationCount = cpuCount * 2

let queue = DispatchQueue(label: "com.xchtmlreport.lock")

var summaries = [TestSummary]()

testPlanSummaries.summaries
.flatMap(\.testableSummaries)
.map { TestSummary(
summary: $0,
file: file,
renderingMode: renderingMode,
downsizeImagesEnabled: downsizeImagesEnabled,
downsizeScaleFactor: downsizeScaleFactor
) }
.forEach { testableSummary in
let operation = BlockOperation {
let summary = TestSummary(
summary: testableSummary,
file: file,
renderingMode: renderingMode,
downsizeImagesEnabled: downsizeImagesEnabled,
downsizeScaleFactor: downsizeScaleFactor
)
queue.sync {
summaries.append(summary)
}
}
operationQueue.addOperation(operation)
}

operationQueue.waitUntilAllOperationsAreFinished()

testSummaries = summaries.sorted { $0.testName < $1.testName }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if this is significantly different from today's behavior? More just to determine if the next release should denote this as a breaking change.

}

private var logSource: String? {
Expand Down
Loading