Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

Keep the run bookkeeping tests away from the real support folder

NotProtonNot98ef31748010
diff --git a/app/Sources/NotProtonApp/SystemStatus.swift b/app/Sources/NotProtonApp/SystemStatus.swift
index 6a37705..cbcdcd4 100644
--- a/app/Sources/NotProtonApp/SystemStatus.swift
+++ b/app/Sources/NotProtonApp/SystemStatus.swift
@@ -62,6 +62,9 @@ final class SystemStatus {
private(set) var failureRemedy: Remedy?
private var runInFlight = false
+ // Tests replace the refresh so a run does not modify the real Steam/support folders
+ // if run on an actual user's machine.
+ @ObservationIgnored var refreshAfterRun: @MainActor (SystemStatus) async -> Void = { await $0.refresh() }
private var checkingLicense = false
var isBusy: Bool { activity != nil || runInFlight || checkingLicense }
@@ -313,7 +316,7 @@ final class SystemStatus {
record(error)
}
- await refresh()
+ await refreshAfterRun(self)
}
private func setUpRunner(from install: CrossOverInstall?, replacingExisting: Bool = false) async {
diff --git a/app/Tests/NotProtonAppTests/SystemStatusTests.swift b/app/Tests/NotProtonAppTests/SystemStatusTests.swift
index e2e92fb..ac17809 100644
--- a/app/Tests/NotProtonAppTests/SystemStatusTests.swift
+++ b/app/Tests/NotProtonAppTests/SystemStatusTests.swift
@@ -466,9 +466,15 @@ struct ActivationQuestionTests {
@Suite("Run bookkeeping")
struct PerformTests {
+ private func quietStatus() -> SystemStatus {
+ let status = SystemStatus()
+ status.refreshAfterRun = { _ in }
+ return status
+ }
+
@Test("A run ends carrying what its body said")
func outcomeComesFromTheBody() async {
- let status = SystemStatus()
+ let status = quietStatus()
await status.perform(from: "Working") { _ in "Done." }
@@ -478,7 +484,7 @@ struct PerformTests {
@Test("A run with nothing to say leaves no outcome behind")
func nothingToSayLeavesNoOutcome() async {
- let status = SystemStatus()
+ let status = quietStatus()
await status.perform(from: "Working") { _ in "Done." }
await status.perform(from: "Working") { _ in nil }
@@ -488,7 +494,7 @@ struct PerformTests {
@Test("A run drops the failure the one before it left")
func aRunClearsTheEarlierFailure() async {
- let status = SystemStatus()
+ let status = quietStatus()
status.setFailure("Old news.")
await status.perform(from: "Working") { _ in "Done." }
@@ -499,7 +505,7 @@ struct PerformTests {
@Test("A body that throws ends the run as a failure and not as an outcome")
func aThrownErrorIsRecorded() async {
- let status = SystemStatus()
+ let status = quietStatus()
// Left by an earlier run, so a failure has something to clear. Without it the
// outcome is already nil and the run never has to drop anything.
await status.perform(from: "Working") { _ in "Done." }
@@ -514,7 +520,7 @@ struct PerformTests {
@Test("The opening label is on screen before the body starts")
func theOpeningLabelIsUpFirst() async {
- let status = SystemStatus()
+ let status = quietStatus()
var seen: String?
await status.perform(from: "Cloning") { _ in
@@ -527,7 +533,7 @@ struct PerformTests {
@Test("A run counts as busy until it is over")
func busyForTheWholeRun() async {
- let status = SystemStatus()
+ let status = quietStatus()
var busyMidRun = false
await status.perform(from: "Working") { progress in
@@ -539,4 +545,15 @@ struct PerformTests {
#expect(busyMidRun)
#expect(!status.isBusy)
}
+
+ @Test("A run refreshes the status before it stops counting as busy")
+ func refreshesBeforeTheRunEnds() async {
+ let status = SystemStatus()
+ var busyDuringRefresh: Bool?
+ status.refreshAfterRun = { busyDuringRefresh = $0.isBusy }
+
+ await status.perform(from: "Working") { _ in "Done." }
+
+ #expect(busyDuringRefresh == true)
+ }
}