Xcresultowners
This project supplements the test results summary produced by xcresulttool with code ownership defined in GitHub's CODEOWNERS file.
Install / Use
/learn @sdidla/XcresultownersREADME
xcresultowners
This project supplements the test results summary produced by xcresulttool with code ownership defined in GitHub's CODEOWNERS file. The package includes two products:
xcresultowners: The command line tool to identify owners of failed tests.XCResultOwnersCore: The library that can be used to build your own macOS tool.
Installation
Install the command line tool using Homebrew:
brew install sdidla/formulae/xcresultowners
Usage
You will need the path to libIndexStore.dylib that is installed with Xcode. This can be located using:
xcrun xcodebuild -find-library libIndexStore.dylib
You will also need to locate the index store of your project. Both Xcode and Swift Package Manager, by default, create an index store before or while building your project.
- For Xcode projects, by default it is located at
$HOME/Library/Developer/Xcode/DerivedData/<projectname>-<hash>/Index.noindex/DataStore - For SPM projects, by default it is located at
./build/debug/index/store
xcresultowners
Supplement xcresult summary with owners
# Genrate a json file with xcresult summary
xcrun xcresulttool get test-results summary --path <path-to-xcresult-bundle> > xcresult.json
# Use xcresultowners to supplement code owners
swift run xcresultowners \
--library-path $(xcrun xcodebuild -find-library libIndexStore.dylib) \
--repository-path <path-to-repository-containing-code-and-codeowners> \
--store-path <path-to-project-index-store> \
--format <json|markdown> \
xcresult.json
List owners of files
swift run xcresultowners file-owners --repository-path <path-to-repository>
Locate tests using IndexStoreDB
swift run xcresultowners locate-test \
--library-path $(xcrun xcodebuild -find-library libIndexStore.dylib) \
--store-path <path-to-project-index-store> \
--module-name <module-name> \
--test-identifier-string <test-identifier-string-from-xcresults-file>
Comprehensive USAGE details
swift run xcresultowners help
XCResultOwnersCore
Resolving owners of all failures
import XCResultOwnersCore
let xcResultSummary = try JSONDecoder().decode(XCResultSummary.self, from: xcResultSummaryJSON)
async let ownedFiles = resolveFileOwners(repositoryURL: repositoryFileURL)
async let indexStoreDB = IndexStoreDB(storePath: storePath, libraryPath: libraryPath)
let ownedFailures = try await resolveFailureOwners(
testFailures: xcResultSummary.testFailures,
ownedFiles: ownedFiles,
indexStoreDB: indexStoreDB
)
for failure in ownedFailures {
print("original failure:", failure.xcFailure)
print("path:", failure.path)
print("owners:", failure.owners)
}
Identifying owners of a file
import XCResultOwnersCore
let repositoryURL = URL(filePath: repositoryPath)
let ownedFiles = try await resolveFileOwners(repositoryURL: repositoryURL)
for file in ownedFiles {
print(file.fileURL)
print(file.owners)
}
Locating Tests
import XCResultOwnersCore
let indexStoreDB = try await IndexStoreDB(
storePath: storePath,
libraryPath: libraryPath
)
let location = indexStoreDB.locate(
testIdentifierString: testIdentifierString,
moduleName: moduleName
)
print(location.moduleName)
print(location.path)
print(location.line)
print(location.utf8Column)
API Documentation
Implementation Details
-
In Xcode 16.3, Apple updated
xcresulttoolto use a much improved JSON schema. The human-readable JSON summary can be printed using:xcrun xcresulttool get test-results summary --path <path-to-xcresult-bundle>The output includes a
testIdentifierStringandtargetNamefor each failing test case. -
Since the
testIdentifierStringis not a location of a file, this needs to be mapped to a file path. Under the hood, Xcode uses the open-sourced indexstore-db project (available as a swift package) for features such as symbol lookups and code completion. This library can be leveraged to locate the test case represented bytestIdentifierString. -
Once the location where the test case is defined is determined, we can use information (patterns and associated team mentions) in the GitHub
CODEOWNERSfile to generate a list of owners for every file in a repository and determine a definitive list of owners of the test case in question. For pattern matching (globbing), we use POSIX standard'sfnmatchthat is natively available inSwift.
Versioning
Though this project uses semantic versioning, to be used as an SPM package dependency, you will have to use the revision: parameter as the underlying indexstore-db project does not use strict semantic versioning.
dependencies: [
.package(url: "https://github.com/sdidla/xcresultowners", revision: "<#release-tag#>")
],
Related Skills
node-connect
347.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
