Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
import XCTest
@testable import NXCore
/// The .NET row looks for dotnet in the build's order and is ready with the first that lists an SDK 10, the one the build puts in front.
final class DotnetDetectionTests: XCTestCase {
func testTheBuildsOrder() {
// build_ipa_from_nsp.py's TOOL_PATHS: Homebrew, /usr/local/bin, the installer's folder, then ~/.dotnet
XCTAssertEqual(Toolchain.dotnetCandidates(home: "/Users/p"),
["/opt/homebrew/bin/dotnet", "/usr/local/bin/dotnet", "/usr/local/share/dotnet/dotnet", "/Users/p/.dotnet/dotnet"])
}
func testOnlyAnSDK10Counts() {
XCTAssertFalse(Toolchain.hasSDK10("7.0.402 [/usr/local/share/dotnet/sdk]\n")) // an Intel .NET 7 in front of ~/.dotnet
XCTAssertFalse(Toolchain.hasSDK10(""))
XCTAssertFalse(Toolchain.hasSDK10("8.0.318 [/x/sdk]\n9.0.100 [/x/sdk]"))
XCTAssertTrue(Toolchain.hasSDK10("7.0.402 [/a/sdk]\n10.0.403 [/b/sdk]\n"))
XCTAssertTrue(Toolchain.hasSDK10("11.0.100-preview.1 [/b/sdk]"))
}
func testTheFirstWithAnSDK10() {
let old = "/share/dotnet", home = "/home/.dotnet/dotnet", broken = "/broken/dotnet", absent = "/none/dotnet"
let sdks = [old: "7.0.402 [/s/sdk]\n", home: "9.0.100 [/h/sdk]\n10.0.403 [/h/sdk]\n", broken: "10.0.403 [/b/sdk]\n"]
let runner = FakeProcessRunner()
runner.answer = { l in
l.executable == broken ? ProcessResult(status: 1, out: sdks[broken]!) : ProcessResult(out: sdks[l.executable] ?? "")
}
func pick(_ cands: [String]) -> String {
let r = Toolchain.findDotnet(cands, runner: runner, exists: { $0 != absent })
return (r.ok ? "ready " : "missing ") + r.path
}
// an Intel .NET 7 in /usr/local/share/dotnet before the .NET 10 in ~/.dotnet: the build puts the second in front
XCTAssertEqual(pick([absent, old, home]), "ready " + home)
XCTAssertEqual(pick([home, old]), "ready " + home)
XCTAssertEqual(pick([broken, home]), "ready " + home)
// no SDK 10 anywhere: Install, as with no dotnet at all
XCTAssertEqual(pick([absent, old]), "missing " + old)
XCTAssertEqual(pick([absent]), "missing dotnet")
}
func testTheRootIsTheFolderOfTheCandidate() {
let runner = FakeProcessRunner()
runner.answer = { _ in ProcessResult(out: "10.0.100 [/h/sdk]\n") }
XCTAssertTrue(Toolchain.dotnetHasSDK10("/home/.dotnet/dotnet", runner: runner))
XCTAssertEqual(runner.launches.first?.environment?["DOTNET_ROOT"], "/home/.dotnet")
}
}