Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
Remove the temp directories some tests left behind
NotProtonNotc29cbaa80d8e
diff --git a/app/Tests/NotProtonAppTests/PrefixToolsTests.swift b/app/Tests/NotProtonAppTests/PrefixToolsTests.swiftindex 70e05ef..c9c85d1 100644--- a/app/Tests/NotProtonAppTests/PrefixToolsTests.swift+++ b/app/Tests/NotProtonAppTests/PrefixToolsTests.swift@@ -344,6 +344,13 @@ struct PrefixToolsTests {// A prefix as a game leaves it: saves under the profile, a link out to the home folder,// and files the game's own installer put in windows and Program Files.+ private func usedPrefixAndRunner() throws -> (dir: URL, runner: URL, prefix: WinePrefix) {+ let dir = FileManager.default.temporaryDirectory.appending(path: "np-profile-\(UUID().uuidString)")+ let home = dir.appending(path: "home")+ try FileManager.default.createDirectory(at: home, withIntermediateDirectories: true)+ return (dir, try fakeRunner(in: dir, home: home), try usedPrefix(in: dir, home: home))+ }+private func usedPrefix(in dir: URL, home: URL) throws -> WinePrefix {let library = SteamLibrary(root: dir)let pfx = library.compatdata.appending(path: "1574480/pfx")@@ -615,11 +622,8 @@ struct PrefixToolsTests {// the link. A rebuild turns it around so Steam and the game stop reading two folders.@Test("A rebuild brings an older profile onto the steamuser layout")func rebuildPutsBackLinksTheTemplateOmits() throws {- let dir = URL(filePath: NSTemporaryDirectory()).appending(path: UUID().uuidString)- let home = dir.appending(path: "home")- try FileManager.default.createDirectory(at: home, withIntermediateDirectories: true)- let runner = try fakeRunner(in: dir, home: home)- let prefix = try usedPrefix(in: dir, home: home)+ let (dir, runner, prefix) = try usedPrefixAndRunner()+ defer { try? FileManager.default.removeItem(at: dir) }let fm = FileManager.defaultlet users = prefix.pfx.appending(path: "drive_c/users")@@ -662,11 +666,8 @@ struct PrefixToolsTests {// lost the file while its save folder came through.@Test("A rebuild keeps a file sitting loose in a profile")func rebuildKeepsALooseProfileFile() throws {- let dir = URL(filePath: NSTemporaryDirectory()).appending(path: UUID().uuidString)- let home = dir.appending(path: "home")- try FileManager.default.createDirectory(at: home, withIntermediateDirectories: true)- let runner = try fakeRunner(in: dir, home: home)- let prefix = try usedPrefix(in: dir, home: home)+ let (dir, runner, prefix) = try usedPrefixAndRunner()+ defer { try? FileManager.default.removeItem(at: dir) }let loose = prefix.pfx.appending(path: "drive_c/users/crossover/settings.ini")try Data("windowed=1".utf8).write(to: loose)@@ -679,11 +680,8 @@ struct PrefixToolsTests {// directories are in place, and a link inside a save directory is only reached that way.@Test("A rebuild keeps a link sitting inside a save directory")func rebuildKeepsALinkInsideAProfile() throws {- let dir = URL(filePath: NSTemporaryDirectory()).appending(path: UUID().uuidString)- let home = dir.appending(path: "home")- try FileManager.default.createDirectory(at: home, withIntermediateDirectories: true)- let runner = try fakeRunner(in: dir, home: home)- let prefix = try usedPrefix(in: dir, home: home)+ let (dir, runner, prefix) = try usedPrefixAndRunner()+ defer { try? FileManager.default.removeItem(at: dir) }let game = prefix.pfx.appending(path: "drive_c/users/crossover/AppData/Roaming/game")try FileManager.default.createSymbolicLink(atPath: game.appending(path: "latest").path(percentEncoded: false),@@ -701,11 +699,8 @@ struct PrefixToolsTests {// and a landing link is what makes the merge give up on a name.@Test("A link from one profile does not take the name another profile's saves land on")func linksWaitForEveryRealDirectory() throws {- let dir = URL(filePath: NSTemporaryDirectory()).appending(path: UUID().uuidString)- let home = dir.appending(path: "home")- try FileManager.default.createDirectory(at: home, withIntermediateDirectories: true)- let runner = try fakeRunner(in: dir, home: home)- let prefix = try usedPrefix(in: dir, home: home)+ let (dir, runner, prefix) = try usedPrefixAndRunner()+ defer { try? FileManager.default.removeItem(at: dir) }let fm = FileManager.defaultlet roaming = prefix.pfx.appending(path: "drive_c/users/crossover/AppData/Roaming")try fm.createSymbolicLink(@@ -729,11 +724,8 @@ struct PrefixToolsTests {// nothing about, so the rebuild took it away along with the tree it sat beside.@Test("A rebuild keeps what the template does not make")func rebuildKeepsStrayTopLevelNames() throws {- let dir = URL(filePath: NSTemporaryDirectory()).appending(path: UUID().uuidString)- let home = dir.appending(path: "home")- try FileManager.default.createDirectory(at: home, withIntermediateDirectories: true)- let runner = try fakeRunner(in: dir, home: home)- let prefix = try usedPrefix(in: dir, home: home)+ let (dir, runner, prefix) = try usedPrefixAndRunner()+ defer { try? FileManager.default.removeItem(at: dir) }let fm = FileManager.defaultlet driveC = prefix.pfx.appending(path: "drive_c")try fm.createDirectory(at: driveC.appending(path: "Games/Quake"), withIntermediateDirectories: true)diff --git a/app/Tests/NotProtonAppTests/SteamBundleTests.swift b/app/Tests/NotProtonAppTests/SteamBundleTests.swiftindex 0607e24..39a7828 100644--- a/app/Tests/NotProtonAppTests/SteamBundleTests.swift+++ b/app/Tests/NotProtonAppTests/SteamBundleTests.swift@@ -46,10 +46,20 @@ struct SteamBundleTests {case other(String)}- private func stubBundle(insert: Insert, dylib: Bool) throws -> URL {- let app = URL.temporaryDirectory- .appending(path: "np-deploy-\(UUID().uuidString)")- .appending(path: "Steam.app")+ private func deployment(+ insert: Insert, dylib: Bool, version: String?, steam: Bool = true+ ) throws -> SteamDeployment {+ let root = URL.temporaryDirectory.appending(path: "np-deploy-\(UUID().uuidString)")+ defer { try? FileManager.default.removeItem(at: root) }+ let app = root.appending(path: "Steam.app")+ let versionFile = root.appending(path: "dylib.version")+ try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)+ if let version { try Data("\(version)\n".utf8).write(to: versionFile) }+ if steam { try stubBundle(app, insert: insert, dylib: dylib) }+ return SteamBundle.deployment(bundledVersion: "0.2.0", app: app, versionFile: versionFile)+ }++ private func stubBundle(_ app: URL, insert: Insert, dylib: Bool) throws {let macOS = app.appending(path: "Contents/MacOS")try FileManager.default.createDirectory(at: macOS, withIntermediateDirectories: true)@@ -72,91 +82,48 @@ struct SteamBundleTests {if dylib {try Data("stand-in\n".utf8).write(to: macOS.appending(path: SupportPaths.dylibName))}- return app- }-- private func versionFile(_ version: String?) throws -> URL {- let root = URL.temporaryDirectory.appending(path: "np-version-\(UUID().uuidString)")- try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)- let url = root.appending(path: "dylib.version")- if let version { try Data("\(version)\n".utf8).write(to: url) }- return url}@Test("A bundle patched for this account with a matching version reads as installed")func installedForThisAccount() throws {- #expect(- SteamBundle.deployment(- bundledVersion: "0.2.0",- app: try stubBundle(insert: .own, dylib: true),- versionFile: try versionFile("0.2.0")- ) == .installed(version: "0.2.0")- )+ #expect(try deployment(insert: .own, dylib: true, version: "0.2.0") == .installed(version: "0.2.0"))}@Test("A bundle patched by another account reports no version rather than a clean install")func patchedByAnotherAccount() throws {- #expect(- SteamBundle.deployment(- bundledVersion: "0.2.0",- app: try stubBundle(insert: .own, dylib: true),- versionFile: try versionFile(nil)- ) == .installed(version: nil)- )+ #expect(try deployment(insert: .own, dylib: true, version: nil) == .installed(version: nil))}@Test("A plist naming a dylib that is not there reads as not installed")func namedDylibMissing() throws {- #expect(- SteamBundle.deployment(- bundledVersion: "0.2.0",- app: try stubBundle(insert: .own, dylib: false),- versionFile: try versionFile("0.2.0")- ) == .notInstalled- )+ #expect(try deployment(insert: .own, dylib: false, version: "0.2.0") == .notInstalled)}@Test("An older recorded version reads as outdated")func outdatedVersion() throws {#expect(- SteamBundle.deployment(- bundledVersion: "0.2.0",- app: try stubBundle(insert: .own, dylib: true),- versionFile: try versionFile("0.1.0")- ) == .outdated(deployed: "0.1.0", bundled: "0.2.0")+ try deployment(insert: .own, dylib: true, version: "0.1.0")+ == .outdated(deployed: "0.1.0", bundled: "0.2.0"))}@Test("Somebody else's insert is left alone")func foreignInsert() throws {#expect(- SteamBundle.deployment(- bundledVersion: "0.2.0",- app: try stubBundle(insert: .other("/opt/other/thing.dylib"), dylib: true),- versionFile: try versionFile(nil)- ) == .foreign(insert: "/opt/other/thing.dylib")+ try deployment(insert: .other("/opt/other/thing.dylib"), dylib: true, version: nil)+ == .foreign(insert: "/opt/other/thing.dylib"))}@Test("An unpatched bundle reads as not installed")func unpatched() throws {- #expect(- SteamBundle.deployment(- bundledVersion: "0.2.0",- app: try stubBundle(insert: .absent, dylib: false),- versionFile: try versionFile(nil)- ) == .notInstalled- )+ #expect(try deployment(insert: .absent, dylib: false, version: nil) == .notInstalled)}@Test("A missing bundle reads as Steam missing")func steamMissing() throws {#expect(- SteamBundle.deployment(- bundledVersion: "0.2.0",- app: URL.temporaryDirectory.appending(path: "np-absent-\(UUID().uuidString).app"),- versionFile: try versionFile("0.2.0")- ) == .steamMissing+ try deployment(insert: .absent, dylib: false, version: "0.2.0", steam: false) == .steamMissing)}}