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

Feature: Add CI for windows #25

Open
wants to merge 78 commits into
base: master
Choose a base branch
from
Open

Feature: Add CI for windows #25

wants to merge 78 commits into from

Conversation

YO4
Copy link

@YO4 YO4 commented Oct 9, 2024

Current Status

yamatanooroti-wt
yamatanooroti-conhost

original PR here

This PR make Yamatanooroti work in windows CI environment.

Now supports conhost(classic, V2) and conhost(legacy, V1).
Windows Terminal is still not supported but planned.

Windows Terminal support is important because of active development.

To test using conhost, you can specify with rake TESTOPTS="--windows=conhost".
In the same way, using conhost(legacy) with rake TESTOPTS="--windows=legacy-conhost".

You can specify showing console reaction during testing with rake TESTOPTS="--show-console"
And close console only for passed test with rake TESTOPTS="--close-console=pass"
or never close with rake TESTOPTS="--close-console=never"

Note: Naming consoles
Since the the Command Prompt Window was the only windows console, it was sufficient to call it console if necessary.
Windows Terminal is the new arrival and is referred to by its own name. What would be a reasonable name for the Command Prompt Window?

conhost.exe provides the Command Prompt Window, so it can be distinguished by calling it conhost as opposed to terminal. Windows Settings App calls it Windows Console Host, so as a short form it is reasonable..
By the way, the Command Prompt Window has 'legacy console mode'.
https://learn.microsoft.com/en-us/windows/console/legacymode
Legacy console mode provides older windows compatibility, ConhostV1.dll provides it.
And there is ForceV2 registry setting.
So older conhost can be refered as legacy V1, newer conhost can be refered as classic V2.
classic is counterpart of legacy, it is taken from the Readme.md of Windows Terminal repository. But that term is not widely used.

YO4 added 29 commits October 3, 2024 20:01
in windows CI enviconments (Github Actions, Appveyor, CircleCI), it seems to standard handles not valid. use conin$/conout$ explicitly.
on console device, gets() returns console codepage string.
SetConsoleScreenBufferSize has a minimum buffer width limit by window width (pixels) derived from the font size.
SetConsoleScreenBufferInfoEx do not seem to have that limitation.

so to use SetConsoleScreenBufferInfoEx can avoid font size tweaking.
AttachConsole(), FreeConsole() ignores C runtime interrupt handler.
If not addressed, the process will not catch Ctrl+C and will die immediately.
Not identical to normal Ctrl+C behavior, but at least a minimal stop action can be performed.
new TESTOPTS
--wait=seconds
--timeout=seconds
--windows=CONSOLE_TYPE
--[no-]show-console
--[no-]close-console[=COND]
We still support only command prompt window (conhost.exe). Windows Terminal support is planned.
Consider legacy-conhost support to be meaningful even without Windows Terminal support, since it can alternatively check operation on older versions of Windows.
When testcase is omitted, @Terminal will be nil
In narrow console window, start up message shows like below:
```
+-----+
|Multi|
|line |
|REPL.|
|promp|
|t>   |
|     |
```
When start_tarminal() with ```startup_message: 'Multiline REPL.'```,
vterm.rb recieves startup message as stream, so window size is not matter.
windows.rb can't recieve startup message as stream, only can retreive_screen().

retreive_screen recieves like:
```["Multi", "line", "REPL.", "promp", "t>", "", ...]```

This patch splits startup_message into every width characters to allow for correct comparisons.

If there are wide widths or complex characters, they will fail to divide accurately.
So it is not perfect. Nevertheless, the situation can be mitigated.
…imes from one testcase

test_simple_dialog_at_right_edge at reline/test/reline/yamatanooroti/test_rendering.rb
If ```def teardown; close; end``` defined in testcase, close() occurs after close_console() which triggered by teardown block in WindowsTestcaseModule
This leak causes problems in the test_yamatanooroti of reline.
To wait process terminate with timeout, use Process.detach and Thread#join(timeout)
@YO4 YO4 force-pushed the ci_for_windows branch 3 times, most recently from 0862bca to 5ea4970 Compare October 20, 2024 09:01
YO4 added 2 commits October 20, 2024 18:23
successful_or_if_not_messageout() returns true
otherwise raise exception or message output to stderr
@YO4 YO4 force-pushed the ci_for_windows branch 2 times, most recently from 1c50d53 to 7cbf84c Compare October 26, 2024 11:42
YO4 added 4 commits October 31, 2024 21:05
new windows/wt.rb (split from windows/terminal.rb, new WindowsTerminal class)
new windows/wmi.rb (WMI Win32_Process interface)
new windows/windows-setup.rb (split from windows/windows.rb)
change windows terminal pane split strategy. make 3 panes at once if sp --size parameter cached.
YO4 added 5 commits November 2, 2024 19:55
More lightweight pid searching process. More lightweight console keeping process. Bonus: child process terminate automatically when yamatanooroti abnormal stopped.

before: search with commandline string via wmi Win32_Process
after: Yamatanootori creates a named pipe and child process connects that. Then use GetNamedPipeClientProcessId()
Sometimes conhost v1(legacy mode conhost) changes console size when changing codepage.
Probably the behavior is only at the transition between SBCS and DBCS.
can't delete running .exe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: api changes to extend windows support.
1 participant