Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Select latest Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
xcode-version: '16.1'

- name: 🛠️ Run All Tests
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public struct MarkdownOutputGenerator: OutputGenerating {
let changes = Self.changeLines(changesPerModule: changesPerTarget)

var lines = [
Self.title(changesPerTarget: changesPerTarget)
Self.title(changesPerTarget: changesPerTarget, allTargets: allTargets)
]

if let oldVersionName, let newVersionName {
Expand All @@ -46,7 +46,7 @@ public struct MarkdownOutputGenerator: OutputGenerating {
lines += changes + [separator]
}

if let allTargets {
if let allTargets, !allTargets.isEmpty {
lines += [
Self.analyzedModulesInfo(allTargets: allTargets)
]
Expand All @@ -60,7 +60,15 @@ public struct MarkdownOutputGenerator: OutputGenerating {

private extension MarkdownOutputGenerator {

static func title(changesPerTarget: [String: [Change]]) -> String {
static func title(
changesPerTarget: [String: [Change]],
allTargets: [String]?
) -> String {

if let allTargets, allTargets.isEmpty {
// We got targets but the list is empty -> Show an error
return "# ‼️ No analyzable targets detected"
}

if changesPerTarget.keys.isEmpty {
return "# ✅ No changes detected"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public protocol OutputGenerating<OutputType> {
/// Generates an output from input parameters
/// - Parameters:
/// - changesPerTarget: A list of changes per target/module
/// - allTargets: A list of all targets/modules that were analysed in previous steps
/// - allTargets: A list of all targets/modules that were analysed in previous steps - if targets are provided but the list is empty it is treated like a failure
/// - oldVersionName: The name of the old/reference version
/// - newVersionName: The name of the new/updated version
/// - warnings: A list of warnings produced in previous steps
Expand Down
70 changes: 62 additions & 8 deletions Tests/UnitTests/OutputGeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
//

@testable import PADOutputGenerator
import XCTest
import Testing

class OutputGeneratorTests: XCTestCase {
class OutputGeneratorTests {

func test_noChanges_singleModule() {
@Test

Choose a reason for hiding this comment

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

👏

func noChanges_singleModule() {

let expectedOutput = """
# ✅ No changes detected
Expand All @@ -27,10 +28,12 @@ class OutputGeneratorTests: XCTestCase {
newVersionName: "new_source",
warnings: []
)
XCTAssertEqual(output, expectedOutput)

#expect(output == expectedOutput)
}

func test_oneChange_singleModule() {
@Test
func oneChange_singleModule() {

let expectedOutput = """
# 👀 1 public change detected
Expand All @@ -57,10 +60,12 @@ class OutputGeneratorTests: XCTestCase {
newVersionName: "new_source",
warnings: []
)
XCTAssertEqual(output, expectedOutput)

#expect(output == expectedOutput)
}

func test_multipleChanges_multipleModules() {
@Test
func multipleChanges_multipleModules() {

let expectedOutput = """
# ⚠️ 4 public changes detected ⚠️
Expand Down Expand Up @@ -109,6 +114,55 @@ class OutputGeneratorTests: XCTestCase {
newVersionName: "new_source",
warnings: []
)
XCTAssertEqual(output, expectedOutput)

#expect(output == expectedOutput)
}

struct AllTargetsExpectation {
let allTargets: [String]?
let expectedTitle: String
let expectedTargetSection: String
}

@Test(
"allTargets should change the output as expected",
arguments: [
AllTargetsExpectation(
allTargets: [],
expectedTitle: "‼️ No analyzable targets detected",
expectedTargetSection: ""
),
AllTargetsExpectation(
allTargets: nil,
expectedTitle: "✅ No changes detected",
expectedTargetSection: ""
),
AllTargetsExpectation(
allTargets: ["SomeTarget"],
expectedTitle: "✅ No changes detected",
expectedTargetSection: "\n**Analyzed targets:** SomeTarget"
)
]
)
func allTargets_shouldChangeOutputAsExpected(argument: AllTargetsExpectation) {

let expectedOutput = """
# \(argument.expectedTitle)
_Comparing `new_source` to `old_repository @ old_branch`_

---\(argument.expectedTargetSection)
"""

let outputGenerator = MarkdownOutputGenerator()

let output = outputGenerator.generate(
from: [:],
allTargets: argument.allTargets,
oldVersionName: "old_repository @ old_branch",
newVersionName: "new_source",
warnings: []
)

#expect(output == expectedOutput)
}
}
2 changes: 2 additions & 0 deletions Tests/public-api-diff.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@
},
"testTargets" : [
{
"parallelizable" : true,
"target" : {
"containerPath" : "container:",
"identifier" : "IntegrationTests",
"name" : "IntegrationTests"
}
},
{
"parallelizable" : true,
"target" : {
"containerPath" : "container:",
"identifier" : "UnitTests",
Expand Down
Loading