Skip to content

Commit c1f3f64

Browse files
committed
[GR-17457] Be more flexible to detect the "Before lowering" phase
PullRequest: truffleruby/3299
2 parents d65c347 + 9e91e0f commit c1f3f64

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

test/truffle/compiler/graphs/run.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
$tests = 0
44
$failures = 0
55

6-
def test(program, extra = '', shape_expected)
6+
def test(program, shape_expected)
77
$tests += 1
8-
output = `bin/jt -q graph --json --describe #{program} #{extra}`
8+
command = "bin/jt -q graph --json --describe #{program}"
9+
output = `#{command}`
10+
unless $?.success?
11+
abort "`#{command}` failed (#{$?}).\nOutput:\n#{output}\n"
12+
end
913
last_line = output.lines.last.strip
1014

1115
begin
1216
decoded = JSON.parse(last_line, symbolize_names: true)
1317
rescue JSON::ParserError => e
14-
abort "#{program}: could not parse JSON (#{e}):\n#{output}"
18+
abort "ERROR: Could not parse JSON from command `#{command}` (#{e}).\n" \
19+
"JSON line:\n#{last_line}\nFull output:\n#{output}\n"
1520
end
1621

1722
shape_got = decoded

tool/jt.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,15 +2150,19 @@ def graph(*args)
21502150
method_glob_pattern = "Isolated:_#{method_glob_pattern}"
21512151
end
21522152

2153-
dumps = Dir.glob('graal_dumps/*').sort.last
2153+
dumps = Dir.glob('graal_dumps/*').select { |path| File.directory?(path) }.sort.last
21542154
raise 'Could not dump directory under graal_dumps/' unless dumps
21552155
graphs = Dir.glob("#{dumps}/*\\[#{method_glob_pattern}*\\].bgv").sort
21562156
graph = graphs.last
21572157
raise "Could not find graph in #{dumps}" unless graph
21582158

21592159
list = run_gem_test_pack_gem_or_install('seafoam', SEAFOAM_VERSION, '--json', graph, 'list', capture: :out, no_print_cmd: true)
21602160
decoded = JSON.parse(list)
2161-
n = decoded.find { |entry| entry['graph_name_components'].last == 'Before phase org.graalvm.compiler.phases.common.LoweringPhase' }['graph_index']
2161+
graph_names = decoded.map { |entry| entry.fetch('graph_name_components').last }
2162+
before_lowering_regexp = /Before.+Lowering/
2163+
before_lowering = graph_names.index { |name| name =~ before_lowering_regexp }
2164+
raise "Could not find #{before_lowering_regexp.inspect} in #{graph_names}" unless before_lowering
2165+
n = decoded.fetch(before_lowering).fetch('graph_index')
21622166

21632167
json_args = json ? %w[--json] : []
21642168
action = describe ? 'describe' : 'render'

0 commit comments

Comments
 (0)