Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
7ca028b
windows: modify for ci
YO4 Apr 8, 2024
871f9c2
windows: change console codepage if needed
YO4 Apr 8, 2024
c91e83a
report exception properly even if that occurs in the target process
YO4 Apr 14, 2024
6a13318
change terminal resizing mechanism
YO4 Apr 15, 2024
ced37b2
use taskkill.exe to close child processes
YO4 Apr 10, 2024
065edb4
more WindowsDefinition
YO4 Oct 3, 2024
ade0feb
prepare windows/windows-definition.rb
YO4 Oct 5, 2024
81e6819
prepare windows/conhost.rb
YO4 Oct 5, 2024
9835ae8
prepare windows/windows.rb
YO4 Oct 5, 2024
22b1d46
resurrect windows.rb
YO4 Oct 5, 2024
df5c8b9
split windows.rb and prepareing to support Windows Terminal
YO4 Oct 5, 2024
837a91a
cleanup process propery when interrupted(Ctrl+C)
YO4 Oct 7, 2024
d5b84ef
Enhance TESTOPTS for windows conhost selection and others
YO4 Oct 8, 2024
16085f7
attr_reader returns nil on old rubies
YO4 Oct 8, 2024
a7c978f
report windows console selection
YO4 Oct 8, 2024
f12c224
ci for windows
YO4 Oct 8, 2024
aec6814
Add minimal TESTOPTS instructions in README.md
YO4 Oct 8, 2024
4558f84
add test windows console selection function working propery
YO4 Oct 9, 2024
30e8bc9
@terminal can be nil
YO4 Oct 10, 2024
f0ee26b
support startup_message with narrow window size
YO4 Oct 10, 2024
d5ae8ac
close subprocess propery even when calling setup_terminal() several t…
YO4 Oct 12, 2024
ae4416b
add TESTOPTS windows terminal settings
YO4 Oct 9, 2024
31a1430
download windows terminal zip
YO4 Oct 9, 2024
875ebf2
extract windows terminal zip
YO4 Oct 13, 2024
5a9886c
support windows terminal
YO4 Oct 13, 2024
a9191f9
expand invoke timeout
YO4 Oct 13, 2024
ec56b4d
add windows terminal to ci
YO4 Oct 13, 2024
6c85a8e
allow close() to be called after close_console()
YO4 Oct 13, 2024
9f46da4
prevent to child process handle leak
YO4 Oct 15, 2024
745b886
use GeneraConsoleCtrlEvent to simulate Ctrl+C
YO4 Oct 15, 2024
6495f7f
kill process recursively
YO4 Oct 15, 2024
5087550
add timeout to wait terminal wakeup
YO4 Oct 16, 2024
808d5c4
always check terminal size
YO4 Oct 16, 2024
f47d625
fix tmpdir when --wt-dir not specified
YO4 Oct 16, 2024
9f20559
report tasklist when marker process detection failed
YO4 Oct 16, 2024
669b5da
more debug
YO4 Oct 16, 2024
8904d9d
shrink windows terminal font size
YO4 Oct 17, 2024
d3dd5ff
repl with ```ruby windows-definition.rb```
YO4 Oct 17, 2024
c6231d4
windows terminal supports --no-show option
YO4 Oct 17, 2024
003507c
propery check codepage changed
YO4 Oct 17, 2024
b6aebec
diagnose WT min/max size
YO4 Oct 17, 2024
b819910
puts WT size if failed
YO4 Oct 17, 2024
a977f74
windows terminal split pane calculation change
YO4 Oct 17, 2024
59e2ed6
Change WT size changing strategy
YO4 Oct 18, 2024
e9bb16e
revert windows terminal supports --no-show option
YO4 Oct 18, 2024
c04f714
Report actual window size
YO4 Oct 18, 2024
d0e9883
Isolate Yamatanooroti::Options dependency from win32api REPL
YO4 Oct 18, 2024
e1e2f3e
WIN32API error message generation fixed
YO4 Oct 19, 2024
b5c4450
In normal case, an error in attach_terminal() should raise an exception
YO4 Oct 19, 2024
4cbf2b8
Avoid timing issues in test
YO4 Oct 19, 2024
9a076a4
add a convenient method invoke_key in windows-definitions.rb REPL
YO4 Oct 20, 2024
6b5eb18
use various ruby versions on windows ci
YO4 Oct 20, 2024
efcf1fb
use newer reline if necessary to avoid an windows specific bug
YO4 Oct 20, 2024
72fe4fc
fiddle of ruby 3.4 is bundled gem
YO4 Oct 20, 2024
2174239
older windows ruby has multibyte character console input issues
YO4 Oct 20, 2024
ae4211e
avoid a frozen string literal issue
YO4 Oct 20, 2024
621e63c
mitigates the issue of close() immediately after write()
YO4 Oct 20, 2024
3adce06
support 2.6 syntax
YO4 Oct 20, 2024
8a4ed71
reduce windows matrix
YO4 Oct 20, 2024
3ec89d1
move gem "fiddle" to gemfile
YO4 Oct 20, 2024
2561d29
waiting before close condition fix and more precise message
YO4 Oct 20, 2024
f97a642
check successful win32_last_error
YO4 Oct 20, 2024
ff0b20a
make conhost.rb console startup waiting method the same way as termin…
YO4 Oct 20, 2024
f570abb
prevent startup message testcase timeout
YO4 Oct 21, 2024
5d47b25
restructure windows source code
YO4 Oct 24, 2024
dede411
Merge branch 'master' into ci_for_windows
YO4 Oct 31, 2024
06875d4
avoid error in ci
YO4 Oct 24, 2024
724ff6e
change windows terminal settings
YO4 Oct 31, 2024
cc8beb0
change child process detection strategy
YO4 Nov 2, 2024
dc6c49a
more robust interrupt detection and terminate process
YO4 Nov 2, 2024
0804413
move codepage setup timing
YO4 Nov 2, 2024
da95f38
reuse existing wt if executable running
YO4 Nov 2, 2024
951c89b
misc. compatibility fix
YO4 Nov 2, 2024
acef53b
kill target process properly when yamatanooroti interrupted.
YO4 Nov 4, 2024
20eb173
avoid start /b for conhost target
YO4 Nov 4, 2024
23212e6
Ctrl+C resistant for conhost
YO4 Nov 4, 2024
cbeb333
ruby 2.7 windows also needs newer reline for test_meta_key
YO4 Nov 4, 2024
47bb74a
property exit windows-definition REPL
YO4 Nov 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/y.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,40 @@ jobs:
run: |
bundle install
bundle exec rake test
windows-yamatanooroti:
needs: ruby-versions
name: >-
${{ matrix.os }} ${{ matrix.ruby }} ${{ matrix.console }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ windows-2019, windows-2022 ]
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
console: [ conhost, legacy-conhost, stable ]
exclude:
- ruby: 2.5
- console: stable
os: windows-2019
- console: legacy-conhost
os: windows-2022
include:
- os: windows-2022
ruby: 3.3
console: preview
- os: windows-2022
ruby: 3.3
console: canary
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: rake test
run: |
bundle install
bundle exec rake test TESTOPTS="-v --wt_dir=./tmp --windows=${{ matrix.console }}"
11 changes: 11 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ unless RbConfig::CONFIG['host_os'].match?(/mswin|msys|mingw|cygwin|bccwin|wince|
gem "vterm", github: "ruby/vterm-gem"
end

if Gem.win_platform?
gem "fiddle", '>= 1.0.8' if
(RUBY_ENGINE == "ruby" && RUBY_VERSION >= '3.4') ||
Gem::Version.new("1.0.8") > begin
require 'fiddle'
Gem::Version.new(Fiddle::VERSION)
rescue
Gem::Version.new("0.0.0")
end
end

# Specify your gem's dependencies in reline.gemspec
gemspec

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ Tasks: TOP => default => test
(See full trace by running task with --trace)
```

### Commandline Options

Yamatanooroti provides some additional TESTOPTS options.

This is more important when running on Windows because of the type of console to be tested is specified in TESTOPTS.

Please see ```rake TESTOPTS="-h"```.

### Advanced Usage

If you want to specify vterm environment that needs vterm gem, you can use `Yamatanooroti::VTermTestCase`:
Expand Down
5 changes: 5 additions & 0 deletions bin/simple_repl
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
loop {
print 'prompt> '
result = gets
result.force_encoding('locale').encode!(Encoding.default_external) unless result.valid_encoding?
puts "=> #{eval(result).inspect}"
}

# On older windows ruby versions(< 3.1 ?), STDIN.gets returns locale code bytes with default external encoding. https://bugs.ruby-lang.org/issues/18353
# Not same versions(< 3.2 ?), STDIN.gets returns invalid bytes if input with leading DBCS characters. https://bugs.ruby-lang.org/issues/18588
# Because of this, input key stroke must start with SBCS character to support older ruby versions.
1 change: 1 addition & 0 deletions lib/yamatanooroti.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'test/unit'
require_relative 'yamatanooroti/options'

class Yamatanooroti
def self.load_vterm
Expand Down
157 changes: 157 additions & 0 deletions lib/yamatanooroti/options.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
class Yamatanooroti
module Options
options = [
:default_wait,
:default_timeout,

# windows console selection
:windows,

# true if conhost(classic) or conhost(legacy)
:conhost,

# true if windows terminal
:terminal,

# windows terminal download/extract dir
:terminal_workdir,

# show console window on windows
:show_console,

# conditional close console window on windows
:close_console,
]
self.singleton_class.instance_eval do
attr_reader(*options)
end

Accessor = Module.new do |mod|
options.each do |name|
mod.define_method name do
Yamatanooroti::Options.public_send(name)
end
end
end

module WindowsTerminal
ALIAS = {
stable: :"1.21",
preview: :"1.22preview"
}
RELEASES = {
"1.22preview": {
url: "https://github.com/microsoft/terminal/releases/download/v1.22.2702.0/Microsoft.WindowsTerminalPreview_1.22.2702.0_x64.zip",
sha256: "CE8EED54D120775F31E3572A76EF5AE461B9E2D8887AB5DFF2F1859E24F4CE0B"
},
"1.21": {
url: "https://github.com/microsoft/terminal/releases/download/v1.21.2701.0/Microsoft.WindowsTerminal_1.21.2701.0_x64.zip",
sha256: "2F712872ED7F552763F3776EA7A823C9E7413CFD5EC65B88E95162E93ACEF899"
},
"1.21preview": {
url: "https://github.com/microsoft/terminal/releases/download/v1.21.1772.0/Microsoft.WindowsTerminalPreview_1.21.1772.0_x64.zip",
sha256: "6AA37175E2B09170829A39DAF3357D4B88A3965C3C529A45B1B0781B8F3425F0"
},
"1.20": {
url: "https://github.com/microsoft/terminal/releases/download/v1.20.11781.0/Microsoft.WindowsTerminal_1.20.11781.0_x64.zip",
sha256: "B7A6046903CE33D75250DA7E40AD2929E51703AB66E9C3A0B02A839C2E868FEC"
},
"1.19": {
url: "https://github.com/microsoft/terminal/releases/download/v1.19.11213.0/Microsoft.WindowsTerminal_1.19.11213.0_x64.zip",
sha256: "E32D7E72F8490AD94174708BB0B420E1EF4467B92F442D40DFAFDF42202A16A7"
},
"1.18": {
url: "https://github.com/microsoft/terminal/releases/download/v1.18.10301.0/Microsoft.WindowsTerminal_1.18.10301.0_x64.zip",
sha256: "38B0E38B545D9C61F1B4214EA3EC6117C0EC348FEB18476D04ECEFB4D7DA723D"
},
# v1.17 : the first windows terminal supports portable mode
"1.17": {
url: "https://github.com/microsoft/terminal/releases/download/v1.17.11461.0/Microsoft.WindowsTerminal_1.17.11461.0_x64.zip",
sha256: "F2B1539649D17752888D7944F97D6372F8D48EB1CEB024501DF8D8E9D3352F25"
},
}

def self.interpret(name)
if ALIAS.has_key?(name)
name = ALIAS[name]
end
if RELEASES.has_key?(name)
return name.to_s
elsif name == :canary
return name
end
raise "bug! #{name} is unknows"
end
end

CONHOST_TYPES = [:conhost, :"legacy-conhost"]
TERMINAL_TYPES = [:stable, :preview, :canary]
TERMINAL_VERSIONS = WindowsTerminal::RELEASES.keys
CLOSE_WHEN = [:always, :pass, :never]

::Test::Unit::AutoRunner.setup_option do |autorunner, o|
@default_wait = 0.01
@default_timeout = 2.0
@windows = Yamatanooroti.win? ? :conhost : nil
@conhost = true
@terminal = false
@terminal_workdir = nil
@show_console = nil
@close_console = :always

o.on_tail("yamatanooroti options")
o.on_tail("--wait=#{@default_wait}", Float,
"Specify yamatanooroti wait time in seconds.") do |seconds|
@default_wait = seconds
end

o.on_tail("--timeout=#{@default_timeout}", Float,
"Specify yamatanooroti timeout in seconds.") do |seconds|
@default_timeout = seconds
end

o.on_tail("windows specific yamatanooroti options")

o.on_tail("--windows=TYPE", CONHOST_TYPES + TERMINAL_TYPES + TERMINAL_VERSIONS,
"Specify console type",
"(#{autorunner.keyword_display(CONHOST_TYPES + TERMINAL_TYPES)})",
"(#{TERMINAL_VERSIONS.sort.join(", ")})") do |type|
@conhost = CONHOST_TYPES.include?(type)
@terminal = !@conhost
@windows = @conhost ? type : WindowsTerminal.interpret(type)
if @terminal
if @show_console == false
puts "Windows Terminal is always visible. --no-show-console is ignored."
end
@show_console = true
end
end

o.on_tail("--wt-dir=DIR", String,
"Specify Windows Terminal working dir.",
"Automatically determined if not specified and treated temporary.",
"DIR is treaded permanent if specified and download files are remains.") do |dir|
@terminal_workdir = dir
end

o.on_tail("--[no-]show-console",
"Show test ongoing console.") do |show|
if show == false and @terminal
puts "Windows Terminal is always visible. --no-show-console is ignored."
else
@show_console = show
end
end

o.on_tail("--[no-]close-console[=COND]", CLOSE_WHEN,
"Close test target console when COND met",
"(#{autorunner.keyword_display(CLOSE_WHEN)})") do |cond|
@close_console = (cond.nil? ? :always : cond) || :never
end
end
end

def self.options
Options
end
end
6 changes: 3 additions & 3 deletions lib/yamatanooroti/vterm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
require 'io/wait'

module Yamatanooroti::VTermTestCaseModule
def start_terminal(height, width, command, wait: 0.01, timeout: 2, startup_message: nil)
@timeout = timeout
@wait = wait
def start_terminal(height, width, command, wait: nil, timeout: nil, startup_message: nil)
@timeout = timeout || Yamatanooroti.options.default_timeout
@wait = wait || Yamatanooroti.options.default_wait
@result = nil

@pty_output, @pty_input, @pid = PTY.spawn(*command)
Expand Down
Loading