summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-22 14:53:17 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-22 14:53:17 +0000
commit171c496e5082c2e1e9aad80bcd204c1e850512c1 (patch)
tree8ea5671d51497ec7a83e6308750df6cc2fb73763 /test
parentcc777d09f44fa909a336ba14f3aa802ffe16e010 (diff)
version.c: show +JIT when --jit is passed
in version output. version.h: ditto ruby.c: propagate option for it common.mk: updated dependency for version.c mjit.c: overwrites the RUBY_DESCRIPTION to have +JIT when --jit is passed test/ruby/test_rubyoptions.rb: add test for them Only `ruby --jit -v` will have "+JIT", but this is intentional. This may not be convenient for debugging by ticket with `ruby -v`, but it's convenient for benchmark tools that pass options (--jit) when showing it. At least such behavior is planned for benchmark_driver.gem and this behavior is designed for it. Other benchmark tools are recommended to follow the behavior too if they show version. RUBY_DESCRIPTION might be useful for it too. The position of "+JIT" is changed from original proposal because other platforms like JRuby and TruffleRuby end it with archtecture. It's made similar to JRuby, but it's upper-cased because Matz made approval for "+JIT" in the ticket. Example: $ ruby -v ruby 2.6.0dev (2018-02-22 trunk 62529) [x86_64-linux] $ ruby --jit -v ruby 2.6.0dev (2018-02-22 trunk 62529) +JIT [x86_64-linux] After --jit is made default in the future, this output may be removed. So do not rely on this output if possible. [Feature #14462] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_rubyoptions.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 083572ca67..038d0c2db2 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -96,6 +96,15 @@ class TestRubyOptions < Test::Unit::TestCase
end
private_constant :VERSION_PATTERN
+ VERSION_PATTERN_WITH_JIT =
+ case RUBY_ENGINE
+ when 'jruby'
+ VERSIN_PATTERN
+ else
+ /^ruby #{q[RUBY_VERSION]}(?:[p ]|dev|rc).*? \+JIT \[#{q[RUBY_PLATFORM]}\]$/
+ end
+ private_constant :VERSION_PATTERN_WITH_JIT
+
def test_verbose
assert_in_out_err(["-vve", ""]) do |r, e|
assert_match(VERSION_PATTERN, r[0])
@@ -155,7 +164,20 @@ class TestRubyOptions < Test::Unit::TestCase
def test_version
assert_in_out_err(%w(--version)) do |r, e|
assert_match(VERSION_PATTERN, r[0])
- assert_equal(RUBY_DESCRIPTION, r[0])
+ if RubyVM::MJIT.enabled?
+ assert_equal(EnvUtil.invoke_ruby(['-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
+ else
+ assert_equal(RUBY_DESCRIPTION, r[0])
+ end
+ assert_equal([], e)
+ end
+ assert_in_out_err(%w(--version --jit)) do |r, e|
+ assert_match(VERSION_PATTERN_WITH_JIT, r[0])
+ if RubyVM::MJIT.enabled?
+ assert_equal(RUBY_DESCRIPTION, r[0])
+ else
+ assert_equal(EnvUtil.invoke_ruby(['--jit', '-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
+ end
assert_equal([], e)
end
end