Skip to content

Commit 29ea639

Browse files
committed
[Xcodeproj] Fix Plist to write in deterministic order.
- Also, add a missing test declaration for Linux.
1 parent 3c7d9e7 commit 29ea639

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

Sources/Xcodeproj/Plist.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extension Plist {
4040
case .array(let items):
4141
return "(" + items.map { $0.serialize() }.joined(separator: ", ") + ")"
4242
case .dictionary(let items):
43-
return "{" + items.map { " \($0) = \($1.serialize()) " }.joined(separator: "; ") + "; };"
43+
return "{" + items.sorted(by: { (lhs, rhs) in lhs.0 < rhs.0 }).map { " \($0) = \($1.serialize()) " }.joined(separator: "; ") + "; };"
4444
}
4545
}
4646

Tests/XcodeprojTests/PlistTests.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ class PlistTests: XCTestCase {
1515
func testBasics() {
1616
XCTAssertEqual("\"hello \\\" world\"", Plist.string("hello \" world").serialize())
1717
XCTAssertEqual("(\"hello world\", \"cool\")", Plist.array([.string("hello world"), .string("cool")]).serialize())
18-
XCTAssertEqual("{ user = \"cool\" ; polo = (\"hello \\\" world\", \"cool\") ; };", Plist.dictionary(["user": .string("cool"), "polo": Plist.array([.string("hello \" world"), .string("cool")])]).serialize())
18+
XCTAssertEqual("{ polo = (\"hello \\\" world\", \"cool\") ; user = \"cool\" ; };", Plist.dictionary(["user": .string("cool"), "polo": Plist.array([.string("hello \" world"), .string("cool")])]).serialize())
1919
}
20+
21+
static var allTests = [
22+
("testBasics", testBasics),
23+
]
2024
}

Tests/XcodeprojTests/XCTestManifests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public func allTests() -> [XCTestCaseEntry] {
1515
return [
1616
testCase(GenerateXcodeprojTests.allTests),
1717
testCase(FunctionalTests.allTests),
18+
testCase(PlistTests.allTests),
1819
]
1920
}
2021
#endif

0 commit comments

Comments
 (0)