From 21b4bd680a3c6b96dd190258f198456b0a560765 Mon Sep 17 00:00:00 2001 From: Caelan Sayler Date: Wed, 27 Mar 2024 14:18:10 +0000 Subject: [PATCH] Better search for rust binaries in test runner --- test/PathHelper.cs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/test/PathHelper.cs b/test/PathHelper.cs index bbadc0ab..be1195ac 100644 --- a/test/PathHelper.cs +++ b/test/PathHelper.cs @@ -41,6 +41,8 @@ public static class PathHelper public static string CopyRustAssetTo(string assetName, string dir) { var path = GetRustAsset(assetName); + if (!File.Exists(path)) + throw new FileNotFoundException($"File not found: {path}"); var newPath = Path.Combine(dir, assetName); File.Copy(path, newPath); return newPath; @@ -49,6 +51,8 @@ public static class PathHelper public static string CopyFixtureTo(string fixtureName, string dir) { var path = GetFixture(fixtureName); + if (!File.Exists(path)) + throw new FileNotFoundException($"File not found: {path}"); var newPath = Path.Combine(dir, fixtureName); File.Copy(path, newPath); return newPath; @@ -56,9 +60,29 @@ public static class PathHelper public static string CopyUpdateTo(string dir) { - var updateName = VelopackRuntimeInfo.IsWindows ? "update.exe" : "update"; - var path = GetRustAsset(updateName); - var newPath = Path.Combine(dir, updateName); + string GetUpdatePath() + { + if (VelopackRuntimeInfo.IsWindows && File.Exists(GetRustAsset("update.exe"))) { + return GetRustAsset("update.exe"); + } + + if (VelopackRuntimeInfo.IsLinux && File.Exists(GetRustAsset("UpdateNix"))) { + return GetRustAsset("UpdateNix"); + } + + if (VelopackRuntimeInfo.IsOSX && File.Exists(GetRustAsset("UpdateMac"))) { + return GetRustAsset("UpdateMac"); + } + + if (!VelopackRuntimeInfo.IsWindows && File.Exists(GetRustAsset("update"))) { + return GetRustAsset("update"); + } + + throw new FileNotFoundException("update.exe not found"); + } + + var path = GetUpdatePath(); + var newPath = Path.Combine(dir, Path.GetFileName(path)); File.Copy(path, newPath); return newPath; }