Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 6 additions & 9 deletions .github/workflows/ubuntu-ibm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
# https://github.com/IBM/actionspz/issues/30
- name: Set HOME env
run: |
echo "HOME: #{HOME}"
echo "HOME: ${HOME}"
echo "HOME=$(ls -d ~)" >> $GITHUB_ENV
working-directory:
if: ${{ endsWith(matrix.os, 'ppc64le') || endsWith(matrix.os, 's390x') }}
Expand Down Expand Up @@ -134,15 +134,12 @@ jobs:
continue-on-error: true
timeout-minutes: 3

# A temporary workaround: Skip user ground id test
# There is a mismatch between the group IDs of "id -g" and C function
# getpwuid(uid_t uid) pw_gid.
# A temporary workaround: Set the user's primary group to avoid a mismatch
# between the group IDs of "id -g" and C function getpwuid(uid_t uid)
# pw_gid.
# https://github.com/IBM/actionspz/issues/31
- name: Skip user group id test
run: |
sed -i.orig '/^ it "returns user group id" do/a\ skip' \
../src/spec/ruby/library/etc/struct_passwd_spec.rb
diff -u ../src/spec/ruby/library/etc/struct_passwd_spec.rb{.orig,} || :
- name: Set user's group id
run: sudo usermod -g "$(id -g)" runner
if: ${{ endsWith(matrix.os, 'ppc64le') || endsWith(matrix.os, 's390x') }}

- name: make ${{ matrix.test_task }}
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/zjit-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,22 @@ jobs:
fail-fast: false
matrix:
include:
- test_task: 'zjit-check'
- test_task: 'check'
configure: '--enable-zjit=dev'
run_opts: '--zjit-call-threshold=1'
specopts: '-T --zjit-call-threshold=1'

- test_task: 'zjit-check' # zjit-test + quick feedback of test_zjit.rb
configure: '--enable-yjit=dev --enable-zjit'
rust_version: "1.85.0"

- test_task: 'ruby' # build test for combo build
- test_task: 'ruby'
hint: 'combo build test'
configure: '--enable-yjit --enable-zjit'

- test_task: 'zjit-test-all'
configure: '--enable-zjit=dev'
testopts: '--seed=11831'

- test_task: 'test'
configure: '--enable-zjit=dev'
zjit_opts: '--zjit-call-threshold=1'

env:
GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
RUN_OPTS: ${{ matrix.zjit_opts }}
RUN_OPTS: ${{ matrix.run_opts }}
SPECOPTS: ${{ matrix.specopts }}
TESTOPTS: ${{ matrix.testopts }}

Expand Down Expand Up @@ -113,13 +111,15 @@ jobs:
RUN_OPTS="$RUN_OPTS"
SPECOPTS="$SPECOPTS"
TESTOPTS="$TESTOPTS"
TEST_EXCLUDES="$TEST_EXCLUDES"
timeout-minutes: 60
env:
RUBY_TESTOPTS: '-q --tty=no'
TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
SYNTAX_SUGGEST_TIMEOUT: '5'
PRECHECK_BUNDLED_GEMS: 'no'
TESTS: ${{ matrix.tests }}
TEST_EXCLUDES: '--excludes-dir=../src/test/.excludes-zjit --name=!/memory_leak/'
continue-on-error: ${{ matrix.continue-on-test_task || false }}

result:
Expand Down
26 changes: 12 additions & 14 deletions .github/workflows/zjit-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,23 @@ jobs:
fail-fast: false
matrix:
include:
- test_task: 'zjit-bindgen'
hint: 'To fix: use patch in logs'
configure: '--enable-zjit=dev --with-gcc=clang-14'
libclang_path: '/usr/lib/llvm-14/lib/libclang.so.1'
- test_task: 'check'
configure: '--enable-zjit=dev'
run_opts: '--zjit-call-threshold=1'
specopts: '-T --zjit-call-threshold=1'

- test_task: 'zjit-check'
- test_task: 'zjit-check' # zjit-test + quick feedback of test_zjit.rb
configure: '--enable-yjit --enable-zjit=dev'
rust_version: '1.85.0'

- test_task: 'zjit-test-all'
configure: '--enable-zjit=dev'
testopts: '--seed=18140'

