-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from roman-dzieciol/test-summaries
Add model and tests for test action result summaries
- Loading branch information
Showing
10 changed files
with
1,623 additions
and
1,235 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
SWXCResult.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file was deleted.
Oops, something went wrong.
107 changes: 29 additions & 78 deletions
107
SWXCResult.xcodeproj/xcshareddata/xcschemes/SWXCResult-Package.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "9999" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "SWXCResult::SWXCResult" | ||
BuildableName = "SWXCResult.framework" | ||
BlueprintName = "SWXCResult" | ||
ReferencedContainer = "container:SWXCResult.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
codeCoverageEnabled = "YES" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "SWXCResult::SWXCResultTests" | ||
BuildableName = "SWXCResultTests.xctest" | ||
BlueprintName = "SWXCResultTests" | ||
ReferencedContainer = "container:SWXCResult.xcodeproj"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
<AdditionalOptions> | ||
</AdditionalOptions> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
<Scheme LastUpgradeVersion = "9999" version = "1.3"> | ||
<BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BuildableName = "'lib$(TARGET_NAME)'" | ||
BlueprintName = "SWXCResult" | ||
ReferencedContainer = "container:SWXCResult.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
codeCoverageEnabled = "NO"> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "SWXCResult::SWXCResult" | ||
BuildableName = "SWXCResult.framework" | ||
BlueprintName = "SWXCResult" | ||
BuildableName = "'$(TARGET_NAME)'" | ||
BlueprintName = "SWXCResultTests" | ||
ReferencedContainer = "container:SWXCResult.xcodeproj"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
<AdditionalOptions> | ||
</AdditionalOptions> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
</TestAction> | ||
</Scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
import Foundation | ||
|
||
public final class SchemeActionResultTestSummary: Codable { | ||
|
||
public let FormatVersion: String | ||
|
||
public let RunDestination: SchemeActionRunDestinationRecord | ||
|
||
public let TestableSummaries: [SchemeActionTestableSummary] | ||
|
||
|
||
public static func from(contentsOf url: URL) throws -> SchemeActionResultTestSummary { | ||
let inputData = try Data(contentsOf: url) | ||
let decoder = PropertyListDecoder() | ||
return try decoder.decode(SchemeActionResultTestSummary.self, from: inputData) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import XCTest | ||
@testable import SWXCResult | ||
|
||
|
||
final class PlistTests: XCTestCase { | ||
|
||
func testCodable() throws { | ||
do { | ||
let bundleDirURL = try generateResultBundles() | ||
let inputURL = bundleDirURL.appendingPathComponent("CleanAnalyzeTest.result") | ||
|
||
let xcresult = try XCResult(bundleURL: inputURL) | ||
let infoPlist = xcresult.infoPlist | ||
let infoOutputURL = urlForStoringInTempDir(url: xcresult.infoURL) | ||
|
||
try write(asPlist: infoPlist, url: infoOutputURL) | ||
XCTAssertTrue(try diff(url: xcresult.infoURL, with: infoOutputURL)) | ||
|
||
let testSummariesURL = try infoPlist.urlForTestSummary(relativeTo: inputURL) | ||
let testSummariesPlist = try infoPlist.testSummary(relativeTo: inputURL) | ||
let testSummariesOutputURL = urlForStoringInTempDir(url: testSummariesURL) | ||
|
||
try write(asPlist: testSummariesPlist, url: testSummariesOutputURL) | ||
XCTAssertTrue(try diff(url: testSummariesURL, with: testSummariesOutputURL)) | ||
|
||
try xcresult.infoPlist.Actions?.forEach { action in | ||
try [action.ActionResult, action.BuildResult].compactMap{ $0 }.forEach { result in | ||
if let url = result.urlForTestSummary(relativeTo: inputURL) { | ||
let summaries = try SchemeActionResultTestSummary.from(contentsOf: url) | ||
let outputURL = urlForStoringInTempDir(url: url) | ||
try write(asPlist: summaries, url: outputURL) | ||
XCTAssertTrue(try diff(url: url, with: outputURL)) | ||
} | ||
} | ||
} | ||
} catch { | ||
NSLog("error: \(error)") | ||
throw error | ||
} | ||
} | ||
|
||
func write<T>(asPlist object: T, url: URL) throws where T: Codable { | ||
let plistEncoder = PropertyListEncoder() | ||
plistEncoder.outputFormat = .xml | ||
let outputData = try plistEncoder.encode(object) | ||
try outputData.write(to: url) | ||
} | ||
|
||
func urlForStoringInTempDir(url: URL) -> URL { | ||
let ext = url.pathExtension | ||
let basename = url.deletingPathExtension().lastPathComponent | ||
return FileManager.default | ||
.temporaryDirectory | ||
.appendingPathComponent(basename) | ||
.appendingPathExtension(UUID().uuidString) | ||
.appendingPathExtension(ext) | ||
} | ||
|
||
static var allTests = [ | ||
("testCodable", testCodable), | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters