Browse Source

Locate tests directory in code.

Rather than using a hard-coded path.
Steven Kirk 7 years ago
parent
commit
6133837600
1 changed files with 14 additions and 1 deletions
  1. 14 1
      tests/Avalonia.RenderTests/TestBase.cs

+ 14 - 1
tests/Avalonia.RenderTests/TestBase.cs

@@ -46,7 +46,8 @@ namespace Avalonia.Direct2D1.RenderTests
 
         public TestBase(string outputPath)
         {
-            var testFiles = Path.GetFullPath(@"..\..\..\..\TestFiles\");
+            var testPath = GetTestsDirectory();
+            var testFiles = Path.Combine(testPath, "TestFiles");
 #if AVALONIA_SKIA
             var platform = "Skia";
 #else
@@ -142,6 +143,18 @@ namespace Avalonia.Direct2D1.RenderTests
             }
         }
 
+        private string GetTestsDirectory()
+        {
+            var path = Directory.GetCurrentDirectory();
+
+            while (path.Length > 0 && Path.GetFileName(path) != "tests")
+            {
+                path = Path.GetDirectoryName(path);
+            }
+
+            return path;
+        }
+
         private class TestThreadingInterface : IPlatformThreadingInterface
         {
             public bool CurrentThreadIsLoopThread => MainThread.ManagedThreadId == Thread.CurrentThread.ManagedThreadId;