Skip to content

Commit 963b164

Browse files
committed
Add specs for the launcher runtime configuration flags
(cherry picked from commit e6dfd43)
1 parent f4a899d commit 963b164

File tree

3 files changed

+52
-9
lines changed

3 files changed

+52
-9
lines changed

spec/tags/truffle/launcher_tags.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ slow:The launcher supports running rdoc symlinked
5656
slow:The launcher supports running ri symlinked
5757
slow:The launcher supports running ruby symlinked
5858
slow:The launcher supports running truffleruby symlinked
59+
arm64:The launcher for gem can install and uninstall the hello-world gem
5960
slow:The launcher should recognize ruby --vm options in RUBYOPT
6061
slow:The launcher should recognize ruby --vm options in TRUFFLERUBYOPT
61-
arm64:The launcher for gem can install and uninstall the hello-world gem
62+
slow:The launcher runtime configuration flags should recognize ruby --vm options in RUBYOPT when switching to JVM
63+
slow:The launcher runtime configuration flags should recognize ruby --vm options in TRUFFLERUBYOPT when switching to JVM
64+
slow:The launcher runtime configuration flags uses --native by default
65+
slow:The launcher runtime configuration flags switches to JVM with --jvm as a Ruby argument
66+
slow:The launcher runtime configuration flags keeps --jvm as an application argument if given as an application argument

spec/truffle/fixtures/argv.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
p ARGV

spec/truffle/launcher_spec.rb

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,6 @@ def check_status_or_print(stdout_and_stderr)
145145
end
146146
end
147147

148-
['RUBYOPT', 'TRUFFLERUBYOPT'].each do |var|
149-
it "should recognize ruby --vm options in #{var}" do
150-
out = ruby_exe('print Truffle::System.get_java_property("foo")', env: { var => "--vm.Dfoo=bar" }, args: @redirect)
151-
check_status_and_empty_stderr
152-
out.should == 'bar'
153-
end
154-
end
155-
156148
def should_print_full_java_command(options, env: {})
157149
out = ruby_exe(nil, options: options, env: env, args: @redirect)
158150
check_status_and_empty_stderr
@@ -410,4 +402,49 @@ def should_print_full_java_command(options, env: {})
410402
end
411403
end
412404

405+
['RUBYOPT', 'TRUFFLERUBYOPT'].each do |var|
406+
it "should recognize ruby --vm options in #{var}" do
407+
out = ruby_exe('print Truffle::System.get_java_property("foo")', env: { var => "--vm.Dfoo=bar" }, args: @redirect)
408+
check_status_and_empty_stderr
409+
out.should == 'bar'
410+
end
411+
end
412+
413+
guard -> {
414+
# GraalVM with both --jvm and --native
415+
TruffleRuby.graalvm_home and TruffleRuby.native?
416+
} do
417+
describe "runtime configuration flags" do
418+
['RUBYOPT', 'TRUFFLERUBYOPT'].each do |var|
419+
it "should recognize ruby --vm options in #{var} when switching to JVM" do
420+
out = ruby_exe('puts RUBY_DESCRIPTION; puts Truffle::System.get_java_property("foo")', env: { var => "--jvm --vm.Dfoo=bar" }, args: @redirect)
421+
check_status_and_empty_stderr
422+
out = out.lines.map(&:chomp)
423+
out[0].should =~ /GraalVM (CE|EE) JVM/
424+
out[1].should == 'bar'
425+
end
426+
end
427+
428+
it "uses --native by default" do
429+
out = ruby_exe(nil, options: "--version", args: @redirect)
430+
check_status_and_empty_stderr
431+
out.should =~ /GraalVM (CE|EE) Native/
432+
end
433+
434+
it "switches to JVM with --jvm as a Ruby argument" do
435+
out = ruby_exe(nil, options: "--jvm --version", args: @redirect)
436+
check_status_and_empty_stderr
437+
out.should =~ /GraalVM (CE|EE) JVM/
438+
end
439+
440+
it "keeps --jvm as an application argument if given as an application argument" do
441+
script = fixture(__FILE__, "argv.rb")
442+
out = ruby_exe(nil, options: "-v", args: "#{script} --jvm 1 2 #{@redirect}")
443+
check_status_and_empty_stderr
444+
out = out.lines.map(&:chomp)
445+
out[0].should =~ /GraalVM (CE|EE) Native/
446+
out.should.include?('["--jvm", "1", "2"]')
447+
end
448+
end
449+
end
413450
end

0 commit comments

Comments
 (0)