Restructure test code a bit

This commit is contained in:
Caelan Sayler
2023-12-30 15:39:45 +00:00
parent a69bdd5e88
commit 66b214252e
11 changed files with 142 additions and 57 deletions

View File

@@ -2,12 +2,32 @@
public static class PathHelper
{
public static string GetFixturesDir()
public static string GetFixturesDir()
=> Path.Combine(GetTestRoot(), "fixtures");
public static string GetFixture(params string[] names)
public static string GetProjectDir()
=> Path.Combine(GetTestRoot(), "..");
public static string GetVendorLibDir()
=> Path.Combine(GetProjectDir(), "vendor");
public static string GetFixture(params string[] names)
=> Path.Combine(new string[] { GetTestRoot(), "fixtures" }.Concat(names).ToArray());
public static string GetRustSrcDir()
=> Path.Combine(GetProjectDir(), "src", "Rust");
#if DEBUG
public static string GetRustBuildOutputDir()
=> Path.Combine(GetRustSrcDir(), "target", "debug");
#else
public static string GetRustBuildOutputDir()
=> Path.Combine(GetRustSrcDir(), "target", "release");
#endif
public static string GetRustAsset(params string[] names)
=> Path.Combine(new string[] { GetRustBuildOutputDir() }.Concat(names).ToArray());
public static string GetTestRoot()
{
// XXX: This is an evil hack, but it's okay for a unit test

View File

@@ -4,7 +4,7 @@ using Squirrel.Packaging;
using Xunit.Abstractions;
using Xunit.Sdk;
[assembly: Xunit.TestFramework("Squirrel.Packaging.Tests.TestsInit", "Squirrel.Packaging.Tests")]
[assembly: TestFramework("Squirrel.Packaging.Tests.TestsInit", "Squirrel.Packaging.Tests")]
namespace Squirrel.Packaging.Tests
{
@@ -13,14 +13,8 @@ namespace Squirrel.Packaging.Tests
public TestsInit(IMessageSink messageSink)
: base(messageSink)
{
var baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location.Replace("file:///", ""));
var projectdir = Path.Combine(baseDir, "..", "..", "..", "..", "..");
#if DEBUG
HelperFile.AddSearchPath(Path.Combine(projectdir, "src\\Rust\\target\\debug"));
#else
HelperFile.AddSearchPath(Path.Combine(projectdir, "src\\Rust\\target\\release"));
#endif
HelperFile.AddSearchPath(Path.Combine(projectdir, "vendor"));
HelperFile.AddSearchPath(PathHelper.GetRustBuildOutputDir());
HelperFile.AddSearchPath(PathHelper.GetVendorLibDir());
}
}
}

View File

@@ -190,7 +190,8 @@ namespace Squirrel.Tests
var basePkgPath = Path.Combine(packagesDir, basePkg.OriginalFilename);
File.Copy(basePkgFixturePath, basePkgPath);
var locator = new TestSquirrelLocator(id, fromVersion, packagesDir, logger);
var locator = new TestSquirrelLocator(id, fromVersion,
packagesDir, null, null, PathHelper.GetRustAsset("update.exe"), logger);
var um = new UpdateManager(source, logger, locator);
var info = await um.CheckForUpdatesAsync();