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

Create tests that roundtrip output through a conpty to a Terminal #4213

Merged
8 commits merged into from
Jan 17, 2020

Conversation

zadjii-msft
Copy link
Member

Summary of the Pull Request

This PR adds two tests:

  • First, I started by writing a test where I could write output to the console host and inspect what output came out of conpty. This is the ConptyOutputTests in the host unit tests.
  • Then I got crazy and thought "what if I could take that output and dump it straight into the Terminal"? Hence, the ConptyRoundtripTests were born, into the TerminalCore unit tests.

References

Done in pursuit of #4200, but I felt this warranted it's own atomic PR

PR Checklist

  • Doesn't close anything on it's own.
  • I work here
  • you better believe this adds tests
  • [n/a] Requires documentation to be updated

Detailed Description of the Pull Request / Additional comments

From the comment in ConptyRoundtripTests:

This test class creates an in-proc conpty host as well as a Terminal, to
validate that strings written to the conpty create the same resopnse on the
terminal end. Tests can be written that validate both the contents of the
host buffer as well as the terminal buffer. Everytime that
renderer.PaintFrame() is called, the tests will validate the expected
output, and then flush the output of the VtEngine straight to th

Also, some other bits had to be updated:

  • The renderer needed to be able to survive without a thread, so I hadded a simple check that it actually had a thread before calling pThread->NotifyPaint
  • Bits in CommonState used NTSTATUS_FROM_HRESULT which did not work outside the host project. Since the NTSTATUS didn't seem that important, I replaced that with a HRESULT
  • CommonState likes to initialize the console to some weird defaults. I added an optional param to let us just use the defaults.

@zadjii-msft zadjii-msft added Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Product-Conpty For console issues specifically related to conpty Product-Terminal The new Windows Terminal. labels Jan 14, 2020
Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing there's no way to reuse the same tests without duplicate code?

src/host/ut_host/ConptyOutputTests.cpp Outdated Show resolved Hide resolved
src/host/ut_host/ConptyOutputTests.cpp Outdated Show resolved Hide resolved
zadjii-msft added a commit that referenced this pull request Jan 14, 2020
@zadjii-msft
Copy link
Member Author

I'm guessing there's no way to reuse the same tests without duplicate code?

At this point maybe but I kinda expect these tests to drift more over time, where re-using the code would make letting the tests drift apart and specialize harder.

I guess I could just not have the ConptyOutputTests at all, and just use the roundtrip ones, though I think I wanted to really focus on the raw output in the ConptyOutputTests, and focus on the results in ConptyRoundtripTests

Co-Authored-By: Carlos Zamora <carlos.zamora@microsoft.com>
Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Glad to have these coming online. Just a few minor comments.

Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, thanks. I'll try to fix the build issue given it's probably merge related and a bit late for you today.

@miniksa miniksa added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jan 17, 2020
@ghost
Copy link

ghost commented Jan 17, 2020

Hello @miniksa!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

// STEP 2: Set up the Conpty

// Set up some sane defaults
auto& g = ServiceLocator::LocateGlobals();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh i am very deeply concerned that the TerminalCore tests have a dependency on CONSOLE_INFORMATION 😦

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean if it's going to straddle looking at conpty and terminal... it sort of has to. The alternative is breaking it into YET ANOTHER library.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea it's kinda the whole point of this particular test. Yes I could move this to it's own project, but is that worth it?

@miniksa miniksa removed the AutoMerge Marked for automatic merge by the bot when requirements are met label Jan 17, 2020
@miniksa
Copy link
Member

miniksa commented Jan 17, 2020

Ugh it's still toast somehow. Unmarking automerge. Now I have to go for the day so @zadjii-msft will probably see this in the morning before me.

@zadjii-msft zadjii-msft added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jan 17, 2020
@zadjii-msft
Copy link
Member Author

tests got stuck 😢 /azp run

@zadjii-msft
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ghost ghost merged commit 62765f1 into master Jan 17, 2020
@ghost ghost deleted the dev/migrie/f/i-love-these-tests branch January 17, 2020 16:40
mkitzan added a commit to mkitzan/terminal that referenced this pull request Jan 18, 2020
ghost pushed a commit that referenced this pull request Jan 22, 2020
## Summary of the Pull Request

In #4213 I added a dependency to the `UnitTests_TerminalCore` project on basically all of conhost. This _worked on my machine_, but it's consistently not working on other machines. This should fix those issues.

## References

## PR Checklist
* [x] Closes #4285 
* [x] I work here
* [n/a] Tests added/passed
* [n/a] Requires documentation to be updated

## Validation Steps Performed
Made a fresh clone and built it.
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. AutoMerge Marked for automatic merge by the bot when requirements are met Product-Conpty For console issues specifically related to conpty Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants