[PR #4213] [MERGED] Create tests that roundtrip output through a conpty to a Terminal #25690

Open
opened 2026-01-31 09:11:09 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4213
Author: @zadjii-msft
Created: 1/14/2020
Status: Merged
Merged: 1/17/2020
Merged by: @undefined

Base: masterHead: dev/migrie/f/i-love-these-tests


📝 Commits (8)

  • 302e04a Create some tests that roundtrip content through conpt to verify in the terminal
  • bf4f610 polish for review
  • eb6992e Apply suggestions from code review
  • a8fd596 Merge remote-tracking branch 'origin/master' into dev/migrie/f/i-love-these-tests
  • 77fbfc6 These were some comments from niksa
  • 1b767b4 Merge branch 'master' into dev/migrie/f/i-love-these-tests
  • e2a918e Merge remote-tracking branch 'origin/master' into dev/migrie/f/i-love-these-tests
  • 7c8a7d1 fix @miniksa breaking my build

📊 Changes

16 files changed (+788 additions, -19 deletions)

View changed files

📝 src/cascadia/TerminalCore/Terminal.hpp (+9 -0)
src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp (+366 -0)
📝 src/cascadia/UnitTests_TerminalCore/UnitTests.vcxproj (+39 -2)
📝 src/cascadia/UnitTests_TerminalCore/precomp.h (+17 -3)
📝 src/host/screenInfo.hpp (+2 -0)
src/host/ut_host/ConptyOutputTests.cpp (+309 -0)
📝 src/host/ut_host/Host.UnitTests.vcxproj (+1 -0)
📝 src/host/ut_host/TextBufferTests.cpp (+1 -1)
📝 src/host/ut_host/sources (+1 -0)
📝 src/inc/test/CommonState.hpp (+12 -9)
📝 src/renderer/base/renderer.cpp (+6 -2)
📝 src/renderer/base/renderer.hpp (+4 -0)
📝 src/renderer/vt/Xterm256Engine.hpp (+1 -0)
📝 src/renderer/vt/XtermEngine.hpp (+1 -0)
📝 src/renderer/vt/state.cpp (+12 -2)
📝 src/renderer/vt/vtrenderer.hpp (+7 -0)

📄 Description

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/4213 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 1/14/2020 **Status:** ✅ Merged **Merged:** 1/17/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/migrie/f/i-love-these-tests` --- ### 📝 Commits (8) - [`302e04a`](https://github.com/microsoft/terminal/commit/302e04a091781e37d1a63404fbd1da87f323aa21) Create some tests that roundtrip content through conpt to verify in the terminal - [`bf4f610`](https://github.com/microsoft/terminal/commit/bf4f6104e57833d1bee58797ebf1e5d8dd074f1e) polish for review - [`eb6992e`](https://github.com/microsoft/terminal/commit/eb6992e03f06ab7fdccb54b9358d68c40e3f68a8) Apply suggestions from code review - [`a8fd596`](https://github.com/microsoft/terminal/commit/a8fd59662fffb11b8f470ec71259feb5ec09780f) Merge remote-tracking branch 'origin/master' into dev/migrie/f/i-love-these-tests - [`77fbfc6`](https://github.com/microsoft/terminal/commit/77fbfc62c8a4339ea4e16d853c05e8b73b2302c2) These were some comments from niksa - [`1b767b4`](https://github.com/microsoft/terminal/commit/1b767b4e2c9bb7997e0dab889f77fbafd1157813) Merge branch 'master' into dev/migrie/f/i-love-these-tests - [`e2a918e`](https://github.com/microsoft/terminal/commit/e2a918e257ee117a4340e3be88ba19edfeebf013) Merge remote-tracking branch 'origin/master' into dev/migrie/f/i-love-these-tests - [`7c8a7d1`](https://github.com/microsoft/terminal/commit/7c8a7d10d8e518d7aee0ca4675fde209979b1202) fix @miniksa breaking my build ### 📊 Changes **16 files changed** (+788 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalCore/Terminal.hpp` (+9 -0) ➕ `src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp` (+366 -0) 📝 `src/cascadia/UnitTests_TerminalCore/UnitTests.vcxproj` (+39 -2) 📝 `src/cascadia/UnitTests_TerminalCore/precomp.h` (+17 -3) 📝 `src/host/screenInfo.hpp` (+2 -0) ➕ `src/host/ut_host/ConptyOutputTests.cpp` (+309 -0) 📝 `src/host/ut_host/Host.UnitTests.vcxproj` (+1 -0) 📝 `src/host/ut_host/TextBufferTests.cpp` (+1 -1) 📝 `src/host/ut_host/sources` (+1 -0) 📝 `src/inc/test/CommonState.hpp` (+12 -9) 📝 `src/renderer/base/renderer.cpp` (+6 -2) 📝 `src/renderer/base/renderer.hpp` (+4 -0) 📝 `src/renderer/vt/Xterm256Engine.hpp` (+1 -0) 📝 `src/renderer/vt/XtermEngine.hpp` (+1 -0) 📝 `src/renderer/vt/state.cpp` (+12 -2) 📝 `src/renderer/vt/vtrenderer.hpp` (+7 -0) </details> ### 📄 Description ## 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 * [x] Doesn't close anything on it's own. * [x] I work here * [x] 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:11:09 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25690