Skip to content

Commit

Permalink
Remove RugbyPods scheme after testing
Browse files Browse the repository at this point in the history
  • Loading branch information
swiftyfinch committed Mar 9, 2024
1 parent a74bc9e commit 794543d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
25 changes: 17 additions & 8 deletions Sources/RugbyFoundation/Core/Test/TestManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,26 @@ final class TestManager: Loggable {
}
let processInterruptionTask = processMonitor.runOnInterruption(cleanup)

defer {
let deleteTestsTargetScheme = {
try await self.xcodeProject.deleteTargets([testsTarget.uuid: testsTarget])
}
do {
try await xcodeBuild.test(
scheme: testsTarget.name,
testPlan: testplanPath.deletingPathExtension().lastPathComponent,
simulatorName: simulatorName,
options: options,
paths: paths
)
try await deleteTestsTargetScheme()
processInterruptionTask.cancel()
cleanup()
} catch {
try await deleteTestsTargetScheme()
processInterruptionTask.cancel()
cleanup()
throw error
}
try await xcodeBuild.test(
scheme: testsTarget.name,
testPlan: testplanPath.deletingPathExtension().lastPathComponent,
simulatorName: simulatorName,
options: options,
paths: paths
)
})
}

Expand Down
14 changes: 14 additions & 0 deletions Tests/FoundationTests/Core/Test/TestManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ extension TestManagerTests {
let testplanURL = URL(fileURLWithPath: "tests/Rugby.xctestplan")
testplanEditor.createTestplanTestplanTemplatePathTestTargetsInFolderPathReturnValue = testplanURL
let testsTarget = IInternalTargetMock()
testsTarget.underlyingUuid = "test_RugbyPods_uuid"
testsTarget.underlyingName = "RugbyPods"
testsTarget.explicitDependencies = [
localPodFrameworkUnitTests.uuid: localPodFrameworkUnitTests,
Expand Down Expand Up @@ -397,6 +398,12 @@ extension TestManagerTests {
XCTAssertEqual(loggerBlockInvocations[9].level, .result)
XCTAssertEqual(loggerBlockInvocations[9].output, .all)

XCTAssertEqual(xcodeProject.deleteTargetsKeepGroupsCallsCount, 1)
let deleteTargetsArgs = try XCTUnwrap(xcodeProject.deleteTargetsKeepGroupsReceivedArguments)
XCTAssertEqual(deleteTargetsArgs.targetsForRemove.count, 1)
XCTAssertTrue(deleteTargetsArgs.targetsForRemove.contains(testsTarget.uuid))
XCTAssertTrue(deleteTargetsArgs.keepGroups)

XCTAssertEqual(loggerBlockInvocations[10].header, "Marking Tests as Passed")
XCTAssertNil(loggerBlockInvocations[10].footer)
XCTAssertNil(loggerBlockInvocations[10].metricKey)
Expand Down Expand Up @@ -515,6 +522,7 @@ extension TestManagerTests {
let testplanURL = URL(fileURLWithPath: "tests/Rugby.xctestplan")
testplanEditor.createTestplanTestplanTemplatePathTestTargetsInFolderPathReturnValue = testplanURL
let testsTarget = IInternalTargetMock()
testsTarget.underlyingUuid = "test_RugbyPods_uuid"
testsTarget.underlyingName = "RugbyPods"
testsTarget.explicitDependencies = [
localPodFrameworkUnitTests.uuid: localPodFrameworkUnitTests,
Expand Down Expand Up @@ -664,6 +672,12 @@ extension TestManagerTests {
XCTAssertEqual(loggerBlockInvocations[9].level, .result)
XCTAssertEqual(loggerBlockInvocations[9].output, .all)

XCTAssertEqual(xcodeProject.deleteTargetsKeepGroupsCallsCount, 1)
let deleteTargetsArgs = try XCTUnwrap(xcodeProject.deleteTargetsKeepGroupsReceivedArguments)
XCTAssertEqual(deleteTargetsArgs.targetsForRemove.count, 1)
XCTAssertTrue(deleteTargetsArgs.targetsForRemove.contains(testsTarget.uuid))
XCTAssertTrue(deleteTargetsArgs.keepGroups)

XCTAssertEqual(logger.logLevelOutputReceivedInvocations.count, 4)
XCTAssertEqual(logger.logLevelOutputReceivedInvocations[0].text, "LocalPod-framework-Unit-Tests")
XCTAssertEqual(logger.logLevelOutputReceivedInvocations[0].output, .all)
Expand Down

0 comments on commit 794543d

Please sign in to comment.