diff options
Diffstat (limited to 'src/internal')
-rw-r--r-- | src/internal/WixBuildTools.TestSupport/TestData.cs | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/internal/WixBuildTools.TestSupport/TestData.cs b/src/internal/WixBuildTools.TestSupport/TestData.cs index 8587330d..309e9038 100644 --- a/src/internal/WixBuildTools.TestSupport/TestData.cs +++ b/src/internal/WixBuildTools.TestSupport/TestData.cs | |||
@@ -4,13 +4,42 @@ namespace WixBuildTools.TestSupport | |||
4 | { | 4 | { |
5 | using System; | 5 | using System; |
6 | using System.IO; | 6 | using System.IO; |
7 | using System.Reflection; | ||
8 | using System.Runtime.CompilerServices; | ||
7 | 9 | ||
8 | public class TestData | 10 | public class TestData |
9 | { | 11 | { |
10 | public static string Get(params string[] paths) | 12 | public static string Get(params string[] paths) |
11 | { | 13 | { |
12 | var localPath = Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetCallingAssembly().CodeBase).LocalPath); | 14 | var localPath = Path.GetDirectoryName(new Uri(Assembly.GetCallingAssembly().CodeBase).LocalPath); |
13 | return Path.Combine(localPath, Path.Combine(paths)); | 15 | return Path.Combine(localPath, Path.Combine(paths)); |
14 | } | 16 | } |
17 | |||
18 | public static string GetUnitTestLogsFolder([CallerFilePath] string path = "", [CallerMemberName] string method = "") | ||
19 | { | ||
20 | var startingPath = Path.GetDirectoryName(new Uri(Assembly.GetCallingAssembly().CodeBase).LocalPath); | ||
21 | var buildPath = startingPath; | ||
22 | |||
23 | while (!String.IsNullOrEmpty(buildPath)) | ||
24 | { | ||
25 | var folderName = Path.GetFileName(buildPath); | ||
26 | if (String.Equals("build", folderName, StringComparison.OrdinalIgnoreCase)) | ||
27 | { | ||
28 | break; | ||
29 | } | ||
30 | |||
31 | buildPath = Path.GetDirectoryName(buildPath); | ||
32 | } | ||
33 | |||
34 | if (String.IsNullOrEmpty(buildPath)) | ||
35 | { | ||
36 | throw new InvalidOperationException($"Could not find the 'build' folder in the test path: {startingPath}. Cannot get test logs folder without being able to find the build folder."); | ||
37 | } | ||
38 | |||
39 | var testLogsFolder = Path.Combine(buildPath, "logs", "UnitTests", $"{Path.GetFileNameWithoutExtension(path)}_{method}"); | ||
40 | Directory.CreateDirectory(testLogsFolder); | ||
41 | |||
42 | return testLogsFolder; | ||
43 | } | ||
15 | } | 44 | } |
16 | } | 45 | } |