Skip to content

Commit 1d8f473

Browse files
authored
Merge branch 'master' into jruby-new-pty
2 parents e311608 + c634c7f commit 1d8f473

8 files changed

Lines changed: 86 additions & 41 deletions

File tree

.github/workflows/push_gem.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ jobs:
2323

2424
steps:
2525
- name: Harden Runner
26-
uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2
26+
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
2727
with:
2828
egress-policy: audit
2929

30-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3131

3232
- name: Set up Ruby
3333
uses: ruby/setup-ruby@eaecf785f6a34567a6d97f686bbb7bccc1ac1e5c # v1.237.0

.github/workflows/sync-ruby.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Sync ruby
2+
on:
3+
push:
4+
branches: [master]
5+
jobs:
6+
sync:
7+
name: Sync ruby
8+
runs-on: ubuntu-latest
9+
if: ${{ github.repository_owner == 'ruby' }}
10+
steps:
11+
- uses: actions/checkout@v5
12+
13+
- name: Create GitHub App token
14+
id: app-token
15+
uses: actions/create-github-app-token@v2
16+
with:
17+
app-id: 2060836
18+
private-key: ${{ secrets.RUBY_SYNC_DEFAULT_GEMS_PRIVATE_KEY }}
19+
owner: ruby
20+
repositories: ruby
21+
22+
- name: Sync to ruby/ruby
23+
uses: convictional/trigger-workflow-and-wait@v1.6.5
24+
with:
25+
owner: ruby
26+
repo: ruby
27+
workflow_file_name: sync_default_gems.yml
28+
github_token: ${{ steps.app-token.outputs.token }}
29+
ref: master
30+
client_payload: |
31+
{"gem":"${{ github.event.repository.name }}","before":"${{ github.event.before }}","after":"${{ github.event.after }}"}
32+
propagate_failure: true
33+
wait_interval: 10

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
git config --global core.autocrlf false
3535
git config --global core.eol lf
3636
git config --global advice.detachedHead 0
37-
- uses: actions/checkout@v4
37+
- uses: actions/checkout@v5
3838
- name: Set up Ruby ${{ matrix.ruby }}
3939
uses: ruby/setup-ruby@v1
4040
with:

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ gemspec
66
group :development do
77
gem "bundler"
88
gem "rake"
9+
gem "rdoc"
910
gem "test-unit"
1011
gem "test-unit-ruby-core"
1112
gem 'rake-compiler'

ext/io/console/console.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
static const char *const
7-
IO_CONSOLE_VERSION = "0.8.0";
7+
IO_CONSOLE_VERSION = "0.8.1";
88

99
#include "ruby.h"
1010
#include "ruby/io.h"

ext/io/console/extconf.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
abort
1111

1212
have_func("rb_interned_str_cstr")
13-
have_func("rb_io_path")
14-
have_func("rb_io_descriptor")
15-
have_func("rb_io_get_write_io")
16-
have_func("rb_io_closed_p")
17-
have_func("rb_io_open_descriptor")
13+
have_func("rb_io_path", "ruby/io.h")
14+
have_func("rb_io_descriptor", "ruby/io.h")
15+
have_func("rb_io_get_write_io", "ruby/io.h")
16+
have_func("rb_io_closed_p", "ruby/io.h")
17+
have_func("rb_io_open_descriptor", "ruby/io.h")
1818
have_func("rb_ractor_local_storage_value_newkey")
1919

2020
is_wasi = /wasi/ =~ MakeMakefile::RbConfig::CONFIG["platform"]

lib/ffi/io/console.rb

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,45 +24,51 @@
2424
require_relative 'console/version'
2525
require_relative 'console/common'
2626

27-
# If Windows, always use the stub version
28-
if RbConfig::CONFIG['host_os'] =~ /(mswin)|(win32)|(ming)/
29-
require_relative 'console/stub_console'
30-
else
31-
27+
case RbConfig::CONFIG['host_os']
28+
when /darwin|openbsd|freebsd|netbsd|linux/i
3229
# If Linux or BSD, try to load the native version
33-
if RbConfig::CONFIG['host_os'].downcase =~ /darwin|openbsd|freebsd|netbsd|linux/
34-
begin
3530

