Skip to content

Add regression test for ANSI escape bug #1617

Closed
@andyleejordan

Description

@andyleejordan

Hm, well this is as far as I got with the test and I think I'm going to postpone getting a test for this so we can just get the fix in:

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Management.Automation;
using System.Threading;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution;
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Host;
using Xunit;

namespace Microsoft.PowerShell.EditorServices.Test.Console
{
    public class PSHostTests : IDisposable
    {
        private readonly PsesInternalHost _psesHost;
        public PSHostTests()
        {
            _psesHost = PsesHostFactory.Create(NullLoggerFactory.Instance);
        }

        public void Dispose()
        {
            _psesHost.StopAsync().GetAwaiter().GetResult();
        }

        [Trait("Category", "LengthInBufferCells")]
        [Fact]
        public void HasLengthInBufferCells()
        {
            var script = @"[pscustomobject]@{ a = ""`e[30mtest`e[0m"" } | Format-Table @{ Width = 4; Expression = 'a' } | Out-Default";

            IReadOnlyList<string> results = _psesHost.InvokePSCommand<string>(
                new PSCommand().AddScript(script),
                new PowerShellExecutionOptions { WriteInputToHost = true, WriteOutputToHost = true, ThrowOnError = false, InterruptCurrentForeground = true },
                CancellationToken.None);
            Assert.NotEmpty(results);
        }
    }
}

Originally posted by @andschwa in #1606 (comment)

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions