Skip to content
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 @@ -74,13 +74,6 @@ internal int CollectLinux(CollectLinuxArgs args)
return (int)ReturnCode.PlatformNotSupportedError;
}

Console.WriteLine("==========================================================================================");
Console.WriteLine("The collect-linux verb is a new preview feature and relies on an updated version of the");
Console.WriteLine(".nettrace file format. The latest PerfView release supports these trace files but other");
Console.WriteLine("ways of using the trace file may not work yet. For more details, see the docs at");
Console.WriteLine("https://learn.microsoft.com/dotnet/core/diagnostics/dotnet-trace.");
Console.WriteLine("==========================================================================================");

int ret = (int)ReturnCode.TracingError;
string scriptPath = null;
try
Expand Down
27 changes: 6 additions & 21 deletions src/tests/dotnet-trace/CollectLinuxCommandFunctionalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void CollectLinuxCommand_Probe_ListsProcesses_WhenNoArgs()
int exitCode = Run(args, console);

Assert.Equal((int)ReturnCode.Ok, exitCode);
string[] expected = ExpectPreviewWithMessages(
string[] expected = ExpectMessages(
new[] {
"Probing .NET processes for support of the EventPipe UserEvents IPC command used by collect-linux. Requires runtime '10.0.0' or later.",
".NET processes that support the command:",
Expand All @@ -139,7 +139,7 @@ public void CollectLinuxCommand_Probe_CsvToConsole()
int exitCode = Run(args, console);

Assert.Equal((int)ReturnCode.Ok, exitCode);
string[] expected = ExpectPreviewWithMessages(
string[] expected = ExpectMessages(
new[] {
"pid,processName,supportsCollectLinux",
""
Expand All @@ -157,7 +157,7 @@ public void CollectLinuxCommand_Probe_Csv()
int exitCode = Run(args, console);

Assert.Equal((int)ReturnCode.Ok, exitCode);
string[] expected = ExpectPreviewWithMessages(
string[] expected = ExpectMessages(
new[] {
"Successfully wrote EventPipe UserEvents IPC command support results to '" + tempFilePath + "'.",
}
Expand Down Expand Up @@ -235,7 +235,7 @@ public void CollectLinuxCommand_Probe_ReportsConnectionFailed_NonDotNetProcess()
int exitCode = Run(args, console);

Assert.Equal((int)ReturnCode.Ok, exitCode);
string[] expected = ExpectPreviewWithMessages(
string[] expected = ExpectMessages(
new[] {
$"Could not probe process '{pid1Name} (1)'. The process may have exited, or it doesn't have an accessible .NET diagnostic port.",
}
Expand Down Expand Up @@ -582,10 +582,7 @@ private static string FormatProvider(string name, string keywordsHex, string lev
}
private static string[] FormatException(string message)
{
List<string> result = new();
result.AddRange(PreviewMessages);
result.Add($"[ERROR] {message}");
return result.ToArray();
return [$"[ERROR] {message}"];
}
private static string DefaultOutputFile => $"Output File : {Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar}trace.nettrace";
private static readonly string[] CommonTail = [
Expand All @@ -594,19 +591,9 @@ private static string[] FormatException(string message)
"[dd:hh:mm:ss]\tRecording trace.",
"Press <Enter> or <Ctrl+C> to exit...",
];
private static string[] PreviewMessages = [
"==========================================================================================",
"The collect-linux verb is a new preview feature and relies on an updated version of the",
".nettrace file format. The latest PerfView release supports these trace files but other",
"ways of using the trace file may not work yet. For more details, see the docs at",
"https://learn.microsoft.com/dotnet/core/diagnostics/dotnet-trace.",
"=========================================================================================="
];

private static string[] ExpectPreviewWithMessages(string[] messages)
private static string[] ExpectMessages(string[] messages)
{
List<string> result = new();
result.AddRange(PreviewMessages);
if (messages.Length > 0)
{
result.AddRange(messages);
Expand All @@ -621,8 +608,6 @@ private static string[] ExpectProvidersAndPerfEventsWithMessages(string[] messag
{
List<string> result = new();

result.AddRange(PreviewMessages);

if (messages.Length > 0)
{
result.AddRange(messages);
Expand Down
Loading