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

Fix help #46206

Closed

Fix help #46206

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 @@ -47,6 +47,7 @@ internal event EventHandler OnProgressStopUpdate

private readonly uint? _originalConsoleMode;
private bool _isDiscovery;
private bool _isHelp;
private DateTimeOffset? _testExecutionStartTime;

private DateTimeOffset? _testExecutionEndTime;
Expand Down Expand Up @@ -147,9 +148,10 @@ public TerminalTestReporter(IConsole console, TerminalTestReporterOptions option
_terminalWithProgress = terminalWithProgress;
}

public void TestExecutionStarted(DateTimeOffset testStartTime, int workerCount, bool isDiscovery)
public void TestExecutionStarted(DateTimeOffset testStartTime, int workerCount, bool isDiscovery, bool isHelp)
{
_isDiscovery = isDiscovery;
_isHelp = isHelp;
_testExecutionStartTime = testStartTime;
_terminalWithProgress.StartShowingProgress(workerCount);
}
Expand Down Expand Up @@ -189,7 +191,10 @@ public void TestExecutionCompleted(DateTimeOffset endTime)
_testExecutionEndTime = endTime;
_terminalWithProgress.StopShowingProgress();

_terminalWithProgress.WriteToTerminal(_isDiscovery ? AppendTestDiscoverySummary : AppendTestRunSummary);
if (!_isHelp)
{
_terminalWithProgress.WriteToTerminal(_isDiscovery ? AppendTestDiscoverySummary : AppendTestRunSummary);
}

NativeMethods.RestoreConsoleMode(_originalConsoleMode);
_assemblies.Clear();
Expand Down Expand Up @@ -757,7 +762,7 @@ internal void AssemblyRunCompleted(string assembly, string? targetFramework, str

_terminalWithProgress.RemoveWorker(assemblyRun.SlotIndex);

if (!_isDiscovery && _options.ShowAssembly && _options.ShowAssemblyStartAndComplete)
if (!_isHelp && !_isDiscovery && _options.ShowAssembly && _options.ShowAssemblyStartAndComplete)
{
_terminalWithProgress.WriteToTerminal(terminal => AppendAssemblySummary(assemblyRun, terminal));
}
Expand Down
14 changes: 4 additions & 10 deletions src/Cli/dotnet/commands/dotnet-test/TestingPlatformCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public int Run(ParseResult parseResult)
_args = [.. parseResult.UnmatchedTokens];
_isHelp = ContainsHelpOption(parseResult.GetArguments());

InitializeOutput(degreeOfParallelism);
InitializeOutput(degreeOfParallelism, _isHelp);

bool filterModeEnabled = parseResult.HasOption(TestingPlatformOptions.TestModulesFilterOption);
if (_isHelp)
Expand Down Expand Up @@ -100,7 +100,7 @@ private void SetupCancelKeyPressHandler()
};
}

private void InitializeOutput(int degreeOfParallelism)
private void InitializeOutput(int degreeOfParallelism, bool isHelp)
{
var console = new SystemConsole();
_output = new TerminalTestReporter(console, new TerminalTestReporterOptions()
Expand All @@ -112,10 +112,7 @@ private void InitializeOutput(int degreeOfParallelism)
ShowAssemblyStartAndComplete = true,
});

if (!_isHelp)
{
_output.TestExecutionStarted(DateTimeOffset.Now, degreeOfParallelism, _isDiscovery);
}
_output.TestExecutionStarted(DateTimeOffset.Now, degreeOfParallelism, _isDiscovery, _isHelp);
}

private void InitializeHelpActionQueue(int degreeOfParallelism, BuildConfigurationOptions buildConfigurationOptions, bool filterModeEnabled)
Expand Down Expand Up @@ -174,10 +171,7 @@ private void CompleteRun()
{
if (Interlocked.CompareExchange(ref _cancelled, 1, 0) == 0)
{
if (!_isHelp)
{
_output?.TestExecutionCompleted(DateTimeOffset.Now);
}
_output?.TestExecutionCompleted(DateTimeOffset.Now);
}
}

Expand Down