Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete TestProjectFixture and associated helpers #99847

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/installer/tests/HostActivation.Tests/NativeUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
using Microsoft.DotNet.CoreSetup.Test;
using Microsoft.DotNet.Cli.Build.Framework;

namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.NativeUnitTests
namespace HostActivation.Tests
{
public class NativeUnitTests
{
[Fact]
public void Native_Test_Fx_Ver()
{
RepoDirectoriesProvider repoDirectoriesProvider = new RepoDirectoriesProvider();

string testPath = Path.Combine(repoDirectoriesProvider.HostTestArtifacts, Binaries.GetExeFileNameForCurrentPlatform("test_fx_ver"));
string testPath = Path.Combine(RepoDirectoriesProvider.Default.HostTestArtifacts, Binaries.GetExeFileNameForCurrentPlatform("test_fx_ver"));

Command testCommand = Command.Create(testPath);
testCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public RegisteredInstallLocationOverride(string productBinaryPath)
// On Linux/macOS the install location is registered in a file which is normally
// located in /etc/dotnet/install_location
// So we need to redirect it to a different place here.
string directory = Path.Combine(TestArtifact.TestArtifactsPath, "installLocationOverride" + Process.GetCurrentProcess().Id.ToString());
string directory = Path.Combine(TestContext.TestArtifactsPath, "installLocationOverride" + Process.GetCurrentProcess().Id.ToString());
if (Directory.Exists(directory))
Directory.Delete(directory, true);
Directory.CreateDirectory(directory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.DotNet.CoreSetup.Packaging.Tests
{
public class NETCoreTests
{
private readonly RepoDirectoriesProvider dirs = new RepoDirectoriesProvider();
private readonly RepoDirectoriesProvider dirs = RepoDirectoriesProvider.Default;

[Fact]
public void NETCoreTargetingPackIsValid()
Expand Down
52 changes: 0 additions & 52 deletions src/installer/tests/TestUtils/AnsiColorExtensions.cs

This file was deleted.

145 changes: 0 additions & 145 deletions src/installer/tests/TestUtils/AnsiConsole.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,5 @@ public string GetDiagnosticsInfo()
$"StdOut:{Environment.NewLine}{Result.StdOut}{Environment.NewLine}" +
$"StdErr:{Environment.NewLine}{Result.StdErr}{Environment.NewLine}";
}

public AndConstraint<CommandResultAssertions> HaveSkippedProjectCompilation(string skippedProject, string frameworkFullName)
{
Result.StdOut.Should().Contain("Project {0} ({1}) was previously compiled. Skipping compilation.", skippedProject, frameworkFullName);

return new AndConstraint<CommandResultAssertions>(this);
}

public AndConstraint<CommandResultAssertions> HaveCompiledProject(string compiledProject, string frameworkFullName)
{
Result.StdOut.Should().Contain($"Project {0} ({1}) will be compiled", compiledProject, frameworkFullName);

return new AndConstraint<CommandResultAssertions>(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,5 @@ public static DirectoryInfoAssertions Should(this DirectoryInfo dir)
{
return new DirectoryInfoAssertions(dir);
}

public static DirectoryInfo Sub(this DirectoryInfo dir, string name)
{
return new DirectoryInfo(Path.Combine(dir.FullName, name));
}
}
}
22 changes: 0 additions & 22 deletions src/installer/tests/TestUtils/BuildFailureException.cs

This file was deleted.

38 changes: 0 additions & 38 deletions src/installer/tests/TestUtils/BuildReporter.cs

This file was deleted.

35 changes: 16 additions & 19 deletions src/installer/tests/TestUtils/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;

namespace Microsoft.DotNet.Cli.Build.Framework
Expand Down Expand Up @@ -315,33 +313,32 @@ private string FormatProcessInfo(ProcessStartInfo info, bool includeWorkingDirec
return prefix + " " + info.Arguments;
}

private static DateTime _initialTime = DateTime.Now;

private string GetFormattedTime()
{
const string TimeSpanFormat = @"hh\:mm\:ss\.fff";
return (DateTime.Now - _initialTime).ToString(TimeSpanFormat);
}

private void ReportExecBegin()
{
BuildReporter.BeginSection("EXEC", FormatProcessInfo(Process.StartInfo, includeWorkingDirectory: false));
string message = FormatProcessInfo(Process.StartInfo, includeWorkingDirectory: false);
Console.WriteLine($"[EXEC >] [....] [{GetFormattedTime()}] {message}");
}

private void ReportExecWaitOnExit()
{
BuildReporter.SectionComment("EXEC", $"Waiting for process {Process.Id} to exit...");
string message = $"Waiting for process {Process.Id} to exit...";
Console.WriteLine($"[EXEC -] [....] [{GetFormattedTime()}] {message}");
}

private void ReportExecEnd(int exitCode, bool fExpectedToFail)
{
bool success = exitCode == 0;
string msgExpectedToFail = "";

if (fExpectedToFail)
{
success = !success;
msgExpectedToFail = "failed as expected and ";
}

var message = $"{FormatProcessInfo(Process.StartInfo, includeWorkingDirectory: !success)} {msgExpectedToFail}exited with {exitCode}";

BuildReporter.EndSection(
"EXEC",
success ? message.Green() : message.Red().Bold(),
success);
bool success = fExpectedToFail ? exitCode != 0 : exitCode == 0;
var status = success ? " OK " : "FAIL";
var message = $"{FormatProcessInfo(Process.StartInfo, includeWorkingDirectory: !success)} exited with {exitCode}. Expected: {(fExpectedToFail ? "non-zero" : "0")}";
Console.WriteLine($"[EXEC <] [{status}] [{GetFormattedTime()}] {message}");
}

private void ThrowIfRunning([CallerMemberName] string memberName = null)
Expand Down
2 changes: 1 addition & 1 deletion src/installer/tests/TestUtils/CommandExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static Command EnableHostTracing(this Command command)

public static Command EnableHostTracingToFile(this Command command, out string filePath)
{
filePath = Path.Combine(TestArtifact.TestArtifactsPath, "trace" + Guid.NewGuid().ToString() + ".log");
filePath = Path.Combine(TestContext.TestArtifactsPath, "trace" + Guid.NewGuid().ToString() + ".log");
if (File.Exists(filePath))
{
File.Delete(filePath);
Expand Down
Loading