Skip to content

Commit fa37903

Browse files
committed
[GR-17722] GraalVM tests fixes.
PullRequest: truffleruby/1254
2 parents 57ec7de + 530b639 commit fa37903

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

test/truffle/integration/no_extra_output.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ function check() {
2727

2828
echo "Basic test of the output"
2929

30-
jt --silent ruby -e 'puts 3*4' 1>temp.txt 2>&1
30+
$RUBY_BIN -e 'puts 3*4' 1>temp.txt 2>&1
3131
check $?
3232

3333
echo "Basic test of the output with lazy options disabled"
3434

35-
jt --silent ruby --lazy-default=false -e 'puts 3*4' 1>temp.txt 2>&1
35+
$RUBY_BIN --experimental-options --lazy-default=false -e 'puts 3*4' 1>temp.txt 2>&1
3636
check $?
3737

3838
echo "Test loading many standard libraries"
3939

40-
jt --silent ruby --lazy-default=false test/truffle/integration/no_extra_output/all_stdlibs.rb 1>temp.txt 2>&1
40+
$RUBY_BIN --experimental-options --lazy-default=false test/truffle/integration/no_extra_output/all_stdlibs.rb 1>temp.txt 2>&1
4141
check $?

tool/jt.rb

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,19 @@ def ruby_launcher
185185
return @ruby_launcher if defined? @ruby_launcher
186186

187187
@ruby_name ||= ENV['RUBY_BIN'] || 'jvm'
188-
@ruby_launcher = if @ruby_name == 'ruby'
189-
ENV['RBENV_ROOT'] ? `rbenv which ruby`.chomp : which('ruby')
190-
elsif File.executable?(@ruby_name)
191-
@ruby_name
192-
else
193-
"#{TRUFFLERUBY_DIR}/mxbuild/truffleruby-#{@ruby_name}/#{language_dir}/ruby/bin/ruby"
194-
end
188+
ruby_launcher = if @ruby_name == 'ruby'
189+
ENV['RBENV_ROOT'] ? `rbenv which ruby`.chomp : which('ruby')
190+
elsif File.executable?(@ruby_name)
191+
@ruby_name
192+
else
193+
"#{TRUFFLERUBY_DIR}/mxbuild/truffleruby-#{@ruby_name}/#{language_dir}/ruby/bin/ruby"
194+
end
195195

196-
raise "The Ruby executable #{@ruby_launcher} does not exist" unless File.exist?(@ruby_launcher)
197-
raise "The Ruby executable #{@ruby_launcher} is not executable" unless File.executable?(@ruby_launcher)
196+
raise "The Ruby executable #{ruby_launcher} does not exist" unless File.exist?(ruby_launcher)
197+
ruby_launcher = File.realpath(ruby_launcher)
198+
199+
raise "The Ruby executable #{ruby_launcher} is not executable" unless File.executable?(ruby_launcher)
200+
@ruby_launcher = ruby_launcher
198201

199202
unless @silent
200203
shortened_path = @ruby_launcher.sub(%r[^#{Regexp.escape TRUFFLERUBY_DIR}/], '').sub(%r[/bin/ruby$], '').sub(%r[/#{language_dir}/ruby$], '')
@@ -210,9 +213,12 @@ def ruby_launcher
210213
ENV['RUBY_BIN'] = ruby_launcher
211214
@ruby_launcher
212215
end
213-
214216
alias_method :require_ruby_launcher!, :ruby_launcher
215217

218+
def ruby_home
219+
File.expand_path('../..', ruby_launcher)
220+
end
221+
216222
def truffleruby_native!
217223
unless truffleruby_native?
218224
raise "The ruby executable #{ruby_launcher} is not native."
@@ -239,8 +245,7 @@ def truffleruby_compiler?
239245
return @truffleruby_compiler = true if truffleruby_native?
240246

241247
# Detect if the compiler is present by reading the $graalvm_home/release file
242-
# Use realpath to always use the executable in languages/ruby/bin/
243-
graalvm_home = File.expand_path("../../../..#{'/..' * language_dir.count('/')}", File.realpath(ruby_launcher))
248+
graalvm_home = File.expand_path("..#{'/..' * (language_dir.count('/') + 1)}", ruby_home)
244249
@truffleruby_compiler = File.readlines("#{graalvm_home}/release").grep(/^COMMIT_INFO=/).any? do |line|
245250
line.include?('"compiler":') || line.include?("'compiler':")
246251
end
@@ -907,7 +912,7 @@ def test(*args)
907912
# TODO (eregon, 4 Feb 2019): This should run on GraalVM, not development jars
908913
# The home needs to be set, otherwise TruffleFile does not allow access to files in the TruffleRuby home,
909914
# because it cannot find the correct home.
910-
home = "-Druby.home=#{TRUFFLERUBY_DIR}/mxbuild/truffleruby-jvm/#{language_dir}/ruby"
915+
home = "-Druby.home=#{ruby_home}"
911916
mx 'unittest', home, *tests
912917
when 'tck' then mx 'tck', *rest
913918
else
@@ -1143,7 +1148,7 @@ def retag(*args)
11431148

11441149
# Test that running the post-install hook works, even when opt &
11451150
# llvm-link are not on PATH, as it is the case on macOS.
1146-
sh({'TRUFFLERUBY_RECOMPILE_OPENSSL' => 'true'}, "mxbuild/truffleruby-jvm/#{language_dir}/ruby/lib/truffle/post_install_hook.sh")
1151+
sh({'TRUFFLERUBY_RECOMPILE_OPENSSL' => 'true'}, "#{ruby_home}/lib/truffle/post_install_hook.sh")
11471152

11481153
when 'gems'
11491154
# Test that we can compile and run some real C extensions
@@ -1745,8 +1750,6 @@ def format_time_metrics(*args)
17451750
end
17461751

17471752
def benchmark(*args)
1748-
require_ruby_launcher!
1749-
17501753
vm_args = []
17511754
if truffleruby?
17521755
vm_args << '--experimental-options' << '--engine.CompilationExceptionsAreFatal'

0 commit comments

Comments
 (0)