Skip to content

Add regression test for ANSI escape bug #1617

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

Closed
andyleejordan opened this issue Nov 3, 2021 · 2 comments
Closed

Add regression test for ANSI escape bug #1617

andyleejordan opened this issue Nov 3, 2021 · 2 comments
Assignees
Labels
Area-Test Issue-Enhancement A feature request (enhancement).

Comments

@andyleejordan
Copy link
Member

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)

@ghost ghost added the Needs: Triage Maintainer attention needed! label Nov 3, 2021
@SeeminglyScience
Copy link
Collaborator

The missing piece is a test PSHost that inherits EditorServicesConsolePSHost and overwrites WriteLine to something that just adds to a StringBuilder.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Nov 5, 2021
@andyleejordan
Copy link
Member Author

Ah! _psesHost has a host that is EditorServicesConsolePSHost. I'll try to create a test harness that does what you say.

@StevenBucher98 StevenBucher98 removed Needs: Triage Maintainer attention needed! Needs: Maintainer Attention Maintainer attention needed! labels Nov 16, 2021
@andyleejordan andyleejordan moved this to Todo in Sea Biscuit Jan 20, 2022
@andyleejordan andyleejordan added the Needs: Triage Maintainer attention needed! label Feb 3, 2022
@StevenBucher98 StevenBucher98 removed the Needs: Triage Maintainer attention needed! label Feb 9, 2022
@SydneyhSmith SydneyhSmith moved this from Todo to P0 - Todo in American Pharoah May 3, 2022
@andyleejordan andyleejordan self-assigned this Aug 3, 2022
@andyleejordan andyleejordan added the Issue-Enhancement A feature request (enhancement). label Aug 3, 2022
Repository owner moved this from Todo to Done in American Pharoah Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Test Issue-Enhancement A feature request (enhancement).
Projects
No open projects
Status: Done
Development

No branches or pull requests

3 participants