xtool.git
Publicgit clone https://git.maproj.org/xtool.gitxtool.git / Tests / XToolTests / PackerTests.swift
PackerTests.swift40 lines · 2.0 KiBRaw
| 1 | import Foundation |
| 2 | import Testing |
| 3 | @testable import PackLib |
| 4 | |
| 5 | @Test func cfBundleSupportedPlatformsFollowsBuildTriple() { |
| 6 | #expect(Packer.cfBundleSupportedPlatforms(for: "arm64-apple-ios") == ["iPhoneOS"]) |
| 7 | #expect(Packer.cfBundleSupportedPlatforms(for: "arm64-apple-ios-simulator") == ["iPhoneSimulator"]) |
| 8 | |
| 9 | #expect(Packer.cfBundleSupportedPlatforms(for: "arm64-apple-ios17.0") == ["iPhoneOS"]) |
| 10 | #expect(Packer.cfBundleSupportedPlatforms(for: "arm64-apple-ios17.0-simulator") == ["iPhoneSimulator"]) |
| 11 | #expect(Packer.cfBundleSupportedPlatforms(for: "x86_64-apple-ios-simulator") == ["iPhoneSimulator"]) |
| 12 | #expect(Packer.cfBundleSupportedPlatforms(for: "arm64-apple-macosx") == ["MacOSX"]) |
| 13 | #expect(Packer.cfBundleSupportedPlatforms(for: "x86_64-apple-macosx") == ["MacOSX"]) |
| 14 | |
| 15 | #expect(Packer.cfBundleSupportedPlatforms(for: "unknown-triple") == ["iPhoneOS"]) |
| 16 | } |
| 17 | |
| 18 | @Test func compiledAssetFileNamesExcludesSidecarsAndPartialPlist() throws { |
| 19 | let dir = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) |
| 20 | try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true) |
| 21 | defer { try? FileManager.default.removeItem(at: dir) } |
| 22 | for name in ["Assets.car", "[email protected]", "Assets.xcassets.sha256", "assets-partial-Info.plist"] { |
| 23 | try Data().write(to: dir.appendingPathComponent(name)) |
| 24 | } |
| 25 | #expect(try Packer.compiledAssetFileNames(in: dir) == ["[email protected]", "Assets.car"]) |
| 26 | #expect(throws: (any Error).self) { |
| 27 | try Packer.compiledAssetFileNames(in: dir.appendingPathComponent("missing")) |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | @Test func packSchemaDecodesAssetCatalogCompiledDir() throws { |
| 32 | let base = try YAMLTestDecode() |
| 33 | #expect(base.assetCatalog?.compiledDir == "Resources") |
| 34 | } |
| 35 | |
| 36 | private func YAMLTestDecode() throws -> PackSchemaBase { |
| 37 | // Exercises the same Codable shape xtool.yml uses in Modern-Apps. |
| 38 | let json = #"{"version":1,"bundleID":"cc.findfamily.app.1","assetCatalog":{"compiledDir":"Resources"}}"# |
| 39 | return try JSONDecoder().decode(PackSchemaBase.self, from: Data(json.utf8)) |
| 40 | } |