From 5dcf68d971fbf45545421c99bfaf4b03d274fac2 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 25 Jun 2022 18:36:07 +0200 Subject: [PATCH] Enable publishing tests for ComputeSharp project --- .../NativeLibrariesResolverTests.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/ComputeSharp.Tests.NativeLibrariesResolver/NativeLibrariesResolverTests.cs diff --git a/tests/ComputeSharp.Tests.NativeLibrariesResolver/NativeLibrariesResolverTests.cs b/tests/ComputeSharp.Tests.NativeLibrariesResolver/NativeLibrariesResolverTests.cs new file mode 100644 index 00000000..6e8afe8c --- /dev/null +++ b/tests/ComputeSharp.Tests.NativeLibrariesResolver/NativeLibrariesResolverTests.cs @@ -0,0 +1,35 @@ +using System.Diagnostics; +using System.IO; +using ComputeSharp.Tests.NativeLibrariesResolver.Helpers; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace ComputeSharp.Tests.NativeLibrariesResolver; + +[TestClass] +public class NativeLibrariesResolverTests : NativeLibrariesResolverTestsBase +{ + /// + protected override string SampleProjectName => "ComputeSharp.NuGet"; + + /// + /// Performs static initialization for the assembly before any unit tests are run. + /// + /// The for the test runner instance in use. + [ClassInitialize] + public static void InitializeDynamicDependencies(TestContext _) + { + string path = Path.GetDirectoryName(typeof(DynamicNativeLibrariesResolverTests).Assembly.Location)!; + + while (Path.GetFileName(path) is not "ComputeSharp") + { + path = Path.GetDirectoryName(path)!; + } + + string corePackagingProjectPath = Path.Combine(path, "src", "ComputeSharp.Core", "ComputeSharp.Core.msbuildproj"); + string packagingProjectPath = Path.Combine(path, "src", "ComputeSharp.Package", "ComputeSharp.Package.msbuildproj"); + + // Run dotnet pack and on the packaging projects, to ensure the local NuGet packages are available + Process.Start("dotnet", $"pack {corePackagingProjectPath} -c Release").WaitForExit(); + Process.Start("dotnet", $"pack {packagingProjectPath} -c Release").WaitForExit(); + } +}