|
11 | 11 | using System.Text;
|
12 | 12 | using System.Text.RegularExpressions;
|
13 | 13 | using Xunit;
|
| 14 | +using Xunit.Abstractions; |
14 | 15 |
|
15 | 16 | namespace AssembliesValid
|
16 | 17 | {
|
@@ -40,30 +41,37 @@ public class AssembliesValid
|
40 | 41 | new Regex("/packs/"),
|
41 | 42 | };
|
42 | 43 |
|
| 44 | + private readonly ITestOutputHelper output; |
| 45 | + |
| 46 | + public AssembliesValid(ITestOutputHelper output) |
| 47 | + { |
| 48 | + this.output = output; |
| 49 | + } |
| 50 | + |
43 | 51 | [Fact]
|
44 | 52 | public void ValidateAssemblies()
|
45 | 53 | {
|
46 | 54 | string dotnetPath = null;
|
47 | 55 | int exitCode = RunProcessAndGetOutput(new string[] { "bash", "-c", "command -v dotnet" }, out dotnetPath);
|
48 | 56 | if (exitCode != 0)
|
49 | 57 | {
|
50 |
| - Console.Error.WriteLine("'dotnet' command not found"); |
51 |
| - Console.Error.WriteLine("PATH: " + Environment.GetEnvironmentVariable("PATH")); |
| 58 | + output.WriteLine("'dotnet' command not found"); |
| 59 | + output.WriteLine("PATH: " + Environment.GetEnvironmentVariable("PATH")); |
52 | 60 | Assert.True(false);
|
53 | 61 | }
|
54 | 62 | dotnetPath = dotnetPath.Trim();
|
55 | 63 | exitCode = RunProcessAndGetOutput(new string[] { "readlink", "-f", dotnetPath }, out dotnetPath);
|
56 | 64 | if (exitCode != 0)
|
57 | 65 | {
|
58 |
| - Console.Error.WriteLine($"Unable to run readlink -f {dotnetPath}"); |
| 66 | + output.WriteLine($"Unable to run readlink -f {dotnetPath}"); |
59 | 67 | Assert.True(false);
|
60 | 68 | }
|
61 | 69 | dotnetPath = dotnetPath.Trim();
|
62 | 70 |
|
63 | 71 | string searchRoot = new FileInfo(dotnetPath).DirectoryName;
|
64 | 72 | var searchRootDirectory = new System.IO.DirectoryInfo(searchRoot);
|
65 | 73 |
|
66 |
| - Console.WriteLine($"Searching for dotnet binaries in {searchRoot}"); |
| 74 | + output.WriteLine($"Searching for dotnet binaries in {searchRoot}"); |
67 | 75 |
|
68 | 76 | var architecture = RuntimeInformation.OSArchitecture;
|
69 | 77 | var machine = GetCurrentMachine(architecture);
|
@@ -106,11 +114,11 @@ public void ValidateAssemblies()
|
106 | 114 |
|
107 | 115 | if (valid)
|
108 | 116 | {
|
109 |
| - Console.WriteLine($"{assembly}: OK"); |
| 117 | + output.WriteLine($"{assembly}: OK"); |
110 | 118 | }
|
111 | 119 | else
|
112 | 120 | {
|
113 |
| - Console.WriteLine($"error: {assembly} hasMethods: {hasMethods}, hasAot: {hasAot}, inReleaseMode: {inReleaseMode}"); |
| 121 | + output.WriteLine($"error: {assembly} hasMethods: {hasMethods}, hasAot: {hasAot}, inReleaseMode: {inReleaseMode}"); |
114 | 122 | allOkay = false;
|
115 | 123 | }
|
116 | 124 | }
|
|
0 commit comments