Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bording committed Nov 9, 2021
1 parent 3e78e83 commit 9a9a297
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions LibGit2Sharp.Tests/GlobalSettingsFixture.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using LibGit2Sharp.Core;
using LibGit2Sharp.Tests.TestHelpers;
Expand Down Expand Up @@ -64,12 +65,13 @@ public void LoadFromSpecifiedPath(string architecture)
var testDir = Path.GetDirectoryName(typeof(GlobalSettingsFixture).Assembly.Location);
var testAppExe = Path.Combine(testDir, $"NativeLibraryLoadTestApp.{architecture}.exe");
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
var platformDir = Path.Combine(tempDir, "plat");
var platformDir = Path.Combine(tempDir, "plat", architecture);
var libraryPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lib", "win32", architecture);

try
{
Directory.CreateDirectory(Path.Combine(platformDir, architecture));
File.Copy(Path.Combine(GlobalSettings.NativeLibraryPath, architecture, nativeDllFileName), Path.Combine(platformDir, architecture, nativeDllFileName));
Directory.CreateDirectory(platformDir);
File.Copy(Path.Combine(libraryPath, nativeDllFileName), Path.Combine(platformDir, nativeDllFileName));

var (output, exitCode) = ProcessHelper.RunProcess(testAppExe, arguments: $@"{NativeDllName.Name} ""{platformDir}""", workingDirectory: tempDir);

Expand Down
4 changes: 2 additions & 2 deletions NativeLibraryLoadTestApp/TestApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class TestApp
private static extern IntPtr GetModuleHandle(string path);

[DllImport("kernel32")]
private static extern int GetModuleFileName(IntPtr handle, [Out]StringBuilder path, int size);
private static extern int GetModuleFileName(IntPtr handle, [Out] StringBuilder path, int size);

static int Main(string[] args)
{
Expand All @@ -23,7 +23,7 @@ static int Main(string[] args)

var moduleName = args[0];
var loadFromDirectory = args[1];
var expectedPath = Path.Combine(loadFromDirectory, (IntPtr.Size == 4) ? "x86" : "x64", moduleName + ".dll");
var expectedPath = Path.Combine(loadFromDirectory, moduleName + ".dll");

GlobalSettings.NativeLibraryPath = loadFromDirectory;
var isValid = Repository.IsValid(Path.GetTempPath());
Expand Down

0 comments on commit 9a9a297

Please sign in to comment.