more fixes for tests
iOS CI / Build and Test SwiftUI App (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build Unsigned iOS IPA (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build macOS ZIP (push) Canceled after 0s

This commit is contained in:
wt committed 2026-08-11 15:42:01 +07:00
1 parent 2558f722fc
commit 88616124b6
4 files changed
+60 -9

No files matched your search

+9 -1
View File
@@ -32,4 +32,12 @@ jobs:
xcodebuild test \
-project Luma.xcodeproj \
-scheme Luma \
-destination 'platform=iOS Simulator,name=iPhone 17 Pro Max,OS=26.4.1'
-destination 'platform=iOS Simulator,name=iPhone 17 Pro Max,OS=26.4.1' \
-resultBundlePath TestResults.xcresult
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Luma-TestResults
path: TestResults.xcresult
+16 -3
View File
@@ -4,6 +4,14 @@ import Foundation
import UniformTypeIdentifiers
import WebRTC
enum RuntimeEnvironment {
static var isRunningTests: Bool {
let environment = ProcessInfo.processInfo.environment
return environment["XCTestConfigurationFilePath"] != nil
|| environment["XCTestBundlePath"] != nil
}
}
@MainActor
final class AppModel: ObservableObject {
@Published private(set) var account: AccountConfiguration?
@@ -186,9 +194,11 @@ final class AppModel: ObservableObject {
}
}
bootstrapTask = Task { [weak self] in
guard let self else { return }
await self.bootstrap()
if !RuntimeEnvironment.isRunningTests {
bootstrapTask = Task { [weak self] in
guard let self else { return }
await self.bootstrap()
}
}
}
@@ -242,6 +252,7 @@ final class AppModel: ObservableObject {
}
func bootstrap() async {
guard !RuntimeEnvironment.isRunningTests else { return }
guard let saved = preferences.load() else { return }
account = saved
globalEncryptionEnabled = preferences.encryptionEnabled(for: saved.normalizedJID)
@@ -376,6 +387,7 @@ final class AppModel: ObservableObject {
}
func reconnect() async {
guard !RuntimeEnvironment.isRunningTests else { return }
guard let account else { return }
do {
guard let password = try credentials.password(for: account.normalizedJID) else {
@@ -390,6 +402,7 @@ final class AppModel: ObservableObject {
func setApplicationActive(_ active: Bool) {
appIsActive = active
guard !RuntimeEnvironment.isRunningTests else { return }
xmpp.setApplicationActive(active)
if !active {
resetTypingState()
@@ -49,7 +49,10 @@ final class PhoneWatchBridge: NSObject, WCSessionDelegate {
private var deliveredVoiceTransferIDs: Set<String> = []
override init() {
session = WCSession.isSupported() ? .default : nil
session =
!RuntimeEnvironment.isRunningTests && WCSession.isSupported()
? .default
: nil
super.init()
pendingVoiceMessages = Self.loadPersistedVoiceMessages()
session?.delegate = self
@@ -150,6 +153,7 @@ final class PhoneWatchBridge: NSObject, WCSessionDelegate {
func sessionDidBecomeInactive(_ session: WCSession) {}
func sessionDidDeactivate(_ session: WCSession) {
guard !RuntimeEnvironment.isRunningTests else { return }
session.activate()
}
+30 -4
View File
@@ -22,19 +22,45 @@ final class CryptoKitAESGCMEngineTests: XCTestCase {
func testModifiedTagFails() {
let engine = CryptoKitAESGCMEngine()
let key = Data(repeating: 0x31, count: 16)
let iv = Data(repeating: 0x22, count: 12)
var ciphertext = Data()
var tag = Data()
XCTAssertTrue(
guard
engine.encrypt(
iv: iv, key: key, message: Data("secret".utf8), output: &ciphertext, tag: &tag))
iv: iv,
key: key,
message: Data("secret".utf8),
output: &ciphertext,
tag: &tag
)
else {
XCTFail("AES-GCM encryption unexpectedly failed")
return
}
XCTAssertEqual(tag.count, 16)
guard tag.count == 16 else {
return
}
var modifiedTag = tag
modifiedTag[0] ^= 0x01
modifiedTag[modifiedTag.startIndex] ^= 0x01
var decrypted = Data()
XCTAssertFalse(
engine.decrypt(
iv: iv, key: key, encoded: ciphertext, auth: modifiedTag, output: &decrypted))
iv: iv,
key: key,
encoded: ciphertext,
auth: modifiedTag,
output: &decrypted
)
)
}
}