Skip to content

Commit

Permalink
Fix some bugs and add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pepicrft committed Jul 20, 2024
1 parent 1760894 commit 875bbcb
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class PBXFileSystemSynchronizedBuildFileExceptionSet: PBXObject {
// MARK: - Equatable

override func isEqual(to object: Any?) -> Bool {
guard let rhs = object as? PBXFrameworksBuildPhase else { return false }
guard let rhs = object as? PBXFileSystemSynchronizedBuildFileExceptionSet else { return false }
return isEqual(to: rhs)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public class PBXFileSystemSynchronizedRootGroup: PBXFileElement {
}

override func isEqual(to object: Any?) -> Bool {
guard let rhs = object as? PBXFrameworksBuildPhase else { return false }
guard let rhs = object as? PBXFileSystemSynchronizedRootGroup else { return false }
return isEqual(to: rhs)
}
}
7 changes: 4 additions & 3 deletions Sources/XcodeProj/Objects/Targets/PBXTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ public class PBXTarget: PBXContainerItem {
packageProductDependencyReferences = packageProductDependencyReferenceStrings.map {
objectReferenceRepository.getOrCreate(reference: $0, objects: objects)
}
let fileSystemSynchronizedGroupsReferences: [String] = try container.decodeIfPresent(.fileSystemSynchronizedGroups) ?? []
self.fileSystemSynchronizedGroupsReferences = fileSystemSynchronizedGroupsReferences.map { objectReferenceRepository.getOrCreate(reference: $0, objects: objects) }

let fileSystemSynchronizedGroupsReferences: [String]? = try container.decodeIfPresent(.fileSystemSynchronizedGroups)
if let fileSystemSynchronizedGroupsReferences = fileSystemSynchronizedGroupsReferences {
self.fileSystemSynchronizedGroupsReferences = fileSystemSynchronizedGroupsReferences.map { objectReferenceRepository.getOrCreate(reference: $0, objects: objects) }

Check failure on line 186 in Sources/XcodeProj/Objects/Targets/PBXTarget.swift

View workflow job for this annotation

GitHub Actions / Swiftlint

Line Length Violation: Line should be 170 characters or less; currently it has 175 characters (line_length)

Check failure on line 186 in Sources/XcodeProj/Objects/Targets/PBXTarget.swift

View workflow job for this annotation

GitHub Actions / Swiftlint

Line Length Violation: Line should be 170 characters or less; currently it has 175 characters (line_length)
}
productType = try container.decodeIfPresent(.productType)
try super.init(from: decoder)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import XcodeProj

extension PBXFileSystemSynchronizedBuildFileExceptionSet {
static func fixture(target: PBXTarget = .fixture(),
membershipExceptions: [String]? = [],
publicHeaders: [String]? = [],
privateHeaders: [String]? = []) -> PBXFileSystemSynchronizedBuildFileExceptionSet {
return PBXFileSystemSynchronizedBuildFileExceptionSet(target: target,
membershipExceptions: membershipExceptions,
publicHeaders: publicHeaders,
privateHeaders: privateHeaders)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Foundation
import XCTest
@testable import XcodeProj

final class PBXFileSystemSynchronizedBuildFileExceptionSetTests: XCTestCase {
var target: PBXTarget!
var subject: PBXFileSystemSynchronizedBuildFileExceptionSet!

override func setUp() {
super.setUp()
target = PBXTarget.fixture()
subject = PBXFileSystemSynchronizedBuildFileExceptionSet.fixture(target: target)
}

override func tearDown() {
target = nil
subject = nil
super.tearDown()
}

func test_itHasTheCorrectIsa() {
XCTAssertEqual(PBXFileSystemSynchronizedBuildFileExceptionSet.isa, "PBXFileSystemSynchronizedBuildFileExceptionSet")
}

func test_equal_returnsTheCorrectValue() {
let another = PBXFileSystemSynchronizedBuildFileExceptionSet.fixture(target: target)
XCTAssertEqual(subject, another)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import XcodeProj

extension PBXFileSystemSynchronizedRootGroup {
static func fixture(sourceTree: PBXSourceTree? = nil,
path: String? = nil,
name: String? = nil,
includeInIndex: Bool? = nil,
usesTabs: Bool? = nil,
indentWidth: UInt? = nil,
tabWidth: UInt? = nil,
wrapsLines: Bool? = nil,
explicitFileTypes: [String: String] = [:],
exceptions: [PBXFileSystemSynchronizedBuildFileExceptionSet] = [],
explicitFolders: [String] = []) -> PBXFileSystemSynchronizedRootGroup {
return PBXFileSystemSynchronizedRootGroup(sourceTree: sourceTree,
path: path,
name: name,
includeInIndex: includeInIndex,
usesTabs: usesTabs,
indentWidth: indentWidth,
tabWidth: tabWidth,
wrapsLines: wrapsLines,
explicitFileTypes: explicitFileTypes,
exceptions: exceptions,
explicitFolders: explicitFolders)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import Foundation
import XCTest
@testable import XcodeProj

final class PBXFileSystemSynchronizedRootGroupTests: XCTestCase {
var subject: PBXFileSystemSynchronizedRootGroup!
var target: PBXTarget!
var exception: PBXFileSystemSynchronizedBuildFileExceptionSet!

override func setUp() {
super.setUp()
target = PBXTarget.fixture()
exception = PBXFileSystemSynchronizedBuildFileExceptionSet.fixture(target: target)
subject = PBXFileSystemSynchronizedRootGroup(sourceTree: .group,
path: "synchronized",
name: "synchronized",
includeInIndex: true,
usesTabs: true,
indentWidth: 2,
tabWidth: 2,
wrapsLines: true,
explicitFileTypes: ["Source.m": "sourcecode.c.objc"],
exceptions: [exception],
explicitFolders: [])
}

override func tearDown() {
exception = nil
subject = nil
super.tearDown()
}

func test_itHasTheCorrectIsa() {
XCTAssertEqual(PBXFileSystemSynchronizedRootGroup.isa, "PBXFileSystemSynchronizedRootGroup")
}

func test_equal_returnsTheCorrectValue() {
let another = PBXFileSystemSynchronizedRootGroup(sourceTree: .group,
path: "synchronized",
name: "synchronized",
includeInIndex: true,
usesTabs: true,
indentWidth: 2,
tabWidth: 2,
wrapsLines: true,
explicitFileTypes: ["Source.m": "sourcecode.c.objc"],
exceptions: [exception],
explicitFolders: [])
XCTAssertEqual(subject, another)
}
}

0 comments on commit 875bbcb

Please sign in to comment.