Sync source edition with VCC Plus 3.7.0 build 63
This commit is contained in:
1 parent
c652a5276d
commit
b2ecec4d87
86 files changed
+10519
-472
No files matched your search
@@ -36,21 +36,21 @@ final class SoftwareLibraryMachineLaunchTests: XCTestCase {
|
||||
profile.input.right.source = .controller; profile.input.right.device = "remembered-controller"
|
||||
return profile
|
||||
}
|
||||
func plan(cartridge: Bool = true, command: String? = nil, keyboardControls: Bool = false, cartridgeDevice: String = "rom") throws -> SoftwareLibraryLaunchPlan {
|
||||
func plan(cartridge: Bool = true, command: String? = nil, keyboardControls: Bool = false, cartridgeDevice: String = "rom", hardDrive: Bool = false) throws -> SoftwareLibraryLaunchPlan {
|
||||
let working = folder.appendingPathComponent(UUID().uuidString).appendingPathComponent("Working")
|
||||
try FileManager.default.createDirectory(at: working, withIntermediateDirectories: true)
|
||||
let filename = cartridge ? "Fixture.ccc" : "Fixture.dsk"
|
||||
let filename = hardDrive ? "Fixture.vhd" : cartridge ? "Fixture.ccc" : "Fixture.dsk"
|
||||
var bytes = Data(repeating: cartridge ? 0x12 : 0, count: cartridge ? 8192 : 161280)
|
||||
if cartridge { bytes[0] = 0x20; bytes[1] = 0xfe }
|
||||
try bytes.write(to: working.appendingPathComponent(filename))
|
||||
let sha = SHA256.hash(data: bytes).map { String(format: "%02x", $0) }.joined()
|
||||
var configuration: [String: LibraryJSON] = ["profile": .string(cartridge ? "rom-cartridge" : "disk-basic"), "processor": .string("6809"), "ram_kib": .number(2048), "video": .string("composite"), "controller_slot": .number(4), "controls": .object(["right": .object(["suggested_input": .string("keyboard-joystick")])])]
|
||||
var configuration: [String: LibraryJSON] = ["profile": .string(hardDrive ? "hard-drive-basic" : cartridge ? "rom-cartridge" : "disk-basic"), "processor": .string("6809"), "ram_kib": .number(2048), "video": .string("composite"), "controller_slot": .number(4), "controls": .object(["right": .object(["suggested_input": .string("keyboard-joystick")])])]
|
||||
if keyboardControls { configuration["controls"] = .object(["keyboard": .string("Arrow keys, Z, X and C")]) }
|
||||
if cartridge { configuration["launch_method"] = .string("cartridge-autostart"); configuration["cartridge_device"] = .string(cartridgeDevice) }
|
||||
let setup = SoftwareLibrarySetup(status: command == nil && !cartridge ? "manual-setup" : "inferred-ready", command: command,
|
||||
instructions: "Authored launch fixture", configuration: .object(configuration),
|
||||
selectedMembers: .array([.object(["path": .string(filename), "target": .string(cartridge ? "cartridge" : "disk0")])]), reasons: [], validation: .object([:]))
|
||||
let release = SoftwareLibraryRelease(id: "fixture", titleID: "fixture", name: "Fixture", category: cartridge ? "Cartridges" : "Disks/Games", mediaType: cartridge ? "cartridge" : "disk", contentRole: "software", sourceURL: URL(string: "https://example.invalid/" + filename)!, modifiedAt: nil, modifiedPrecision: nil, modifiedTimezone: nil, packageSHA256: sha, byteSize: Int64(bytes.count), languageStatus: "english", metadata: .object(["title": .string("Authored Launch")]), setup: setup, assets: [], downloadURLs: [])
|
||||
selectedMembers: .array([.object(["path": .string(filename), "target": .string(hardDrive ? "hard0" : cartridge ? "cartridge" : "disk0")])]), reasons: [], validation: .object([:]))
|
||||
let release = SoftwareLibraryRelease(id: "fixture", titleID: "fixture", name: "Fixture", category: cartridge ? "Cartridges" : "Disks/Games", mediaType: hardDrive ? "hard-disk" : cartridge ? "cartridge" : "disk", contentRole: "software", sourceURL: URL(string: "https://example.invalid/" + filename)!, modifiedAt: nil, modifiedPrecision: nil, modifiedTimezone: nil, packageSHA256: sha, byteSize: Int64(bytes.count), languageStatus: "english", metadata: .object(["title": .string("Authored Launch")]), setup: setup, assets: [], downloadURLs: [])
|
||||
let receipt = SoftwareLibraryInstallationReceipt(releaseID: release.id, packageSHA256: sha, installedAt: Date(), workingDirectory: working, relativeFiles: [filename])
|
||||
return try SoftwareLibraryLaunchPlan.prepare(release: release, receipt: receipt)
|
||||
}
|
||||
@@ -114,6 +114,56 @@ final class SoftwareLibraryMachineLaunchTests: XCTestCase {
|
||||
XCTAssertEqual(model.profileName, initial.name); XCTAssertTrue(after.disks[0].mounted)
|
||||
}
|
||||
}
|
||||
@MainActor func testHardDriveLibraryRejectsUnrecognizedDiskROMWithoutChangingMachine() async throws {
|
||||
let fixture = try Fixture(); defer { fixture.cleanup() }
|
||||
try await withMachine(fixture) { model, controller, initial in
|
||||
let before = await step(controller.snapshot)
|
||||
do {
|
||||
_ = try await model.prepareLibraryLaunch(fixture.plan(cartridge: false, hardDrive: true))
|
||||
XCTFail("An arbitrary Disk BASIC ROM cannot stand in for RGB-DOS")
|
||||
} catch {
|
||||
XCTAssertTrue(error.localizedDescription.contains("rgbdos.rom"))
|
||||
}
|
||||
let after = await step(controller.snapshot)
|
||||
XCTAssertEqual(after.generation, before.generation)
|
||||
XCTAssertEqual(after.state, .running)
|
||||
XCTAssertEqual(model.diskAssignments.rom, initial.media.rom)
|
||||
XCTAssertEqual(model.profileName, initial.name)
|
||||
}
|
||||
}
|
||||
@MainActor func testHardDriveLibraryUsesSuppliedRGBDOSAndRecognizedCachedFallback() async throws {
|
||||
let startup = try StartupTests.Fixture(); defer { startup.remove() }
|
||||
let fixture = try Fixture(); defer { fixture.cleanup() }
|
||||
let rgbdos = Data(repeating: 0x39, count: 8192)
|
||||
try rgbdos.write(to: startup.kit.directory.appendingPathComponent("rgbdos.rom"))
|
||||
let model = MachineModel(diskStore: startup.disks, displayDefaults: fixture.defaults,
|
||||
inputStore: .init(url: fixture.folder.appendingPathComponent("Input.json")), startupStore: startup.startup)
|
||||
do {
|
||||
try await settle(model)
|
||||
let initial = try fixture.initialProfile()
|
||||
await model.loadProfile(initial); XCTAssertNil(model.profileError)
|
||||
let plan = try fixture.plan(cartridge: false, hardDrive: true)
|
||||
let prepared = try await model.prepareLibraryLaunch(plan)
|
||||
let rom = try XCTUnwrap(prepared.profile.media.rom)
|
||||
XCTAssertNotEqual(rom, initial.media.rom)
|
||||
XCTAssertEqual(try Data(contentsOf: rom), rgbdos)
|
||||
XCTAssertEqual(prepared.profile.media.hardDisks?.drives[0]?.url, plan.hardDiskURLs[0])
|
||||
XCTAssertEqual(prepared.profile.media.cartridges?.slots[4].kind, .floppy)
|
||||
XCTAssertEqual(prepared.profile.media.cartridges?.slots[1].kind, .hardDisk)
|
||||
|
||||
// Known starter firmware remains a valid fallback after bundle moves.
|
||||
let loaded = await model.loadSystemProfile(.hardDriveBasic)
|
||||
XCTAssertTrue(loaded)
|
||||
XCTAssertEqual(model.usageProfile, .hardDriveBasic)
|
||||
try FileManager.default.removeItem(at: startup.kit.directory.appendingPathComponent("rgbdos.rom"))
|
||||
let cached = try await model.prepareLibraryLaunch(plan)
|
||||
XCTAssertEqual(cached.profile.media.rom, rom)
|
||||
XCTAssertEqual(try Data(contentsOf: XCTUnwrap(cached.profile.media.rom)), rgbdos)
|
||||
} catch {
|
||||
await withCheckedContinuation { done in model.shutdown { done.resume() } }; throw error
|
||||
}
|
||||
await withCheckedContinuation { done in model.shutdown { done.resume() } }
|
||||
}
|
||||
@MainActor func testPreviewDoesNotChangeSessionAndStaleConfigurationCannotLaunch() async throws {
|
||||
let fixture = try Fixture(); defer { fixture.cleanup() }
|
||||
try await withMachine(fixture) { model, controller, _ in
|
||||
|
||||
Reference in new issue
Block a user