Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabii committed Mar 20, 2024
1 parent ab71202 commit 6cef374
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/IKVM.Clang.Sdk.Tests/ProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using FluentAssertions;

using Microsoft.Build.Framework;
using Microsoft.Build.Tasks;
using Microsoft.Build.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

Expand Down Expand Up @@ -115,7 +116,7 @@ public static void ClassInitialize(TestContext context)
analyzer.SetGlobalProperty("CreateHardLinksForCopyFilesToOutputDirectoryIfPossible", "true");
analyzer.SetGlobalProperty("CreateHardLinksForCopyLocalIfPossible", "true");
analyzer.SetGlobalProperty("CreateHardLinksForPublishFilesIfPossible", "true");
analyzer.SetGlobalProperty("Configuration", "Release");
analyzer.SetGlobalProperty("Configuration", "Debug");

var options = new EnvironmentOptions();
options.WorkingDirectory = TestRoot;
Expand All @@ -131,10 +132,10 @@ public static void ClassInitialize(TestContext context)
}

[DataTestMethod]
[DataRow(EnvironmentPreference.Core, "x86_64-pc-windows-msvc")]
[DataRow(EnvironmentPreference.Core, "i686-pc-windows-msvc")]
[DataRow(EnvironmentPreference.Core, "aarch64-pc-windows-msvc")]
public void CanBuildTestProject(EnvironmentPreference env, string tid)
[DataRow(EnvironmentPreference.Core, "x86_64-pc-windows-msvc", "{0}.dll", "{0}.exe", "{0}.pdb")]
[DataRow(EnvironmentPreference.Core, "i686-pc-windows-msvc", "{0}.dll", "{0}.exe", "{0}.pdb")]
[DataRow(EnvironmentPreference.Core, "aarch64-pc-windows-msvc", "{0}.dll", "{0}.exe", "{0}.pdb")]
public void CanBuildTestProject(EnvironmentPreference env, string tid, string libName, string exeName, string symName)
{
TestContext.WriteLine("TestRoot: {0}", TestRoot);
TestContext.WriteLine("TempRoot: {0}", TempRoot);
Expand All @@ -155,6 +156,7 @@ public void CanBuildTestProject(EnvironmentPreference env, string tid)
analyzer.SetGlobalProperty("CreateHardLinksForPublishFilesIfPossible", "true");
analyzer.SetGlobalProperty("SkipCopyBuildProduct", "false");
analyzer.SetGlobalProperty("CopyBuildOutputToOutputDirectory", "true");
analyzer.SetGlobalProperty("Configuration", "Debug");

var options = new EnvironmentOptions();
options.WorkingDirectory = TestRoot;
Expand All @@ -170,6 +172,17 @@ public void CanBuildTestProject(EnvironmentPreference env, string tid)
TestContext.AddResultFile(Path.Combine(WorkRoot, $"{tid}-msbuild.binlog"));
result.OverallSuccess.Should().BeTrue();

var binDir = Path.Combine(TestRoot, "Executable", "dist", "Debug", tid, "bin");
File.Exists(Path.Combine(binDir, string.Format(exeName, "Executable"))).Should().BeTrue();
File.Exists(Path.Combine(binDir, string.Format(symName, "Executable"))).Should().BeTrue();

var libDir1 = Path.Combine(TestRoot, "SharedLibrary1", "dist", "Debug", tid, "lib");
File.Exists(Path.Combine(libDir1, string.Format(libName, "SharedLibrary1"))).Should().BeTrue();
File.Exists(Path.Combine(libDir1, string.Format(symName, "SharedLibrary1"))).Should().BeTrue();

var libDir2 = Path.Combine(TestRoot, "SharedLibrary2", "dist", "Debug", tid, "lib");
File.Exists(Path.Combine(libDir2, string.Format(libName, "SharedLibrary2"))).Should().BeTrue();
File.Exists(Path.Combine(libDir2, string.Format(symName, "SharedLibrary2"))).Should().BeTrue();
}

}
Expand Down

0 comments on commit 6cef374

Please sign in to comment.