- test_task: 'test'
configure: '--enable-zjit=dev'
zjit_opts: '--zjit-call-threshold=1'
- test_task: 'zjit-bindgen'
hint: 'To fix: use patch in logs'
configure: '--enable-zjit=dev --with-gcc=clang-14'
libclang_path: '/usr/lib/llvm-14/lib/libclang.so.1'

env:
GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
RUN_OPTS: ${{ matrix.zjit_opts }}
RUN_OPTS: ${{ matrix.run_opts }}
YJIT_BENCH_OPTS: ${{ matrix.yjit_bench_opts }}
SPECOPTS: ${{ matrix.specopts }}
TESTOPTS: ${{ matrix.testopts }}
Expand Down Expand Up @@ -152,12 +149,13 @@ jobs:
run: >-
make -s ${{ matrix.test_task }} ${TESTS:+TESTS="$TESTS"}
RUN_OPTS="$RUN_OPTS" MSPECOPT=--debug SPECOPTS="$SPECOPTS"
TESTOPTS="$TESTOPTS"
TESTOPTS="$TESTOPTS" TEST_EXCLUDES="$TEST_EXCLUDES"
ZJIT_BINDGEN_DIFF_OPTS="$ZJIT_BINDGEN_DIFF_OPTS"
timeout-minutes: 90
env:
RUBY_TESTOPTS: '-q --tty=no'
TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
TEST_EXCLUDES: '--excludes-dir=../src/test/.excludes-zjit --name=!/memory_leak/'
PRECHECK_BUNDLED_GEMS: 'no'
SYNTAX_SUGGEST_TIMEOUT: '5'
ZJIT_BINDGEN_DIFF_OPTS: '--exit-code'
Expand Down
10 changes: 5 additions & 5 deletions doc/_regexp.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -1272,13 +1272,13 @@ because the optimization uses memoization (which may invoke large memory consump

== References

Read (online PDF books):
Read:

- {Mastering Regular Expressions}[https://ia902508.us.archive.org/10/items/allitebooks-02/Mastering%20Regular%20Expressions%2C%203rd%20Edition.pdf]
- <i>Mastering Regular Expressions</i>
by Jeffrey E.F. Friedl.
- {Regular Expressions Cookbook}[https://doc.lagout.org/programmation/Regular%20Expressions/Regular%20Expressions%20Cookbook_%20Detailed%20Solutions%20in%20Eight%20Programming%20Languages%20%282nd%20ed.%29%20%5BGoyvaerts%20%26%20Levithan%202012-09-06%5D.pdf]
- <i>Regular Expressions Cookbook</i>
by Jan Goyvaerts & Steven Levithan.

Explore, test (interactive online editor):
Explore, test:

- {Rubular}[https://rubular.com/].
- {Rubular}[https://rubular.com/]: interactive online editor.
2 changes: 1 addition & 1 deletion math.c
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ math_gamma(VALUE unused_obj, VALUE x)
*
* [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1]
*
* See {logarithmic gamma function}[https://en.wikipedia.org/wiki/Gamma_function#The_log-gamma_function].
* See {log gamma function}[https://en.wikipedia.org/wiki/Gamma_function#Log-gamma_function].
*
* - Domain: <tt>(-INFINITY, INFINITY]</tt>.
* - Range of first element: <tt>(-INFINITY, INFINITY]</tt>.
Expand Down
4 changes: 4 additions & 0 deletions ruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ enum feature_flag_bits {
EACH_FEATURES(DEFINE_FEATURE, COMMA),
DEFINE_FEATURE(frozen_string_literal_set),
feature_debug_flag_first,
#if !USE_YJIT && USE_ZJIT
DEFINE_FEATURE(jit) = feature_zjit,
#else
DEFINE_FEATURE(jit) = feature_yjit,
#endif
feature_jit_mask = FEATURE_BIT(yjit) | FEATURE_BIT(zjit),

feature_debug_flag_begin = feature_debug_flag_first - 1,
Expand Down
4 changes: 3 additions & 1 deletion test/-ext-/bug_reporter/test_bug_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def test_bug_reporter_add

no_core = "Process.setrlimit(Process::RLIMIT_CORE, 0); " if defined?(Process.setrlimit) && defined?(Process::RLIMIT_CORE)
args = ["-r-test-/bug_reporter", "-C", tmpdir]
args.push("--yjit") if JITSupport.yjit_enabled? # We want the printed description to match this process's RUBY_DESCRIPTION
# We want the printed description to match this process's RUBY_DESCRIPTION
args.push("--yjit") if JITSupport.yjit_enabled?
args.push("--zjit") if JITSupport.zjit_enabled?
args.unshift({"RUBY_ON_BUG" => nil})
stdin = "#{no_core}register_sample_bug_reporter(12345); Process.kill :SEGV, $$"
assert_in_out_err(args, stdin, [], expected_stderr, encoding: "ASCII-8BIT")
Expand Down
1 change: 0 additions & 1 deletion test/.excludes-zjit/TestBugReporter.rb

This file was deleted.

1 change: 0 additions & 1 deletion test/.excludes-zjit/TestGc.rb

This file was deleted.

1 change: 0 additions & 1 deletion test/.excludes-zjit/TestProc.rb

This file was deleted.

10 changes: 0 additions & 10 deletions test/.excludes-zjit/TestRubyOptions.rb

This file was deleted.

6 changes: 5 additions & 1 deletion test/lib/jit_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def yjit_supported?
end

def yjit_enabled?
defined?(RubyVM::YJIT.enabled?) && RubyVM::YJIT.enabled?
defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?
end

def yjit_force_enabled?
Expand All @@ -22,4 +22,8 @@ def zjit_supported?
# nil in mswin
@zjit_supported = ![nil, 'no'].include?(RbConfig::CONFIG['ZJIT_SUPPORT'])
end

def zjit_enabled?
defined?(RubyVM::ZJIT) && RubyVM::ZJIT.enabled?
end
end
15 changes: 8 additions & 7 deletions test/ruby/test_rubyoptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
require_relative '../lib/parser_support'

class TestRubyOptions < Test::Unit::TestCase
def self.yjit_enabled? = defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?

# Here we're defining our own RUBY_DESCRIPTION without "+PRISM". We do this
# here so that the various tests that reference RUBY_DESCRIPTION don't have to
# worry about it. The flag itself is tested in its own test.
Expand All @@ -22,8 +20,10 @@ def self.yjit_enabled? = defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?

NO_JIT_DESCRIPTION =
case
when yjit_enabled?
RUBY_DESCRIPTION.sub(/\+YJIT( (dev|dev_nodebug|stats))? /, '')
when JITSupport.yjit_enabled?
RUBY_DESCRIPTION.sub(/\+YJIT( \w+)? /, '')
when JITSupport.zjit_enabled?
RUBY_DESCRIPTION.sub(/\+ZJIT( \w+)? /, '')
else
RUBY_DESCRIPTION
end
Expand Down Expand Up @@ -181,7 +181,7 @@ def test_debug
def test_verbose
assert_in_out_err([{'RUBY_YJIT_ENABLE' => nil}, "-vve", ""]) do |r, e|
assert_match(VERSION_PATTERN, r[0])
if self.class.yjit_enabled? && !JITSupport.yjit_force_enabled?
if (JITSupport.yjit_enabled? && !JITSupport.yjit_force_enabled?) || JITSupport.zjit_enabled?
assert_equal(NO_JIT_DESCRIPTION, r[0])
else
assert_equal(RUBY_DESCRIPTION, r[0])
Expand Down Expand Up @@ -247,7 +247,7 @@ def test_version
assert_match(VERSION_PATTERN, r[0])
if ENV['RUBY_YJIT_ENABLE'] == '1'
assert_equal(NO_JIT_DESCRIPTION, r[0])
elsif self.class.yjit_enabled? # checking -DYJIT_FORCE_ENABLE
elsif JITSupport.yjit_enabled? || JITSupport.zjit_enabled? # checking -DYJIT_FORCE_ENABLE
assert_equal(EnvUtil.invoke_ruby(['-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
else
assert_equal(RUBY_DESCRIPTION, r[0])
Expand Down Expand Up @@ -852,7 +852,8 @@ def assert_segv(args, message=nil, list: SEGVTest::ExpectedStderrList, **opt, &b
# We want YJIT to be enabled in the subprocess if it's enabled for us
# so that the Ruby description matches.
env = Hash === args.first ? args.shift : {}
args.unshift("--yjit") if self.class.yjit_enabled?
args.unshift("--yjit") if JITSupport.yjit_enabled?
args.unshift("--zjit") if JITSupport.zjit_enabled?
env.update({'RUBY_ON_BUG' => nil})
# ASAN registers a segv handler which prints out "AddressSanitizer: DEADLYSIGNAL" when
# catching sigsegv; we don't expect that output, so suppress it.
Expand Down
72 changes: 54 additions & 18 deletions test/ruby/test_zjit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,32 @@ def test
}, insns: [:setglobal]
end

def test_toplevel_binding
# Not using assert_compiles, which doesn't use the toplevel frame for `test_script`.
out, err, status = eval_with_jit(%q{
a = 1
b = 2
TOPLEVEL_BINDING.local_variable_set(:b, 3)
c = 4
print [a, b, c]
})
assert_success(out, err, status)
assert_equal "[1, 3, 4]", out
end

def test_toplevel_local_after_eval
# Not using assert_compiles, which doesn't use the toplevel frame for `test_script`.
out, err, status = eval_with_jit(%q{
a = 1
b = 2
eval('b = 3')
c = 4
print [a, b, c]
})
assert_success(out, err, status)
assert_equal "[1, 3, 4]", out
end

def test_getlocal_after_eval
assert_compiles '2', %q{
def test
Expand Down Expand Up @@ -2428,12 +2454,8 @@ def assert_runs(expected, test_script, insns: [], assert_compiles: false, **opts
IO.open(#{pipe_fd}).write(Marshal.dump(result))
RUBY

status, out, err, result = eval_with_jit(script, pipe_fd:, **opts)

message = "exited with status #{status.to_i}"
message << "\nstdout:\n```\n#{out}```\n" unless out.empty?
message << "\nstderr:\n```\n#{err}```\n" unless err.empty?
assert status.success?, message
out, err, status, result = eval_with_jit(script, pipe_fd:, **opts)
assert_success(out, err, status)

result = Marshal.load(result)
assert_equal(expected, result.fetch(:ret_val).inspect)
Expand Down Expand Up @@ -2462,7 +2484,7 @@ def eval_with_jit(
debug: true,
allowed_iseqs: nil,
timeout: 1000,
pipe_fd:
pipe_fd: nil
)
args = ["--disable-gems"]
if zjit
Expand All @@ -2478,18 +2500,25 @@ def eval_with_jit(
end
end
args << "-e" << script_shell_encode(script)
pipe_r, pipe_w = IO.pipe
# Separate thread so we don't deadlock when
# the child ruby blocks writing the output to pipe_fd
pipe_out = nil
pipe_reader = Thread.new do
pipe_out = pipe_r.read
pipe_r.close
ios = {}
if pipe_fd
pipe_r, pipe_w = IO.pipe
# Separate thread so we don't deadlock when
# the child ruby blocks writing the output to pipe_fd
pipe_out = nil
pipe_reader = Thread.new do
pipe_out = pipe_r.read
pipe_r.close
end
ios[pipe_fd] = pipe_w
end
out, err, status = EnvUtil.invoke_ruby(args, '', true, true, rubybin: RbConfig.ruby, timeout: timeout, ios: { pipe_fd => pipe_w })
pipe_w.close
pipe_reader.join(timeout)
[status, out, err, pipe_out]
result = EnvUtil.invoke_ruby(args, '', true, true, rubybin: RbConfig.ruby, timeout: timeout, ios:)
if pipe_fd
pipe_w.close
pipe_reader.join(timeout)
result << pipe_out
end
result
ensure
pipe_reader&.kill
pipe_reader&.join(timeout)
Expand All @@ -2498,6 +2527,13 @@ def eval_with_jit(
jitlist&.unlink
end

def assert_success(out, err, status)
message = "exited with status #{status.to_i}"
message << "\nstdout:\n```\n#{out}```\n" unless out.empty?
message << "\nstderr:\n```\n#{err}```\n" unless err.empty?
assert status.success?, message
end

def script_shell_encode(s)
# We can't pass utf-8-encoded characters directly in a shell arg. But we can use Ruby \u constants.
s.chars.map { |c| c.ascii_only? ? c : "\\u%x" % c.codepoints[0] }.join
Expand Down
1 change: 1 addition & 0 deletions test/rubygems/test_gem_command_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def test_find_command_unknown
end

def test_find_command_unknown_suggestions
omit "randomly fails on ruby/ruby CI" if ENV["GITHUB_REPOSITORY"] == "ruby/ruby"
e = assert_raise Gem::UnknownCommandError do
@command_manager.find_command "pish"
end
Expand Down
Loading