summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/-ext-/bug_reporter/test_bug_reporter.rb1
-rw-r--r--test/ruby/test_rubyoptions.rb23
-rw-r--r--test/ruby/test_yjit.rb28
-rw-r--r--version.c10
4 files changed, 51 insertions, 11 deletions
@@ -8,6 +8,7 @@ class TestBugReporter < Test::Unit::TestCase
description = RUBY_DESCRIPTION
description = description.sub(/\+JIT /, '') if defined?(RubyVM::JIT) && RubyVM::JIT.enabled?
expected_stderr = [
:*,
/\[BUG\]\sSegmentation\sfault.*\n/,
@@ -10,6 +10,8 @@ class TestRubyOptions < Test::Unit::TestCase
NO_JIT_DESCRIPTION =
if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # checking -DMJIT_FORCE_ENABLE
RUBY_DESCRIPTION.sub(/\+JIT /, '')
else
RUBY_DESCRIPTION
end
@@ -140,10 +142,12 @@ class TestRubyOptions < Test::Unit::TestCase
private_constant :VERSION_PATTERN_WITH_JIT
def test_verbose
- assert_in_out_err(["-vve", ""]) do |r, e|
assert_match(VERSION_PATTERN, r[0])
if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? && !mjit_force_enabled? # checking -DMJIT_FORCE_ENABLE
assert_equal(NO_JIT_DESCRIPTION, r[0])
else
assert_equal(RUBY_DESCRIPTION, r[0])
end
@@ -203,10 +207,13 @@ class TestRubyOptions < Test::Unit::TestCase
end
def test_version
- assert_in_out_err(%w(--version)) do |r, e|
assert_match(VERSION_PATTERN, r[0])
if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # checking -DMJIT_FORCE_ENABLE
assert_equal(EnvUtil.invoke_ruby(['-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
else
assert_equal(RUBY_DESCRIPTION, r[0])
end
@@ -220,7 +227,7 @@ class TestRubyOptions < Test::Unit::TestCase
%w(--version --enable=jit --disable=jit),
%w(--version --enable-jit --disable-jit),
].each do |args|
- assert_in_out_err(args) do |r, e|
assert_match(VERSION_PATTERN, r[0])
assert_match(NO_JIT_DESCRIPTION, r[0])
assert_equal([], e)
@@ -229,16 +236,16 @@ class TestRubyOptions < Test::Unit::TestCase
if JITSupport.supported?
[
- %w(--version --disable-yjit --jit),
- %w(--version --disable-yjit --enable=jit),
- %w(--version --disable-yjit --enable-jit),
].each do |args|
- assert_in_out_err(args) do |r, e|
assert_match(VERSION_PATTERN_WITH_JIT, r[0])
if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # checking -DMJIT_FORCE_ENABLE
assert_equal(RUBY_DESCRIPTION, r[0])
else
- assert_equal(EnvUtil.invoke_ruby(['--disable-yjit', '--jit', '-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
end
assert_equal([], e)
end
@@ -8,6 +8,34 @@ return unless YJIT.enabled?
# Tests for YJIT with assertions on compilation and side exits
# insipired by the MJIT tests in test/ruby/test_jit.rb
class TestYJIT < Test::Unit::TestCase
def test_compile_getclassvariable
script = 'class Foo; @@foo = 1; def self.foo; @@foo; end; end; Foo.foo'
assert_compiles(script, insns: %i[getclassvariable], result: 1)
@@ -43,6 +43,7 @@ const char ruby_platform[] = RUBY_PLATFORM;
const int ruby_level = RUBY_LEVEL;
const char ruby_description[] = RUBY_DESCRIPTION_WITH("");
static const char ruby_description_with_jit[] = RUBY_DESCRIPTION_WITH(" +JIT");
const char ruby_copyright[] = RUBY_COPYRIGHT;
const char ruby_engine[] = "ruby";
@@ -105,6 +106,9 @@ Init_ruby_description(void)
if (MJIT_OPTS_ON) {
description = MKSTR(description_with_jit);
}
else {
description = MKSTR(description);
}
@@ -121,13 +125,13 @@ ruby_show_version(void)
if (MJIT_OPTS_ON) {
PRINT(description_with_jit);
}
else {
PRINT(description);
}
- if (rb_yjit_enabled_p()) {
- fputs("YJIT is enabled\n", stdout);
- }
#ifdef RUBY_LAST_COMMIT_TITLE
fputs("last_commit=" RUBY_LAST_COMMIT_TITLE, stdout);
#endif