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

Simplify Microsoft.Testing.Platform banner #2686

Merged
merged 2 commits into from
Apr 10, 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
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public virtual async Task DisplayBannerAsync()
_bannerDisplayed = true;

StringBuilder stringBuilder = new();
stringBuilder.AppendLine($"Microsoft(R) Testing Platform Execution Command Line Tool");
stringBuilder.Append(".NET Testing Platform");
if (_runtimeFeature.IsDynamicCodeSupported)
{
var version = (AssemblyInformationalVersionAttribute?)Assembly.GetExecutingAssembly().GetCustomAttribute(typeof(AssemblyInformationalVersionAttribute));
Expand All @@ -152,11 +152,11 @@ public virtual async Task DisplayBannerAsync()
int index = informationalVersion.LastIndexOfAny(PlusSign);
if (index != -1)
{
stringBuilder.Append(CultureInfo.InvariantCulture, $"Version: {informationalVersion[..(index + 10)]}");
stringBuilder.Append(CultureInfo.InvariantCulture, $" v{informationalVersion[..(index + 10)]}");
}
else
{
stringBuilder.Append(CultureInfo.InvariantCulture, $"Version: {informationalVersion}");
stringBuilder.Append(CultureInfo.InvariantCulture, $" v{informationalVersion}");
}

var buildTime = Assembly.GetExecutingAssembly()
Expand All @@ -168,17 +168,17 @@ public virtual async Task DisplayBannerAsync()
{
stringBuilder.Append(CultureInfo.InvariantCulture, $" (UTC {buildTime.Value})");
}

stringBuilder.AppendLine();
}

stringBuilder.Append(" [");
#if !NETCOREAPP
stringBuilder.AppendLine($"RuntimeInformation: {RuntimeInformation.FrameworkDescription} ({RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant()})");
stringBuilder.Append(RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant());
#else
stringBuilder.AppendLine(CultureInfo.InvariantCulture, $"RuntimeInformation: {RuntimeInformation.RuntimeIdentifier} - {RuntimeInformation.FrameworkDescription}");
stringBuilder.Append(RuntimeInformation.RuntimeIdentifier);
#endif
stringBuilder.Append(CultureInfo.InvariantCulture, $" - {RuntimeInformation.FrameworkDescription}]");
}

stringBuilder.Append("Copyright(c) Microsoft Corporation.  All rights reserved.");
_console.WriteLine(stringBuilder.ToString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ public async Task Help_WhenNoExtensionRegistered_OutputDefaultHelpContent(string
testHostResult.AssertExitCodeIs(ExitCodes.Success);

const string RegexMatchPattern = $"""
Microsoft\(R\) Testing Platform Execution Command Line Tool
Version: .+
RuntimeInformation: .+
Copyright\(c\) Microsoft Corporation\.  All rights reserved\.
.NET Testing Platform v.+ \[.+\]
Usage {TestAssetFixture.NoExtensionAssetName}.* \[option providers\] \[extension option providers\]
Execute a .NET Test Application\.
Options:
Expand Down Expand Up @@ -95,10 +92,7 @@ public async Task Help_WhenMSTestExtensionRegistered_OutputHelpContentOfRegister
testHostResult.AssertExitCodeIs(ExitCodes.Success);

const string RegexMatchPattern = $"""
Microsoft\(R\) Testing Platform Execution Command Line Tool
Version: .+
RuntimeInformation: .+
Copyright\(c\) Microsoft Corporation\.  All rights reserved\.
.NET Testing Platform v.+ \[.+\]
Usage {TestAssetFixture.MSTestAssetName}.* \[option providers\] \[extension option providers\]
Execute a .NET Test Application\.
Options:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ public async Task Info_WhenNoExtensionRegistered_OutputDefaultInfoContent(string
testHostResult.AssertExitCodeIs(ExitCodes.Success);

string regexMatchPattern = $"""
Microsoft\(R\) Testing Platform Execution Command Line Tool
Version: .+
RuntimeInformation: .+
Copyright\(c\) Microsoft Corporation\.  All rights reserved\.
.NET Testing Platform v.+ \[.+\]
Microsoft Testing Platform:
Version: .+
Dynamic Code Supported: True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ public class NoBannerTests : AcceptanceTestBase
{
private const string AssetName = "NoBannerTest";
private readonly TestAssetFixture _testAssetFixture;
private readonly string _bannerRegexMatchPattern = """
\s*Microsoft\(R\) Testing Platform Execution Command Line Tool.*
\s*Version:.*
\s*RuntimeInformation:.*
\s*Copyright\(c\) Microsoft Corporation[.]  All rights reserved[.].*
""";
private readonly string _bannerRegexMatchPattern = @".NET Testing Platform v.+ \[.+\]";

public NoBannerTests(ITestExecutionContext testExecutionContext, TestAssetFixture testAssetFixture)
: base(testExecutionContext)
Expand Down
Loading