36-
# Attempt to load the native Linux and BSD console logic
37-
require_relative 'console/native_console'
38-
ready = true
31+
begin
32+
33+
# Attempt to load the native Linux and BSD console logic
34+
require_relative 'console/native_console'
35+
36+
rescue Exception => ex
3937

40-
rescue Exception => ex
38+
warn "failed to load native console support: #{ex}" if $VERBOSE
4139

42-
warn "failed to load native console support: #{ex}" if $VERBOSE
43-
ready = false
40+
else
41+
42+
# Native ready.
43+
ready = true
4444

45-
end
4645
end
4746

48-
# Native failed, try to use stty
49-
if !ready
50-
begin
47+
when /mswin|win32|ming/i
48+
# If Windows, stty is not possible, always use the stub version
49+
50+
ready = false
5151

52-
require_relative 'console/stty_console'
53-
ready = true
52+
end
5453

55-
rescue Exception => ex2
54+
if ready.nil?
55+
# Native is not ready, try to use stty
5656

57-
warn "failed to load stty console support: #{ex2}" if $VERBOSE
58-
ready = false
57+
begin
58+
59+
require_relative 'console/stty_console'
60+
ready = true
61+
62+
rescue Exception => ex2
63+
64+
warn "failed to load stty console support: #{ex2}" if $VERBOSE
65+
ready = false
5966

60-
end
6167
end
68+
end
6269

70+
unless ready
6371
# If still not ready, just use stubbed version
64-
if !ready
65-
require_relative 'console/stub_console'
66-
end
6772

73+
require_relative 'console/stub_console'
6874
end

test/io/console/test_io_console.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
end
88

99
class TestIO_Console < Test::Unit::TestCase
10+
HOST_OS = RbConfig::CONFIG['host_os']
11+
private def host_os?(os)
12+
HOST_OS =~ os
13+
end
14+
1015
begin
1116
PATHS = $LOADED_FEATURES.grep(%r"/io/console(?:\.#{RbConfig::CONFIG['DLEXT']}|\.rb|/\w+\.rb)\z") {$`}
1217
rescue Encoding::CompatibilityError
@@ -26,7 +31,7 @@ class TestIO_Console < Test::Unit::TestCase
2631
# But it does not occur in `make test-all > /dev/null`, so
2732
# there should be an additional factor, I guess.
2833
def set_winsize_setup
29-
@old_ttou = trap(:TTOU, 'IGNORE') if RUBY_PLATFORM =~ /freebsd/i
34+
@old_ttou = trap(:TTOU, 'IGNORE') if host_os?(/freebsd/)
3035
end
3136

3237
def set_winsize_teardown
@@ -368,10 +373,10 @@ def assert_ctrl(expect, cc, r, w)
368373
w.flush
369374
result = EnvUtil.timeout(3) {r.gets}
370375
if result
371-
case cc
372-
when 0..31
376+
case cc.chr
377+
when "\C-A".."\C-_"
373378
cc = "^" + (cc.ord | 0x40).chr
374-
when 127
379+
when "\C-?"
375380
cc = "^?"
376381
end
377382
result.sub!(cc, "")
@@ -387,7 +392,7 @@ def test_intr
387392
# TestIO_Console#test_intr [/usr/home/chkbuild/chkbuild/tmp/build/20220304T163001Z/ruby/test/io/console/test_io_console.rb:387]:
388393
# <"25"> expected but was
389394
# <"-e:12:in `p': \e[1mexecution expired (\e[1;4mTimeout::Error\e[m\e[1m)\e[m">.
390-
omit if /freebsd/ =~ RUBY_PLATFORM
395+
omit if host_os?(/freebsd/)
391396

392397
run_pty("#{<<~"begin;"}\n#{<<~'end;'}") do |r, w, _|
393398
begin;
@@ -413,7 +418,7 @@ def test_intr
413418
if cc = ctrl["intr"]
414419
assert_ctrl("#{cc.ord}", cc, r, w)
415420
assert_ctrl("#{cc.ord}", cc, r, w)
416-
assert_ctrl("Interrupt", cc, r, w) unless /linux/ =~ "#{RUBY_PLATFORM} #{RbConfig::CONFIG['host_os']}"
421+
assert_ctrl("Interrupt", cc, r, w) unless host_os?(/linux/)
417422
end
418423
if cc = ctrl["dsusp"]
419424
assert_ctrl("#{cc.ord}", cc, r, w)

0 commit comments

Comments
 (0)