Skip to content

Microsoft Testing Platform does not handle large BufferWidth in console #7240

@FlukeFan

Description

@FlukeFan

Describe the bug

When Console.BufferWidth is set to a larger value than the Console.WindowWidth, the running test timing is not displayed correctly (or at all).

If using Windows Terminal, the output is messed up. If using conhost.exe, then the timings do not appear.

Steps To Reproduce

Using TUnit:

dotnet new console
dotnet add package tunit

Add the following test fixture:

using System.Runtime.InteropServices;

public class Fixture
{
    [Test]
    public async Task Test1()
    {
        await Task.Delay(TimeSpan.FromSeconds(2));

        if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            Console.BufferWidth = 4096;

        await Task.Delay(TimeSpan.FromSeconds(2));
    }

    [Test]
    public Task Test2() => Task.Delay(TimeSpan.FromSeconds(3));
}

Expected behavior

I expect to be able to see the timings as intended while the tests are running (i.e., updated every few seconds, but then removed after the final test run completes).

Actual behavior

If using Windows Terminal, the output is skewed:

testfx_wt.mp4

If using conhost.exe, the timing is not visible.

Additional context

Testing platform is using ANSI codes to position the cursor at the right-hand side of the screen. However, the calculations are done using Console.BufferWidth ... should they perhaps be using Console.WindowWidth to position the output of the test timing?

Or perhaps the timings should be moved to the beginning of the updating output so there's no reliance on the screen/buffer width calculations?

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions